当我将包装设置为捆绑包时,Maven项目中的PluginVersionResolutionException

问题描述 投票:1回答:1

在我的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>

maven apache-felix
1个回答
0
投票

有两种可能的方法。我在自己的项目中使用的是保留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中进行了描述。

© www.soinside.com 2019 - 2024. All rights reserved.