使用maven的maven-shade-plugin插件时需要注意的一个问题

  • Post author:
  • Post category:其他


maven-shade-plugin插件有个配置属性:createDependencyReducedPom,默认值为true.

注意这个属性,如果你用这个插件来deploy,或者发布到中央仓库

这个属性会缩减你的pom文件,会把你依赖的<dependency>干掉

正确的做法是把这个值改成false

<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<version>1.4</version>
				<configuration>
					<createDependencyReducedPom>false</createDependencyReducedPom>
				</configuration>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>shade</goal>
						</goals>
						<configuration>
							<transformers>
								<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
									<mainClass>org.durcframework.core.MainCore</mainClass>
								</transformer>
							</transformers>
						</configuration>
					</execution>
				</executions>
			</plugin>

官方说法:



createDependencyReducedPom


boolean

-
Flag whether to generate a simplified POM for the shaded artifact. If set to

true

, dependencies that have been included into the uber JAR will be removed from the

<dependencies>

section of the generated POM. The reduced POM will be named

dependency-reduced-pom.xml

and is stored into the same directory as the shaded artifact. Unless you also specify dependencyReducedPomLocation, the plugin will create a temporary file named

dependency-reduced-pom.xml

in the project basedir.


Default value is

:

true

.

http://maven.apache.org/plugins/maven-shade-plugin/shade-mojo.html



版权声明:本文为thc1987原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。