为了账号安全,请及时绑定邮箱和手机立即绑定

【maven】enforcer插件

标签:
Java
参考资料:
  1. 【enforcer首页】http://maven.apache.org/enforcer/maven-enforcer-plugin/enforce-mojo.html
  2. 【内置规则】http://maven.apache.org/enforcer/enforcer-rules/index.html
  3. 【codehaus扩展规则】http://www.mojohaus.org/extra-enforcer-rules/
功能:
  1. 不允许出现SNAPSHOT。
  2. 制定GAV规则。
  3. 不允许出现重复jar包
参考代码:
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>enforce</goal>
            </goals>
            <configuration>
                <fail>true</fail>
                <failFast>true</failFast>
                <rules>
                    <requireReleaseDeps>
                        <failWhenParentIsSnapshot>false</failWhenParentIsSnapshot>
                        <message>No Snapshots Allowed!</message>
                        <excludes>
                            <exclude>com.imooc.harder:*</exclude>
                        </excludes>
                    </requireReleaseDeps>
                    <bannedDependencies>
                        <searchTransitive>true</searchTransitive>
                        <message>Dependecy Check Failed!</message>
                        <excludes>
                            <exclude>org.springframework:spring-beans:(,4.1.2.RELEASE]</exclude>
                            <exclude>commons-logging:commons-logging</exclude>
                        </excludes>
                    </bannedDependencies>
                    <banDuplicateClasses>
                        <ignoreClasses>
                            <ignoreClass>javax.*</ignoreClass>
                            <ignoreClass>org.apache.commons.logging.*</ignoreClass>
                            <ignoreClass>org.apache.shiro.*</ignoreClass>
                            <ignoreClass>org.objectweb.asm.*</ignoreClass>
                            <ignoreClass>shade.org.apache.commons.*</ignoreClass>
                            <ignoreClass>org.apache.commons.*</ignoreClass>
                            <ignoreClass>zander.com.google.common.*</ignoreClass>
                            <ignoreClass>zander.com.google.thirdparty.*</ignoreClass>
                            <ignoreClass>com.facebook.fb303.*</ignoreClass>
                            <ignoreClass>scribe.thrift.*</ignoreClass>
                            <ignoreClass>org.apache.thrift.*</ignoreClass>
                            <ignoreClass>org.aspectj.*</ignoreClass>
                        </ignoreClasses>
                        <findAllDuplicates>true</findAllDuplicates>
                    </banDuplicateClasses>
                </rules>
            </configuration>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>extra-enforcer-rules</artifactId>
            <version>1.0-beta-6</version>
        </dependency>
    </dependencies>
</plugin>
点击查看更多内容
1人点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消