zoukankan      html  css  js  c++  java
  • maven-shade-plugin~打包时过滤项目中某些包

    maven-shade-plugin可以用来进行打包,并实现在打包过程中的一些过滤、排除、包含、重命名等一系列操作,当我们设计公用项目时,有时在项目时会有一些测试用例,如果在打包时想把这些测试包排除,使用maven-shade-plugin插件是个不错的选择。

    打包包含和排除

    下面的代码实现了以下几个功能:

    • 打包时排除com.lind.uaa.jwt.three包下的所有内容
    • 打包时排除项目的properties类型的配置文件
    • 打包时,com.baomidou组织的包添加到当然JAR包里,默认是不会添加到当前包的
    • createSourcesJar选项实现了打包时为源代码再打一个包
     <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>2.4.3</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <!-- 过滤器排除配置文件-->
                                <filters>
                                    <filter>
                                        <artifact>*:*</artifact>
                                        <excludes>
                                            <exclude>**/*.properties</exclude>
                                            <exclude>com/lind/uaa/jwt/three/**</exclude>
                                        </excludes>
                                    </filter>
                                </filters>
                                <artifactSet>
                                    <!-- 捆绑包含,目标项目不需要再手动引用这个包了 -->
                                    <includes>
                                        <include>com.baomidou:*</include>
                                    </includes>
         
                                </artifactSet>
                                <createSourcesJar>true</createSourcesJar>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    

  • 相关阅读:
    OleDbCommand 的用法
    递归求阶乘
    C#重写窗体的方法
    HDU 5229 ZCC loves strings 博弈
    HDU 5228 ZCC loves straight flush 暴力
    POJ 1330 Nearest Common Ancestors LCA
    HDU 5234 Happy birthday 01背包
    HDU 5233 Gunner II 离散化
    fast-IO
    HDU 5265 pog loves szh II 二分
  • 原文地址:https://www.cnblogs.com/lori/p/14129659.html
Copyright © 2011-2022 走看看