我正在尝试让项目 B下拉(并解压缩)项目 A构建的 ZIP并部署到远程存储库。
maven-assembly-plugin
ZIP 是使用, 包装类型创建和附加的pom
:
<artifactId>project-a</artifactId>
<name>ZIP</name>
<description>Used by Project B</description>
<packaging>pom</packaging>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>distribution-package</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/scripts.xml</descriptor>
</descriptors>
<tarLongFileMode>gnu</tarLongFileMode>
</configuration>
</execution>
</executions>
</plugin>
尝试使用以下命令从Project B的 pom 中将其拉下maven-dependency-plugin
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-scripts</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/staging</outputDirectory>
<stripVersion>true</stripVersion>
<artifactItems>
<artifactItem>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<overWrite>true</overWrite>
<type>zip</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
失败:[ERROR] Failed to execute goal on project ...: Could not resolve dependencies for project group:artifact:pom:version: Could not find artifact group:project-a:zip:version in nexus (http://...:8081/nexus/content/groups/public) -> [Help 1]
我认为这是因为我将Project A的包装指定为pom
而不是zip
,但是我不能将Project A指定为包装类型zip
,因为它会导致:
[ERROR] Unknown packaging: zip @ line 13, column 13
我在这里做错了什么还是这根本不可能?我只有一堆文件,我想将它们捆绑到一个工件中,并允许多个其他项目下载并解压缩它们以供使用。接受不同的建议...
我还检查以确保组装好的拉链确实在连接处。
已更新答案
为了其他人的利益,我缺少的是<classifier>
依赖项必须与<id>
程序集匹配。请注意thisistheattachedartifactsclassifier
以下文件中指定的位置。
scripts.xml(项目 A):
<assembly>
<id>thisistheattachedartifactsclassifier</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>src/main/resources</directory>
...
</fileSet>
</fileSets>
</assembly>
pom.xml(项目 B):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-scripts</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/staging</outputDirectory>
<stripVersion>true</stripVersion>
<artifactItems>
<artifactItem>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<classifier>thisistheattachedartifactsclassifier</classifier>
<overWrite>true</overWrite>
<type>zip</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>