Bonsoir à tous,
en fait, j'utilise eclipse.
j'ai un task en ANT qui marche correctement avec run as => ANT Build
maintenant, je veux l'exécuter à partir de java.
j'ai trouvé un code sur le net
mais ça marche pas!
public class ANTToolchain {
public static void main(String[] args) throws IOException {
File buildFile = new File("build.xml");
Project p = new Project();
p.setUserProperty("ant.file", buildFile.getAbsolutePath());
p.init();
ProjectHelper helper = ProjectHelper.getProjectHelper();
p.addReference("ant.projectHelper", helper);
helper.parse(p, buildFile);
p.executeTarget(p.getDefaultTarget());
}
}
j'ai comme erreur
Exception in thread "main" /Users/Modeling/workspace/project.toolchain/build.xml:6: Problem: failed to create task or type .....
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
at org.apache.tools.ant.UnknownElement.getNotFoundException(UnknownElement.java:487)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:419)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
at org.apache.tools.ant.Task.perform(Task.java:347)
at org.apache.tools.ant.Target.execute(Target.java:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at project.toolchain.ANTToolchain.main(ANTToolchain.java:65)
![]()
Partager