Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Activator class is not invoked when executing an Ant task(Activator class is not invoked when executing an Ant task)
Activator class is not invoked when executing an Ant task [message #1002279] Fri, 18 January 2013 09:55 Go to next message
Rosa Mising name is currently offline Rosa Mising nameFriend
Messages: 16
Registered: December 2009
Junior Member
I am working with Eclipse. I have created a plugin A that has a class A and a build.xml file.
Build.xml file defines a new task that invokes class A.
Class A has an execute() method that invokes class B. Class B is located in another plugin and I need that the Activator.start(...) method of this plugin is invoked.
However, it doesn't happen.
In fact, I also verified that Activator class in plugin A is not invoked either.
"Activate this plugin when one of its classes are loaded" check box is checked in both plugins.
Please, I need help to understand why Activator classes are not invoked.

Thanks a lot. Rosa
Re: Activator class is not invoked when executing an Ant task [message #1002825 is a reply to message #1002279] Sat, 19 January 2013 14:55 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
So you're developing your code as Eclipse plug-ins and run it as Ant tasks?
How should Ant know about Eclipse plug-ins?
Activators are only envoked when your code runs within an OSGi container like Equinox.
best,
Stephan
Re: Activator class is not invoked when executing an Ant task [message #1003429 is a reply to message #1002825] Mon, 21 January 2013 08:13 Go to previous messageGo to next message
Rosa Mising name is currently offline Rosa Mising nameFriend
Messages: 16
Registered: December 2009
Junior Member
Yes, my code are plugins. To summarize, this is the situation:
I have been investigating a bit more the problem and I think there are some concepts that I don't understand very well. The point is that I have a very simple plugin with MyHelloWorldTask class. When I execute the following command line:
java -jar org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar -console -data myRuntimeWorkspace -application org.eclipse.ant.core.antRunner -buildfile myDevelopmentWorkspace\build.xml
The OSGI environment has my plugin installed and started, so I see that the Activator class is invoked because some println methods located in start() method are printed and everything works fine. I added in the start() method something like "this.getDefault()" and it returns a correct value. However, when the code in MyHelloWorldTask.execute() method invokes Activator.getDefault() it returns null (in fact my code needs to access to the Activator to retrieve some extensions info such as
IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(
Activator.getContext().getBundle().getSymbolicName(), "generators");

I don't understand why Activator.getDefault returns null when it is invoked from MyHelloWorldTask because I verified that the plugin is started, so it seems as if 2 different Activator instances were used. An another thing probably related to that: why Ant needs a classpath when it is executed in an OSGI environment such as Eclipse (headless or normal) ? Do Ant and Equinox share the same VM or are they using different VM ?

Thanks a lot for your help.
Re: Activator class is not invoked when executing an Ant task [message #1003481 is a reply to message #1002825] Mon, 21 January 2013 10:36 Go to previous messageGo to next message
Rosa Mising name is currently offline Rosa Mising nameFriend
Messages: 16
Registered: December 2009
Junior Member
Platform.getBundle(Activator.PLUGIN_ID). It returns the bundle id that we see in OSGI environment for my plugin A.

So, as a by pass, there is one way to force the Activator of plugin A to be initialized in AntRunner is the following one:
BundleContext context = Platform.getBundle(Activator.PLUGIN_ID).getBundleContext();
new Activator().start(context);

However, I would like to know the answers to my previous post, to understand all the picture and to evaluate if this by-pass is good enough or not.

Thanks.

Re: Activator class is not invoked when executing an Ant task [message #1003587 is a reply to message #1003429] Mon, 21 January 2013 15:12 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Easy answer first:
Rosa Mising name wrote on Mon, 21 January 2013 09:13
Do Ant and Equinox share the same VM or are they using different VM ?


You decide: when creating a launch configuration for an Ant Build, go to the JRE tab and find "( ) Run in the same JRE as the workspace".

HTH,
Stephan
Previous Topic:JSP include from other project - false error
Next Topic:xprof argument
Goto Forum:
  


Current Time: Sat Apr 20 05:20:59 GMT 2024

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

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

Back to the top