Maven屏蔽Parent(Module)中的Plugin

何甫
2023-12-01

今天研究关于Presto的SPI的开发,在写好Demo之后大包的过程中发现,如下报错

INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.084 s
[INFO] Finished at: 2018-11-08T16:36:44+08:00
[INFO] Final Memory: 23M/267M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (default) on project plugin_test: Failed during checkstyle execution: Unable to find configuration file at location: /home/levin/workspcae/java/plugin_test/src/checkstyle/checks.xml: Could not find resource '/home/levin/workspcae/java/plugin_test/src/checkstyle/checks.xml'. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

上面的异常看了一下,发现是因为Parent中引用了maven-checkstyle-plugin,但是当本身Module打包的过程中,触发了其中的plugin的check,产生的报错,感觉这些都是无关的那就研究了一下如何屏蔽。
下面是屏蔽的方法贴出来

mvn clean package -Dcheckstyle.skip=true -Dcheckstyle.skipExec=true

上面的貌似只能屏蔽maven-checkstyle-plugin的check,还有一些其他的plugin,google了好多,发现下面这种方法可以使用

<build>
        <plugins>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.gaul</groupId>
                <artifactId>modernizer-maven-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
 </build>

在当前pom中引入想屏蔽的plugin然后添加标签 configuration以及skip属性

 类似资料: