Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » How to use Eclipse Ant Task from Java Code
How to use Eclipse Ant Task from Java Code [message #599804] Wed, 22 July 2009 17:10
Miguel Angel Garcia de Dios is currently offline Miguel Angel Garcia de DiosFriend
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!
Previous Topic:Debugging org.eclipse.compare
Next Topic:Create project in headless mode
Goto Forum:
  


Current Time: Thu Apr 18 22:45:36 GMT 2024

Powered by FUDForum. Page generated in 0.01652 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top