bre*_*ine 3 maven-2 jar maven-plugin maven-3 maven
我正在尝试将jar从我的本地存储库复制到另一个项目中,如下所述:
http://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-artifacts.html
然而,我的jar从maven-assembly-plugin作为"带有依赖性的jar"出来,它将常规jar和组装的jar放在我的本地repo中.jar名称看起来像:
示例 - 测试 - 0.0.1-快照罐与 - dependencies.jar
如果我手动复制,我可以在回购中找到它并使用它.我认为让maven复制它是个好主意所以我使用了上面描述的依赖项复制目标.
但是我不能让它工作,所以它复制"jar with dependencies"jar.
这就是pom的样子:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>my.group</groupId>
<artifactId>example-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>libs</outputDirectory>
<destFileName>somename.jar</destFileName>
</artifactItem>
</artifactItems>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我试图将类型设置为"jar-with-dependencies",但这不起作用.只有当我将类型设为"jar"但它才会复制常规未组装的jar时,它才有效.任何想法如何解决这一问题?
小智 10
如果您有这样的工件:
example-test-0.0.1-SNAPSHOT-jar-with-dependencies.jar
Run Code Online (Sandbox Code Playgroud)
你想像这样引用它:
<artifactItem>
<groupId>my.group</groupId>
<artifactId>example-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<classifier>jar-with-dependencies</classifier>
<overWrite>true</overWrite>
<outputDirectory>libs</outputDirectory>
<destFileName>somename.jar</destFileName>
</artifactItem>
Run Code Online (Sandbox Code Playgroud)
这个例子在这里:
<artifactItem>
<groupId>[ groupId ]</groupId>
<artifactId>[ artifactId ]</artifactId>
<version>[ version ]</version>
<type>[ packaging ]</type>
this---><classifier> [classifier - optional] </classifier>
<overWrite>[ true or false ]</overWrite>
<outputDirectory>[ output directory ]</outputDirectory>
<destFileName>[ filename ]</destFileName>
</artifactItem>
Run Code Online (Sandbox Code Playgroud)