Commit 1166f8dc authored by DELEFOSSE Alexandre's avatar DELEFOSSE Alexandre
Browse files

TODO: gerer les dependances

parents fc801c7a 51c80174
.settings
bin
\ No newline at end of file
bin
tasks
\ No newline at end of file
......@@ -21,6 +21,10 @@
<target name="clean" depends="init">
<delete dir="${bin}" />
<delete>
<dirset dir="." includes="TEST*" />
<fileset dir="." includes="TEST*" />
</delete>
<mkdir dir="${bin}" />
<echo>Cleaning Done </echo>
</target>
......
File added
......@@ -5,7 +5,7 @@ use fr.isima.myant.MkDirTask as mkdirtask
default:other,!
echo[message:"Starting... "]
echotask[message:"value1"]
mkdirtask[dir:"blabla"]
mkdirtask[dir:"tasks/TEST"]
echo[message:"Completed! "]
-
other:!
......@@ -13,5 +13,5 @@ echo[message:"Starting... "]
echotask[message:"un"]
echotask[message:"autre"]
echotask[message:"message"]
cptask[from:"mybuild.txt", to:"testLALALA.txt"]
cptask[from:"mybuild.txt", to:"tasks/TEST.txt"]
echo[message:"Completed! "]
\ No newline at end of file
package fr.isima.myant;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.Paths;
......@@ -20,14 +21,15 @@ public class CopyTask extends Task {
this.to = to;
}
public CopyTask() {
}
public CopyTask() {}
public void execute() {
try {
Files.copy(Paths.get(from), Paths.get(to));
} catch (FileAlreadyExistsException e) {
System.out.println("CopyTask: Le fichier "+ to +" existe deja.");
} catch (Exception e) {
System.out.println("\tErreur: copytask");
}
}
}
......@@ -5,7 +5,6 @@ public class Main {
public static void main(String[] args) {
System.out.println("Init...");
Project p = new Project("test");
p.init();
p.loadFromFile();
System.out.println("Init Done \n");
......
......@@ -13,8 +13,7 @@ public class MkDirTask extends Task {
this.dir = dir;
}
public MkDirTask() {
}
public MkDirTask() {}
public void execute() {
File theDir = new File(dir);
......
......@@ -35,17 +35,6 @@ public class Project {
this.addTarget(t);
}
private boolean targetExist(String name) {
boolean bool=false;
for(Target t : targets) {
if (t.getName().equals(name))
bool = true;
}
return bool;
}
public void loadFromFile() {
String fileName = "mybuild.txt";
String line = null;
......@@ -69,24 +58,25 @@ public class Project {
if(!line.equals("-")) {
targetName = line.split(":")[0];
List<String> dependencies = new ArrayList<String>();
System.out.println("Starting task " + nTask);
System.out.println(targetName);
Target target_current = new Target(targetName);
int indice=0;
while(!line.split(":")[1].split(",")[indice].equals("!")) {
dependencies.add(line.split(":")[1].split(",")[indice]);
//DEPENDENCY LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
System.out.println("Nouvelle Dependence: -" + line.split(":")[1].split(",")[indice] + "-");
indice++;
}
if(!targetExist(targetName))
targets.add(new Target(targetName));
line = bufferedReader.readLine();
//Echo : message
line = bufferedReader.readLine();
while(!line.split("\\[")[0].equals("echo")) {
......@@ -110,25 +100,21 @@ public class Project {
fieldName.add(line.split(":")[i].split(" ")[1]);
}
for(Target t : targets) {
if (t.getName().equals(targetName)) {
try {
Task instance = (Task) clazz.newInstance();
Field fields [] = clazz.getDeclaredFields();
for(int j=0; j<fieldName.size(); j++) {
for(int i=0; i<fields.length; i++) {
if (fieldName.get(j).equals(fields[i].getName())) {
fields[i].setAccessible(true);
fields[i].set(instance, attributs.get(j));
}
}
try {
Task instance = (Task) clazz.newInstance();
Field fields [] = clazz.getDeclaredFields();
for(int j=0; j<fieldName.size(); j++) {
for(int i=0; i<fields.length; i++) {
if (fieldName.get(j).equals(fields[i].getName())) {
fields[i].setAccessible(true);
fields[i].set(instance, attributs.get(j));
}
t.addTask(instance);
} catch (Exception e) {
e.printStackTrace();
}
}
target_current.addTask(instance);
} catch (Exception e) {
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
......@@ -138,6 +124,7 @@ public class Project {
}
line = bufferedReader.readLine();
}
targets.add(target_current);
System.out.println("Completed task " + nTask++);
}
}
......
package fr.isima.myant;
public class Task {
public void execute() {
}
public void execute() {}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment