Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-dev] Tycho Extension with custom project type

Igor/all,

I investigated a bit further and I think I’m closer to the root cause of the problem.

1. My plug-in contributes a custom packaging type. Therefore, I have to set <extensions>true</extensions>.

2. This in turn triggers org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant to be found on the class path of my plug-in. Maven (Plexus?) sees the annotation and registers it as  build lifecycle component.

3. Both instances of TychoMavenLifecycleParticipant are loaded with different class loaders. From my readings it seems that this is a design feature of Maven so that plug-in contributing extensions don’t screw up Maven core. ("When build extensions refer to the same group id, artifact id, version and dependencies, they will use the same extension class loader. Otherwise, each extension gets its own class loader.“) [1]

4. Now (depending on timing) either mine or Tycho’s one get registered first. The one which triggers first is the first one to create a ReactoreProject and store it in the project context. Because both are loaded with different class loader, the one that comes later sees the instance but of course the cast fails.


So now I have a few more questions:

A) Is it possible to tell Maven (Plexus?) to ignore @Component annotated classes from dependencies? FWIW, I tried with changing the scopes and types dependencies in my Maven plug-in pom to provided, maven-plugin, etc. but without luck. When I set them to "provided" then my plugin fails with ClassNotFoundExceptions.

B) Any advice on an alternate approach?  FWIW, my goal is to use/integrate with Tycho for the following things: build qualifier computation and expansion based on Git timestamps, generating p2 metadata for OSGi artifacts produced by my plug-in (one bundle jar and a corresponding source bundle jar) and (optional) contribution of the artifacts (bundle and source bundle) to the current reactor build so that a later module (eg. eclipse-feature and eclipse-repository) can include them in their output. However, the last part is optional. I could also just publish the artifacts (including p2 metadata?) into a local Maven repository and the use a separate run to fetch them. 

Thanks!

-Gunnar

[1] https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Class+Loading

-- 
Gunnar Wagenknecht
gunnar@xxxxxxxxxxxxxxx







Back to the top