我有一个只包含文件的项目。我想将这些文件打包成zip并将它们存储在maven存储库中。我有配置插件配置来构建zip文件,该部分工作得很好,但我似乎无法弄清楚如何安装zip文件?
另外,如果我想在另一个工件中使用这个程序集,我该怎么做?我打算调用依赖:unpack,但我没有在存储库中有一个工件来解压缩。
如何在我的存储库中获取一个zip文件,以便我可以在另一个工件中重复使用它?
父母pom
<build>
<plugins>
<plugin>
<!--<groupId>org.apache.maven.plugins</groupId>-->
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<filters>
<filter></filter>
</filters>
<descriptors>
<descriptor>../packaging.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
</build>
儿童POM
<parent>
<groupId>com. ... .virtualHost</groupId>
<artifactId>pom</artifactId>
<version>0.0.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<name>Virtual Host - ***</name>
<groupId>com. ... .virtualHost</groupId>
<artifactId>***</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
我把名字过滤掉了。这个POM是否正确?我只想将特定虚拟主机的文件捆绑在一起。
谢谢,
沃尔特
我有配置插件配置来构建zip文件,该部分工作得很好,但我似乎无法弄清楚如何安装zip文件?
好吧,创建的程序集应该自动附加到项目中,然后上传到存储库中 install
和 deploy
目标。你能展示你的pom吗?
更新: 使用当前配置,我不认为程序集是作为构建的一部分创建的。你需要绑定 single
通常是生命周期阶段的目标 package
:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptors>
<descriptor>../packaging.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- append to the packaging phase. -->
<goals>
<goal>single</goal> <!-- goals == mojos -->
</goals>
</execution>
</executions>
</plugin>
现在它应该正确安装/部署。
另外,如果我想在另一个工件中使用这个程序集,我该怎么做?我打算调用依赖:unpack,但我没有在存储库中有一个工件来解压缩。
您可以声明对程序集的依赖关系(使用右侧 classifier
和 type
在你的情况下)但由于依赖关系是通过存储库解决的,你需要先解决第一步。然后,声明类似这样的东西(分类器是程序集的id):
<dependency>
<groupId>com. ... .virtualHost</groupId>
<artifactId>***</artifactId>
<version>0.0.1</version>
<classifier>...</classifier>
<type>zip</type>
</dependency>
我认为程序集应该自动附加到构建,但如果这不起作用,那么 Maven Build Helper“附加工件”目标 附加要在存储库中安装的指定文件。我已经使用这个插件来安装由Ant或NSIS等外部进程创建的文件。
我不知道这对你有用,但由于JAR文件基本上是一个ZIP文件加上META-INF信息,你可以创建你的项目作为一个没有来源的jar并添加xip对手 src/main/resources
无需任何插件配置。
如果您希望自己的内容位于不同的位置,则可以执行以下操作:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.myzip</groupId>
<artifactId>myzip-artifact-id</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>false</filtering>
<directory>${basedir}/zipcontent</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</build>
</project>
如果您希望安装工件并在存储库中访问,则需要在部署阶段进行设置:
http://maven.apache.org/plugins/maven-deploy-plugin/usage.html