Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » AntRunner vs Eclipse Indigo(Plugin Eclipse Indigo throwing InvocationTargetException)
icon5.gif  AntRunner vs Eclipse Indigo [message #770232] Fri, 23 December 2011 17:45 Go to next message
Raphael Moita is currently offline Raphael MoitaFriend
Messages: 25
Registered: September 2011
Junior Member
Hi guys,

I'm facing an issue when I run a plugin in Eclipse Indigo/Helios.

This plugin works perfectly in Eclipse Galileo.

The plugin itself just call an ant build that is in the local box filesystem thru AntRunner class. This build file uses a custom task that create in runtime other tasks. I worked in a simple example in order to exemplify better the situation:

Custom Task:
package com.test;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.RuntimeConfigurable;
import org.apache.tools.ant.Target;
import org.apache.tools.ant.Task;

public class Ant extends Task {

	@Override
	public void execute() throws BuildException {
		Task task = this.getProject().createTask("copy");
		RuntimeConfigurable rc = new RuntimeConfigurable(task, task.getTaskName());
		rc.setAttribute("file", "/temp/file1.txt");
		rc.setAttribute("todir", "/temp/folder1");
		Target target = new Target();		
		target.addTask(task);
		target.execute();
		super.execute();
	}
}


The code above is used to generate the jar file used by build.xml below as custom a task:

Build.xml
<?xml version="1.0"?>
<project name="SimpleAntTask" default="test" basedir=".">

	<taskdef name="test" classname="com.test.Ant">
	        <classpath>
			<pathelement location="${file.separator}temp${file.separator}simple_ant_test_1.0.0.jar"/>
		</classpath>
	</taskdef>
	
	<target name="test">
		<test/>
	</target>

</project>


So far so good. Both Build.xml and simple_ant_test_1.0.0.jar are in temp folder and working fine.

The issue started when I tried to run it thru an Eclipse Plugin. The caller build.xml code is described below:

package com.test;

import java.util.HashMap;

import org.eclipse.ant.core.AntRunner;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.CoreException;

public class SimpleAntTestHandler extends AbstractHandler {
	private static String CUSTOM_BUILD_XML_FILE = "/temp/build.xml";
	private static String BUILD_XML_TARGET = "test";

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		try {
			AntRunner runner = new AntRunner();
			runner.setBuildFileLocation(CUSTOM_BUILD_XML_FILE);
			runner.setExecutionTargets(new String[] { BUILD_XML_TARGET });
			runner.run();
		} catch (CoreException e) {
			e.printStackTrace();
		}

		return null;
	}	
}


When this plugin is executed (in a simple eclipse menu) a NullPointerExcpetion is thrown. In order to go deeper debuging the code I've included the Ant source code and I figured out that the real exception is an InvocationTargetException.

Does someone know what was the changes on Eclipse that can be caused such different behavior on it?

Any help will be extremely appreciated.

Merry Christimas and Happy New 2012
--
Raphael Moita
Re: AntRunner vs Eclipse Indigo [message #774033 is a reply to message #770232] Tue, 03 January 2012 06:02 Go to previous message
Michael Rennie is currently offline Michael RennieFriend
Messages: 67
Registered: July 2009
Location: Canada
Member
It would help if you could paste the entire exception thrown by Ant here.

From what I see, it should be working (as you are expecting).
Previous Topic:Using Run
Next Topic:File tabs disappeared
Goto Forum:
  


Current Time: Wed Apr 24 14:38:47 GMT 2024

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

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

Back to the top