When using "bundle" with targets, maven-bundle-plugin runs twice
I have a (simple) maven project with "bundle" packaging type using org.apache.felix:maven-bundle-plugin:2.5.4
. It creates the correct jar with the OSGI package. However, I observe that all goals are met at least twice. How can I prevent this? The problem is that some targets (checkstyle in this example) are slow, so the duplication problem is the problem here.
NOTE : I am using maven 3.2.5 from the command line.
Output or mvn clean install
(removed all irrelevant data). Note that many plugins are executed 4 times. maven-checkstyle-plugin
runs twice.
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ my-project ---
[INFO] --- maven-enforcer-plugin:1.4:enforce (enforce-maven) @ my-project ---
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ my-project ---
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ my-project ---
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ my-project ---
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ my-project ---
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ my-project ---
[INFO] >>> maven-bundle-plugin:2.5.4:bundle (default-bundle) > package @ my-project >>>
[INFO] --- maven-enforcer-plugin:1.4:enforce (enforce-maven) @ my-project ---
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ my-project ---
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ my-project ---
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ my-project ---
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ my-project ---
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ my-project ---
[INFO] <<< maven-bundle-plugin:2.5.4:bundle (default-bundle) < package @ my-project <<<
[INFO] --- maven-bundle-plugin:2.5.4:bundle (default-bundle) @ my-project ---
[INFO] --- maven-checkstyle-plugin:2.15:check (checkstyle-main) @ my-project ---
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ my-project ---
[INFO] >>> maven-bundle-plugin:2.5.4:install (default-install) > install @ my-project >>>
[INFO] --- maven-enforcer-plugin:1.4:enforce (enforce-maven) @ my-project ---
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ my-project ---
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ my-project ---
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ my-project ---
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ my-project ---
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ my-project ---
[INFO] >>> maven-bundle-plugin:2.5.4:bundle (default-bundle) > package @ my-project >>>
[INFO] --- maven-enforcer-plugin:1.4:enforce (enforce-maven) @ my-project ---
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ my-project ---
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ my-project ---
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ my-project ---
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ my-project ---
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ my-project ---
[INFO] <<< maven-bundle-plugin:2.5.4:bundle (default-bundle) < package @ my-project <<<
[INFO] --- maven-bundle-plugin:2.5.4:bundle (default-bundle) @ my-project ---
[INFO] --- maven-checkstyle-plugin:2.15:check (checkstyle-main) @ my-project ---
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ my-project ---
[INFO] <<< maven-bundle-plugin:2.5.4:install (default-install) < install @ my-project <<<
[INFO] --- maven-bundle-plugin:2.5.4:install (default-install) @ my-project ---
Additional Information:
Parent POM
<project ...>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>9</version>
</parent>
...
<version>3.0.5-SNAPSHOT</version>
<packaging>pom</packaging>
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.4</version>
<extensions>true</extensions>
<inherited>true</inherited>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
POM for OSGI package:
<project ...>
<parent>
<groupId>myGroupId</groupId>
<artifactId>myArtifactId</artifactId>
<version>3.0.5-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
...
<packaging>bundle</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Export-Package>myPackage</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
UPDATE . This is a known bug (also see K Erlandsson's answer): https://issues.apache.org/jira/browse/FELIX-4882
This issue has now been resolved ( maven-bundle-plugin-2.5.5
)
source to share
Edit . Since rmuller has been updated in the question, this is a bug: https://issues.apache.org/jira/browse/FELIX-4882 . The bug is fixed in the version 3.0.0
.
I remember we had a similar problem (specifically the package was deployed twice) when we updated maven-bundle-plugin
to 2.5.4
. We downgraded it to 2.5.3
to solve our problems.
I haven't gone deep yet to find out if this is a bug or if there are only other configuration requirements for 2.5.4
.
source to share
I tried to skip target deployment maven-bundle-plugin 2.5.4
with this workaround:
<executions>
<execution>
<id>default-deploy</id>
<phase>no-execute</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
This only worked for qualified release numbers in my case: eg. 0.3.0-RC1
... Releasing a build with a release number without a selection code still didn't work: e. g 0.3.0
.
Upgrading to maven-bundle-plugin before 2.5.3 solved this problem that the package was deployed twice. But I ran into another problem:
Maven Bundle Plugin fails with ArrayIndexOutOfBoundsException, "Invalid Class File"
...
According to https://issues.apache.org/jira/browse/FELIX-4556 switching to bndlib
version 2.4.0
works for me.
So I solved my problems by using maven-bundle-plugin 2.5.3
and using bndlib
version 2.4.0
:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.3</version>
<dependencies>
<dependency>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bndlib</artifactId>
<version>2.4.0</version>
</dependency>
</dependencies>
<plugin>
source to share