| How to use Eclipse Ant Task from Java Code [message #68801] |
Wed, 22 July 2009 13:10  |
Miguel Angel Garcia de Dios Messages: 22 Registered: July 2009 |
Junior Member |
|
|
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!
|
|
|
|
| Re: How to use Eclipse Ant Task from Java Code [message #559903 is a reply to message #68829] |
Mon, 20 September 2010 06:14   |
Deepak Singla Messages: 27 Registered: December 2009 |
Junior Member |
|
|
eclipse.refreshLocal is used for resreshing your worksapce.
For eclipse.refreshLocal ant task Following may help you:
From the main menu select the Run -> External Tools -> Select External Tools again and then select your XML from under Ant Build. There are a series of tabs on the next menu including a scroll bar which you must select and scroll right until JRE appears. Then change the radion button to "Run in the same JRE as the workspace". That should do it.
This helped for me.
[Updated on: Mon, 20 September 2010 06:20] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01779 seconds