码迷,mamicode.com
首页 > 其他好文 > 详细

maven插件: shade, assembly

时间:2018-07-31 13:41:23      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:sem   mave   pom   style   exe   ade   src   tor   back   

 

shade插件的作用: 

通过版本的exclution无法解决jar冲突的问题, 

解决方案是把依赖的包打到本model的jar中,打包的时候由mvn plugin自动修改代码中的依赖jar包名

relocation配置会强制修改代码中的依赖包名 ==>

技术分享图片

 

示例配置:

<build>

        <plugins>
            <plugin>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
                            <promoteTransitiveDependencies>false</promoteTransitiveDependencies>
                            <createDependencyReducedPom>true</createDependencyReducedPom>
                            <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
                            <minimizeJar>false</minimizeJar>
                            <createSourcesJar>false</createSourcesJar>
                            <artifactSet>
                                <includes>
                                    <include>io.netty:netty-all</include>
                                </includes>
                            </artifactSet>
                            <relocations>
                                <relocation>
                                    <pattern>io.netty</pattern>
                                    <shadedPattern>com.mytest.shade.io.netty</shadedPattern>
                                </relocation>
                            </relocations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>

    </build>

  

 

maven插件: shade, assembly

标签:sem   mave   pom   style   exe   ade   src   tor   back   

原文地址:https://www.cnblogs.com/yszzu/p/9395114.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!