How to use Eclipse Ant Task from Java Code [message #68801] |
Wed, 22 July 2009 13:10  |
Eclipse User |
|
|
|
Hi everyone,
I have spent lot of time trying to solve my problem and maybe you could
help me.
My question is quite simple: I have a build.xml file with some targets
ans tasks. Some of these tasks are Eclipse task, like:
eclipse.refreshLocal
qvto:transformation
jet.transform
My build.xml file is executed without problems if I launch it as
External Tool - Ant Build setting the "Run in the same JRE as the
workspace" property as usual.
The problem is when I want to launch my build.xml not from Java code
instead of from External Tool.
The code is below:
----------------------------------------------
private void execute() {
//Get written values
String preguiValue = (String)this.preguiCB.getSelectedItem();
String presecumlValue = (String)this.presecumlCB.getSelectedItem();
String roleValue = (String)this.roleCB.getSelectedItem();
Project project = new Project();
ByteArrayOutputStream out = null;
out = new ByteArrayOutputStream();
project.addBuildListener(UpdateModelsJFrame.createLogger( out ));
//project.setInputHandler(getProject().getInputHandler());
project.init();
File buildFile = new File("build.xml");
ProjectHelper.configureProject( project, buildFile);
project.setProperty("nameModel","PhoneBook2");
project.executeTarget("jet");
}
private static BuildLogger createLogger( ByteArrayOutputStream out ){
BuildLogger logger = null;
logger = new DefaultLogger();
logger.setMessageOutputLevel(Project.MSG_INFO);
logger.setOutputPrintStream(new PrintStream( out ));
logger.setErrorPrintStream(new PrintStream( out ));
logger.setEmacsMode(false);
return logger;
}
---------------------------------------------------
I get this error message:
---------------------------------------------------------
Exception in thread "AWT-EventQueue-0"
/home/miguel/eclipse/workspace/app.updatePreguiPresecModels/ build.xml:62:
Problem: failed to create task or type eclipse.refreshLocal
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.
-----------------------------------------------------------
How con I set the classical "Run in the same JRE as the workspace"
property but programmatically?
In other words: How can I lunch my build.xml Ant file from Java code in
the same time this file can access to these task??
Thank you in advance!
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.26348 seconds