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

Do you want to resolve original jar and sources-jar from maven
repositories or these will be checked-in in git?

Frankly, what you are trying to do is not currently supported and may
not be possible at all. Classloading issues aside, you need to generate
bundle manifest and corresponding p2 metadata from P2MetadataProvider,
which is invoked before actual build starts and conceptually is too
early for any resource generation.

Since you need bundle manifest and corresponding p2 metadata generated
before project build, you don't need a maven plugin. A simple jar that
is added as <dependency> of tycho-maven-plugin should make your new
packaging tycho and extra components available to tycho core, which
maybe enough for what you need.

If you can split "generate bundle" and "generate p2 repository" into two
separate builds, this will give you more flexibility and this is more
inline with what is currently supported.

Maybe Jan or Tobias have other ideas.


On 2/1/2014, 4:19, Gunnar Wagenknecht wrote:

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.




Back to the top