Shade Plugin Harcording Excpendency For Excluded Artifact也

时间:2014-11-18 08:48:43

标签: maven maven-shade-plugin uberjar

我有以下shade插件配置:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createSourcesJar>false</createSourcesJar>
                            <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
                            <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
                            <artifactSet>
                                <includes>
                                    <include>XXXX:AAAA-common</include
                                </includes>
                                <excludes>
                                    <exclude>XXXX:client</exclude>
                                </excludes>
                            </artifactSet>
                            <finalName>${project.artifactId}-${project.version}</finalName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

我看到XXXX:客户端被排除在maven依赖项之外,但是在生成的pom中,我看到依赖项正在使用版本进行硬编码

<dependency>
   <groupId>XXXX</groupId>
   <artifactId>client</artifactId>
   <version>1.2.3</version>
   <scope>compile</scope>
</dependency>

有没有办法可以完全删除依赖项,或者只删除硬编码版本?

1 个答案:

答案 0 :(得分:0)

进一步分析后,我发现他们无法删除硬编码版本。您可以尝试的替代方法是maven-assembly插件,但它提供的灵活性很小。