创建没有依赖项的 Maven Uber Jar
我目前正在尝试从一个包中的多个 jar 创建一个库 jar,这是我无法控制的。
我一直致力于摆脱传递依赖。
库 pom.xml 看起来像这样
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>root-pom</artifactId>
<groupId>foo</groupId>
<version>1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>library</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>out-of-my-control</groupId>
<artifactId>out-of-my-control</artifactId>
<version>1</version>
<type>pom</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<id>shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
当我将库作为依赖项添加到项目之一的其他模块时,它工作得很好,但我仍然拥有树中的所有依赖项以及打包到最终产品(war、ear)中。
有没有比将库排除在另一个项目中更好的方法(它就是这样并且不再需要)或者使用一些对我来说似乎有点黑客的本地存储库?
I'm currently trying to create a library jar from multiple jars that come in one bundle which is out of my control.
I'm stuck at getting rid of the transitive dependencies.
Library pom.xml looks like this
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>root-pom</artifactId>
<groupId>foo</groupId>
<version>1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>library</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>out-of-my-control</groupId>
<artifactId>out-of-my-control</artifactId>
<version>1</version>
<type>pom</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<id>shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I add the library as dependency to one of the projects other modules it works just fine but I still have all the dependencies in the tree as well as packaged into the final product (war, ear).
Is there a better way than excluding the library into another project which is how it was and not wanted anymore or using some local repository which seems a bit hacky to me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论