我正在尝试有一个项目B拉下(并解压)由以下人员构建的 ZIP项目A并部署到远程存储库。
使用以下命令创建并附加 ZIP:maven-assembly-plugin
, 带包装类型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>
试图将其拉下来项目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]
我认为这是因为我指定了项目A的包装为pom
并不是zip
,但是我无法指定项目A作为包装类型zip
因为它会导致:
[ERROR] Unknown packaging: zip @ line 13, column 13
我在这里做错了什么还是这根本不可能?
我只有一堆文件,我想将它们捆绑到一个工件中,并允许多个其他项目下载并解压它们以供使用。接受不同的建议...
我还检查过以确保组装好的 zip 确实位于连接中。
更新了答案
为了其他人的利益,我所缺少的是<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>