Hi sahoo,
Just now, I found an interesting thing of fighterfish as following:
I have a background that in some module of fighterfish(eg.
glassfish-obr-builder), I want to add some dependencies related to
jersey into the module's pom file. For example,
...
<properties>
<hk2.version>1.1.0</hk2.version>
<jersey.version>2.0-m11</jersey.version>
<jax-rs-api.version>2.0-m15</jax-rs-api.version>
</properties>
...
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${jax-rs-api.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey.version}</version>
</dependency>
...
Here, fighterfish uses com.sun.enterprise:hk2-maven-plugin 1.1.0.
While building the module, you will see the following exception:
...
[INFO] Building Builds OBR from a set of OSGi bundles 4.0-SNAPSHOT
。。。
[WARNING] The POM for org.glassfish.hk2:hk2-api:jar:1.1.0 is missing, no
dependency information available
[WARNING] The POM for org.glassfish.hk2:hk2-locator:jar:1.1.0 is
missing, no dependency information available
...
[INFO] BUILD FAILURE
...
[ERROR] Failed to execute goal on project glassfish-obr-builder: Could
not resolve dependencies for project
org.glassfish.main:glassfish-obr-builder:jar:4.0-SNAPSHOT: The following
artifacts could not be resolved: org.glassfish.hk2:hk2-api:jar:1.1.0,
org.glassfish.hk2:hk2-locator:jar:1.1.0: Failure to find
org.glassfish.hk2:hk2-api:jar:1.1.0 in
http://repo1.maven.org/maven2/
was cached in the local repository, resolution will not be reattempted
until the update interval of maven-central has elapsed or updates are
forced -> [Help 1]
The above exception info is very curious because I do not declare any
dependecy with group:artifactId called "org.glassfish.hk2:hk2-api:1.1.0".
However, by some investigation, I have found the reason as following:
In org.glassfish.jersey.core:jersey-server:2.0-m11's pom, jersey-server
has some hk2 dependencies as following:
<dependency>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-api</artifactId>
</dependency>
...
Noting: here, jersey-server does not specify hk2-api's <version>.
Although hk2-api's <version> has been specified by jersey-server's
parent pom as following:
...
<hk2.version>2.1.51</hk2.version>
...
However, while specifying <hk2.version> in glassfish-obr-builder module,
the <hk2.version> version has higher priority than jersey-server's
parent pom.
So, while building glassfish-obr-builder module, maven will find
org.glassfish.hk2:hk2-api:jar:1.1.0 rather than
org.glassfish.hk2:hk2-api:jar:2.1.51.
Fixing way is that in fighterfish modules, while wishing to declare
jersey dependencies, rather than defining
<hk2.version>1.1.0</hk2.version> property, you can write
hk2-maven-plugin's version as 1.1.0 directly.
Thanks
--Tang