我有一个名为"MyProject“的maven项目,它使用另一个项目作为我编写的普通maven依赖项"MyDependency”。MyDependency是一个maven项目,它使用了其他依赖项,如springframework、apache-commons、apache-camel等。
问题是这样的。我希望MyProject能够看到MyDependency中的传递依赖项,而不必将它们再次添加到pom文件中。我尝试了maven-dependency插件和maven-jar插件,以生成一个jar,如下所示,其中包含所有依赖项,但没有结果。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>compile</includeScope>
<outputDirectory>${project.build.directory}/classes/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>lib/</Class-Path>
</manifestEntries>
</archive>
<finalName>core-${project.version}</finalName>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
有没有办法做到这一点?还是我的问题全错了?
发布于 2017-05-17 14:28:35
MyProject可以使用MyDependency中的依赖项。Maven自动解析传递依赖关系。你不需要做任何复制。您可以使用mvn dependency:list查看项目使用的工件的完整列表。
https://stackoverflow.com/questions/44017106
复制相似问题