我有两个项目:ProjA和ProjB。 ProjB依赖于ProjA。我想要做的只是在包装阶段将几个文件从ProjA(与程序集插件一起打包)复制到ProjB(这只是标准jar)。
有两种情况 - 一种是有效的,另一种是无效的。但首先是相关文件:
ProjA pom:
<build>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/assembly/distribution.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
ProjA汇编描述符:
<id>native-libs</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>dir</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.dll</include>
<include>*.so</include>
</includes>
</fileSet>
</fileSets>
ProjB pom:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy native lib</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>someGroupID</groupId>
<artifactId>ProjA</artifactId>
<version>0.1-SNAPSHOT</version>
<type>dir</type>
<classifier>native-libs</classifier>
<outputDirectory>${project.build.directory}/libs</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
在第一种情况下,如果我在ProjA的程序集描述符中使用<packaging>zip</packaging>
,然后设置ProjB的<goal>unpack</goal>
和<packaging>zip</packaging>
,则一切都按预期工作
在第二种情况下,如果我使用<packaging>dir</packaging>
和<goal>copy</goal>
,正如示例中所示,ProjB失败并出现错误:Failed to execute goal ...:copy on project ProjB: Unable to find artifact.: Could not find artifact...
这是我面临的一些错误还是我做错了什么?同样,如果我将包装更改为压缩并将目标更改为解压缩,则可行。它无法打包 dir 和目标复制。