Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Adding absolute agent path to jvm arg (How to add an absolute path in eclipse.ini jvm args to launch an agent)
Adding absolute agent path to jvm arg [message #488082] Fri, 25 September 2009 14:13 Go to next message
Nicolas Mising name is currently offline Nicolas Mising nameFriend
Messages: 3
Registered: September 2009
Junior Member
Hello there,
I am writing an eclipse plugin which need an agent to be attached to the eclipse launching JVM.

Manually, I just add the following jvmarg line in the eclipse.ini:

-agentpath:/home/user/eclipse/plugins/myplugin_version/libag ent.so

That is working perfectly, but need the user to perform a manual task after installing my plugin.

I would like to automate this line adding procedure using p2.
I found some documentation about the addJvmArg p2.inf directive.

So, in my plugin META-INF folder, I wrote a p2.inf that looks like this:
instructions.install = \
    addJvmArg(jvmArg:-agentpath:@artifact/libagent.so);
instructions.install.import= \
    org.eclipse.equinox.p2.touchpoint.eclipse.addJvmArg,


Then, generating the metadata, I can found this part of generated code in content.xml:
<instruction key='install' import='org.eclipse.equinox.p2.touchpoint.eclipse.addJvmArg,'>
            addJvmArg(jvmArg:-agentpath:@artifact/libagent.so);
          </instruction>


In a fresh eclipse install, I install my plugin, using the previous content.xml as metadata, then looks in the resulting eclipse.ini.
-startup
plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.0.200.v20090520
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vmargs
-Xms40m
-Xmx256m
-agentpath:@artifact/libagent.so


The @artifact is not replaced by path of artifact Sad

I have seen the bug report https://bugs.eclipse.org/bugs/show_bug.cgi?id=273480 that seems to looks like this, but has been workarounded.

Is someone has already done this kind of p2 custom?
Any idea to do this agent attach task?

Thanks for your p2 lights Razz
Re: Adding absolute agent path to jvm arg [message #488122 is a reply to message #488082] Fri, 25 September 2009 15:42 Go to previous messageGo to next message
Andrew Niefer is currently offline Andrew NieferFriend
Messages: 990
Registered: July 2009
Senior Member
It doesn't look like the @{artifact} is handled by the addJvmArg action. The workaround in the bug only helps for -D system property vm args.

The only thing I can think of would be to have your p2.inf explicitly hard code the plugins/myplugin_version/libagent.so.

addJvmArg(jvmArg:-agentpath:${installFolder}/plugins/myplugin_version/libagent.so);


This would only work for normal shaped installs, and would require you to modify the p2.inf at build time. You could use something like "myplugin_@version@" in the source, and then use custom build callbacks to change it with something like: (this assumes you are including the p2.inf in your binary bundle).

build.properties: 
    customBuildCallbacks=true
    customBuildCallbacks.inheritall=true
customBuildCallbacks.xml :
<target name="post.gather.bin.parts">
   <replace file="${target.folder}/META-INF/p2.inf" token="@version@" value="${bundleVersion}" />
</target>


Nicolas wrote on Fri, 25 September 2009 10:13
Hello there,
I am writing an eclipse plugin which need an agent to be attached to the eclipse launching JVM.

Manually, I just add the following jvmarg line in the eclipse.ini:

-agentpath:/home/user/eclipse/plugins/myplugin_version/libag ent.so

That is working perfectly, but need the user to perform a manual task after installing my plugin.

I would like to automate this line adding procedure using p2.
I found some documentation about the addJvmArg p2.inf directive.

So, in my plugin META-INF folder, I wrote a p2.inf that looks like this:
instructions.install = \
    addJvmArg(jvmArg:-agentpath:@artifact/libagent.so);
instructions.install.import= \
    org.eclipse.equinox.p2.touchpoint.eclipse.addJvmArg,


Then, generating the metadata, I can found this part of generated code in content.xml:
<instruction key='install' import='org.eclipse.equinox.p2.touchpoint.eclipse.addJvmArg,'>
            addJvmArg(jvmArg:-agentpath:@artifact/libagent.so);
          </instruction>


In a fresh eclipse install, I install my plugin, using the previous content.xml as metadata, then looks in the resulting eclipse.ini.
-startup
plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.0.200.v20090520
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vmargs
-Xms40m
-Xmx256m
-agentpath:@artifact/libagent.so


The @artifact is not replaced by path of artifact Sad

I have seen the bug report https://bugs.eclipse.org/bugs/show_bug.cgi?id=273480 that seems to looks like this, but has been workarounded.

Is someone has already done this kind of p2 custom?
Any idea to do this agent attach task?

Thanks for your p2 lights Razz

Re: Adding absolute agent path to jvm arg [message #488134 is a reply to message #488122] Fri, 25 September 2009 16:07 Go to previous message
Nicolas Mising name is currently offline Nicolas Mising nameFriend
Messages: 3
Registered: September 2009
Junior Member
What a fast and accurate response.
I wonder why I wait so long before asking Smile

Thanks very much for this.

This ${installFolder} is doing the job.
I will use my ant build to replace @plugin_version@ with my plugin version at packaging/delivery time.

Thx again.
Re: Adding absolute agent path to jvm arg [message #488136 is a reply to message #488122] Fri, 25 September 2009 16:00 Go to previous message
Andrew Niefer is currently offline Andrew NieferFriend
Messages: 990
Registered: July 2009
Senior Member
Andrew Niefer wrote:
> This would only work for normal shaped installs, and would require you
> to modify the p2.inf at build time. You could use something like
> "mailto:myplugin_@version@" in the source, and then use
<snip>

For those reading this on NNTP, this should have read
"myplugin_@version@". It seems the forum software was over-aggressive
in identifying email addresses and replacing them with a link.

I raised https://bugs.eclipse.org/bugs/show_bug.cgi?id=290566
Previous Topic:Are there any hidden equinox console features?
Next Topic:Tracking down a package uses conflict.
Goto Forum:
  


Current Time: Thu Apr 25 12:50:06 GMT 2024

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

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

Back to the top