在我的Maven项目中,当我将打包类型从'jar'更改为'bundle'时,我的大多数插件(编译器,部署,安装,资源,surefire)都失去了版本。为什么是这样?
我的pom.xml在下面:
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.ui_4.4.35_patch</artifactId>
<version>1.0.0</version>
<packaging>bundle</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>4.2.1</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Export-Package>web.admin.*</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
有两种可能的方法。我在自己的项目中使用的是保留bundle
包装并将maven插件版本添加到pom.xml中的pluginManagement
部分。例如:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
<!-- Add you current 'plugins' section here. -->
</build>
除了版本,您还可以向每个插件添加configuration
。如果您的项目有一个父pom,自然会在其中添加pluginManagement
部分,而不是在bundle模块中。
或者,按照@khmarbaise的建议,您可以使用jar
打包,仅使用maven-bundle-plugin生成清单。该方法在plugin documentation page中进行了描述。