当使用 "bundle" 打包时,maven-bundle-plugin 目标被执行两次
When using "bundle" packaging with maven-bundle-plugin goals are executed twice
我有一个(简单的)maven 项目,打包类型为 "bundle",使用 org.apache.felix:maven-bundle-plugin:2.5.4
。它会生成正确的 OSGI 包 jar。但是我观察到所有目标至少执行 两次 。我该如何防止这种情况?问题是一些目标(本例中的 checkstyle)很慢,所以重复执行是一个问题。
注意:我从命令行使用 maven 3.2.5。
输出或mvn clean install
(删除了所有不相关的信息)。请注意,许多插件执行了 4 次。 maven-checkstyle-plugin
执行了两次。
[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 ---
额外信息:
父 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>
OSGI 包的 POM:
<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:这是一个已知错误(另见答案 K Erlandsson):https://issues.apache.org/jira/browse/FELIX-4882
此问题现已解决 (maven-bundle-plugin-2.5.5
)
编辑:由于rmuller在问题中更新,这是一个错误:https://issues.apache.org/jira/browse/FELIX-4882。该错误已在版本 3.0.0
.
中修复
我记得我们在将 maven-bundle-plugin
升级到 2.5.4
时遇到过类似的问题(具体来说,捆绑部署了两次)。我们将其降级为 2.5.3
以解决我们的问题。
我没有更深入地研究这是否是一个错误,或者是否只有 2.5.4
的其他配置要求。
我试图通过以下解决方法跳过 maven-bundle-plugin 2.5.4
的目标部署:
<executions>
<execution>
<id>default-deploy</id>
<phase>no-execute</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
在我的例子中,这仅适用于带有限定符的版本号:例如0.3.0-RC1
。
没有限定符的版本号的发布版本仍然不起作用:e。 G。 0.3.0
.
将 maven-bundle-plugin 降级到 2.5.3 解决了这个问题,该包被部署了两次。但是我遇到了另一个问题:
Maven Bundle Plugin fails with ArrayIndexOutOfBoundsException, "Invalid Class File"
...
根据 https://issues.apache.org/jira/browse/FELIX-4556,切换到 bndlib
版本 2.4.0
适合我。
所以我通过使用 maven-bundle-plugin 2.5.3
和 bndlib
版本 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>
版本 maven-bundle-plugin-2.5.5
适合我。
我有一个(简单的)maven 项目,打包类型为 "bundle",使用 org.apache.felix:maven-bundle-plugin:2.5.4
。它会生成正确的 OSGI 包 jar。但是我观察到所有目标至少执行 两次 。我该如何防止这种情况?问题是一些目标(本例中的 checkstyle)很慢,所以重复执行是一个问题。
注意:我从命令行使用 maven 3.2.5。
输出或mvn clean install
(删除了所有不相关的信息)。请注意,许多插件执行了 4 次。 maven-checkstyle-plugin
执行了两次。
[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 ---
额外信息:
父 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>
OSGI 包的 POM:
<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:这是一个已知错误(另见答案 K Erlandsson):https://issues.apache.org/jira/browse/FELIX-4882
此问题现已解决 (maven-bundle-plugin-2.5.5
)
编辑:由于rmuller在问题中更新,这是一个错误:https://issues.apache.org/jira/browse/FELIX-4882。该错误已在版本 3.0.0
.
我记得我们在将 maven-bundle-plugin
升级到 2.5.4
时遇到过类似的问题(具体来说,捆绑部署了两次)。我们将其降级为 2.5.3
以解决我们的问题。
我没有更深入地研究这是否是一个错误,或者是否只有 2.5.4
的其他配置要求。
我试图通过以下解决方法跳过 maven-bundle-plugin 2.5.4
的目标部署:
<executions>
<execution>
<id>default-deploy</id>
<phase>no-execute</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
在我的例子中,这仅适用于带有限定符的版本号:例如0.3.0-RC1
。
没有限定符的版本号的发布版本仍然不起作用:e。 G。 0.3.0
.
将 maven-bundle-plugin 降级到 2.5.3 解决了这个问题,该包被部署了两次。但是我遇到了另一个问题:
Maven Bundle Plugin fails with ArrayIndexOutOfBoundsException, "Invalid Class File"
...
根据 https://issues.apache.org/jira/browse/FELIX-4556,切换到 bndlib
版本 2.4.0
适合我。
所以我通过使用 maven-bundle-plugin 2.5.3
和 bndlib
版本 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>
版本 maven-bundle-plugin-2.5.5
适合我。