首页 > 解决方案 > Maven - 从另一个插件中排除插件

问题描述

我有一个需要在构建中使用的插件。然而,这个插件在构建时依赖于另一个插件,并且这种依赖在Java-8 之后不起作用

具体来说,我想使用的插件在它的 pom.xml 文件中有这个

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <dependencies>
                <dependency>
                    <groupId>com.sun</groupId>
                    <artifactId>tools</artifactId>
                    <version>${javaVersion}</version>
                    <scope>system</scope>
                    <systemPath>${tools.jar}</systemPath>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <phase>test-compile</phase>
                    ......
                </execution>
            </executions>
        </plugin>

它设置为test-compile阶段,因此它仅在构建插件本身时运行,而不是在使用时运行。

问题是它systemPath作为依赖项的一部分被设置为使用 Java 9+ 无法解决的问题。这反过来会导致使用插件的项目构建失败:

[ERROR] 'dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} @

所以要么我需要完全忽略maven-antrun-plugin作为我使用这个插件的一部分,要么我至少需要让它的依赖项工作。

有什么想法吗?

干杯

标签: javamavenmaven-plugin

解决方案


推荐阅读