Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » Load-time weaving of maven dependencies of eclipse plugin
Load-time weaving of maven dependencies of eclipse plugin [message #1105733] Tue, 10 September 2013 08:01 Go to next message
Marek Jagielski is currently offline Marek JagielskiFriend
Messages: 97
Registered: April 2012
Member
Hi,
I'm working on eclipse extension split to many plugins. One of them is plugin.libs that contains all needed non-osgi libraries. To do this I use plugins

<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>

I declared needed libraries in maven dependencies. To be able to run and debug this plugin correctly from eclipse launch, I needed to export maven dependencies in .classpath:
<classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>

Library jars are inside target jar.
Up to now everything works correctly.

For one of my dependencies I needed to introduce aspects. I used maven plugin

<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>

with configuration

<weaveDependencies>
<weaveDependency><groupId>my.dependency</groupId><artifactId>my.dependency.api</artifactId></weaveDependency>
</weaveDependencies>

and put my aspects into plugin.libs project. My solution works as espected. Library in target jar is extracted and in bytecode I can see introduceed aspects. When I install my plugins in other instance of eclipse (through update site) I confirm that apsects are executed.

Now I would like to run and debug my plugins in development environment. However, eclipse is taking into account maven dependencies of plugin.libs that are in local maven repository where aspects are not introduced.

My idea is to run eclipse with load-time weaving aspects. I've done something similar before with a standalone applicaction where I had added this in .classpath

<classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.ajdt.inpath" value="org.eclipse.ajdt.inpath"/>
</attributes>
</classpathentry>

My question is. How to run with ajdt the eclipse plugins with load-time weaving.

Thanks in advance,

Marek
Re: Load-time weaving of maven dependencies of eclipse plugin [message #1105803 is a reply to message #1105733] Tue, 10 September 2013 09:42 Go to previous messageGo to next message
Marek Jagielski is currently offline Marek JagielskiFriend
Messages: 97
Registered: April 2012
Member
I tried also EW as it is at http://wiki.eclipse.org/Equinox_Weaving_QuickStart. It seems (if I done it correctly) that is not working in case of maven dependencies.
Marek
Re: Load-time weaving of maven dependencies of eclipse plugin [message #1106021 is a reply to message #1105733] Tue, 10 September 2013 15:24 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
I'm a bit unclear as to what you are trying to do. You say you are creating an Eclipse plugin, but I only see maven artifacts. Is it that one of your OSGi bundles is packaged as a bunch of jar files from maven?

Show me the MANIFEST.MF from this bundle and all the bundles that are involved with weaving.

And if you are using OSGi and LTW, then you must use Equinox Weaving.
Re: Load-time weaving of maven dependencies of eclipse plugin [message #1106055 is a reply to message #1106021] Tue, 10 September 2013 16:18 Go to previous messageGo to next message
Marek Jagielski is currently offline Marek JagielskiFriend
Messages: 97
Registered: April 2012
Member
My plugin com.systemincloud.modeler.libs MANIFEST is generated automatically by felix maven plugin:

			<plugin><groupId>org.apache.felix</groupId><artifactId>maven-bundle-plugin</artifactId>
				<extensions>true</extensions>
				<configuration>
					<instructions>
						<Bundle-ManifestVersion>2</Bundle-ManifestVersion>
						<Bundle-SymbolicName>${project.artifactId};singleton:=true</Bundle-SymbolicName>
						<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
						<Embed-Transitive>true</Embed-Transitive> 
						<_exportcontents>
						    org.codehaus.plexus.*,
						    org.apache.commons.*,
							com.systemincloud.api.*,
							com.systemincloud.modeler.api.*,
							com.google.common.*,
							javax.ws.rs.*
						</_exportcontents>
						<Import-Package></Import-Package>
						<Bundle-ClassPath>.,{maven-dependencies}</Bundle-ClassPath>
						<Embed-Transitive>true</Embed-Transitive>
						<Embed-Directory></Embed-Directory>
						<Bundle-Vendor>System in Cloud</Bundle-Vendor>
						<Bundle-RequiredExecutionEnvironment>JavaSE-1.7</Bundle-RequiredExecutionEnvironment>
						<_failok>true</_failok>
						<_nouses>true</_nouses>
						<_nodefaultversion>true</_nodefaultversion>
              			<_snapshot>${osgi-version-qualifier}</_snapshot>
					</instructions>
				</configuration>
			</plugin>



It gives :
Manifest-Version: 1.0
Bnd-LastModified: 1378825676440
Build-Jdk: 1.7.0_25
Built-By: marek
Bundle-ClassPath: .,com.systemincloud.modeler.api.javatask-0.1.0-SNAPSHO
 T.jar,com.systemincloud.api.java-0.1.0-SNAPSHOT.jar,com.systemincloud.a
 pi.java.msg-0.1.0-SNAPSHOT.jar,com.systemincloud.api.machine.java-0.1.0
 -SNAPSHOT.jar, (... a lot more)
Bundle-ManifestVersion: 2
Bundle-Name: System in Cloud Modeler - Libs
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-SymbolicName: com.systemincloud.modeler.libs;singleton:=true
Bundle-Vendor: System in Cloud
Bundle-Version: 0.1.0.qualifier
Created-By: Apache Maven Bundle Plugin
Embed-Dependency: *;scope=compile|runtime
Embed-Transitive: true
Embedded-Artifacts: com.systemincloud.modeler.api.javatask-0.1.0-SNAPSHO
 T.jar;g="com.systemincloud.modeler.api";a="com.systemincloud.modeler.ap
 i.javatask";v="0.1.0-SNAPSHOT",com.systemincloud.api.java-0.1.0-SNAPSHO
 T.jar;g="com.systemincloud.api";a="com.systemincloud.api.java";v="0.1.0
 -SNAPSHOT",(... a lot more)
Export-Package: org.apache.commons.io;version="1.4.9999",org.apache.comm
 ons.io.input;version="1.4.9999",org.apache.commons.io.filefilter;versio
 n="1.4.9999",org.apache.commons.io.output;version="1.4.9999",org.apache
 .commons.io.monitor;version="2.4",org.apache.commons.cli;version="1.2",
 org.apache.commons.io.comparator;version="1.4.9999",com.systemincloud.a
 pi.machine.java.websocket.jwebsocket,com.systemincloud.api.java.cmd,com
 .systemincloud.api.machine.java,com.systemincloud.api.machine.java.msg,
 com.systemincloud.api.machine.java.websocket,com.systemincloud.api.java
 .msg,com.systemincloud.api.java.msg.args,(... a lot more)
Tool: Bnd-1.50.0



I want to weave one of libraries that are inside of target bundle. With maven I compile aspects and the library is extracted inside bundle jar.

Marek
Re: Load-time weaving of maven dependencies of eclipse plugin [message #1106079 is a reply to message #1106055] Tue, 10 September 2013 17:04 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
OK, I am starting to see what you want to do. In general, if you have all of the artifacts that you want to weave in one place already, then you are best off using compile time weaving. This might be possible if you use the aspectj-maven-plugin for compiling. If you use the aspectj configurator for m2e, it should configure your projects properly for the pom file that you have.


If you really want to use Equinox Weaving, then you need to add extra things to your pom file as well as to your launch configuration.
Re: Load-time weaving of maven dependencies of eclipse plugin [message #1106215 is a reply to message #1106079] Tue, 10 September 2013 21:02 Go to previous messageGo to next message
Marek Jagielski is currently offline Marek JagielskiFriend
Messages: 97
Registered: April 2012
Member
Thanks Aandrew,
Yes, I am already using aspectj-maven-plugin to make compile time weaving. Problem I have is to debug my plugins. Other bundles hadn't seen libraries that were inside bundle com.systemincloud.modeler.libs. It is why I changed .classpath file of com.systemincloud.modeler.libs with adding 'exported="true"' for the maven dependencies. Maybe It should be done in other way. As I observed, during debugging, other plugins are using libraries from my local maven repo .m2/repositories.
The problem showed up when I introduced aspects to the project. Compile time weaved libraries are well inside com.systemincloud.modeler.libs bundle jar. However, when debugging, other plugins are still using not weaved libraries from my maven repo.
Maybe there is a better solution to tell eclipse to use entirely plugin com.systemincloud.modeler.libs and not to choose from maven repo.
Marek
Re: Load-time weaving of maven dependencies of eclipse plugin [message #1106256 is a reply to message #1106215] Tue, 10 September 2013 22:20 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
OK, so now I'm losing you again. It seems like you are saying that your build is OK, but that you can't debug. Are you weaving into compiled jars? If so, you should specify the inpath out folder for the project. This can be set in Project -> Preferences -> AspectJ build -> In Path Out folder.

I am guessing that you are running as an Eclipse application. If so, you will need to add the inpath out folder as a classpath entry to your bundle and make sure it is higher up than the other entries so that it overrides them.
Re: Load-time weaving of maven dependencies of eclipse plugin [message #1107472 is a reply to message #1106256] Thu, 12 September 2013 12:56 Go to previous message
Marek Jagielski is currently offline Marek JagielskiFriend
Messages: 97
Registered: April 2012
Member
Thank you for your time Andrew,

For now, I am holding up on this issue for a while. I will give here my solution as soon as I will come back to this problem and resolve it.

Marek
Previous Topic:roxy Authentication Required
Next Topic:Adding annotation to methods & their parameters
Goto Forum:
  


Current Time: Fri Mar 29 14:10:14 GMT 2024

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

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

Back to the top