从 Hudson 获取所有 Maven 工件

发布于 2024-08-11 07:24:17 字数 2259 浏览 2 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

玩心态 2024-08-18 07:24:17

您可以使用 builder-helper-maven-plugin

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.3</version>
    <executions>
        <execution>
            <id>attach-artifacts</id>
            <phase>package</phase>
            <goals>
                <goal>attach-artifact</goal>
            </goals>
            <configuration>
                <artifacts>
                    <artifact>
                        <file>${project.build.directory}/${build.finalName}.zip</file>
                        <type>zip</type>
                    </artifact>
                </artifacts>
            </configuration>
        </execution>
    </executions>
</plugin>

You can use builder-helper-maven-plugin

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.3</version>
    <executions>
        <execution>
            <id>attach-artifacts</id>
            <phase>package</phase>
            <goals>
                <goal>attach-artifact</goal>
            </goals>
            <configuration>
                <artifacts>
                    <artifact>
                        <file>${project.build.directory}/${build.finalName}.zip</file>
                        <type>zip</type>
                    </artifact>
                </artifacts>
            </configuration>
        </execution>
    </executions>
</plugin>
薄暮涼年 2024-08-18 07:24:17

构建助手 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文