从 Hudson 获取所有 Maven 工件
我有一个 Maven 项目,它是一个子项目。它有许多兄弟项目,该项目的工作是从兄弟项目获取资源并使用 antrun 插件将它们打包在 zip 文件中。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>SystemOfRegistries</artifactId>
<groupId>someGroup</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>someGroup</groupId>
<artifactId>deploy-data</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<!--
Place any Ant task here. You can add anything you can add
between <target> and </target> in a build.xml.
-->
<zip destfile="${project.build.directory}/${build.finalName}.zip"
whenempty="fail">
<zipfileset dir="${project.parent.basedir}/build/AG" prefix="ag"/>
</zip>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
这对于构建拉链来说效果很好。然而,问题是 zip 不是构建的工件。因此,Hudson 中没有下载它的链接。
我想弄清楚如何让 Hudson 认识到这是 Maven 的工件,或者让 Maven 认识到 ZIP 就是工件。 (我曾经缺少打包元素,然后我会得到一个不需要的 JAR 作为工件)。
I have a Maven project that is a child project. It has many sibling projects and the job of this project is to get resources from the siblings and package them in a zip file using the antrun plugin.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>SystemOfRegistries</artifactId>
<groupId>someGroup</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>someGroup</groupId>
<artifactId>deploy-data</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<!--
Place any Ant task here. You can add anything you can add
between <target> and </target> in a build.xml.
-->
<zip destfile="${project.build.directory}/${build.finalName}.zip"
whenempty="fail">
<zipfileset dir="${project.parent.basedir}/build/AG" prefix="ag"/>
</zip>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
This worked fine for building the zip. However, the problem is that the zip is not the artifact of the build. And, thus there is no link in Hudson to download it.
I would either like to figure out how to get Hudson to recognize this as an artifact of Maven, or get Maven to realize that the ZIP is the artifact. (I used to have packaging element missing and then I would get an unwanted JAR as artifact).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 builder-helper-maven-plugin
You can use builder-helper-maven-plugin
构建助手 Maven 插件(attach-artifact 目标) 将告诉 Maven 应该将特定文件添加到该项目的 Maven 工件列表中。在这种情况下,将包装设置为“pom”是正确的做法。
请注意,如果您正在运行“安装”目标,那么您的 zip 文件也将被复制到本地 Maven 存储库,但它将根据 Maven 约定进行重命名。如果您有依赖于此工件的下游构建,则需要注意一些事情。
The Build Helper Maven Plugin (attach-artifact goal) will tell maven that a particular file should be added to maven's list of artifacts for that project. Setting the packaging to "pom" is the correct thing to do in this situation.
Note that if you are running the "install" goal, then your zip file will also be copied to the local maven repository, but it will be renamed according to maven conventions. Just something to be aware of, if you have downstream builds depending on this artifact.