微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Maven - pom 文件 - 未创建工件

如何解决Maven - pom 文件 - 未创建工件

我有一个由 jenkins 触发的 pom 文件,被使用了两次,每次都在不同的机器(docker 容器)上使用不同的编译器(为不同的 linux 发行版构建)。

为了将这 2 个不同的构建作为工件并使用不同的名称,我尝试使用配置文件并将工件的分类器设置为不同的值。

似乎由于某种原因没有创建工件,我不知道为什么。

我不确定我是否正确配置了配置文件,而且我在自己的执行块中也有“附加到工件”,但我不知道它是否正确。

任何帮助将不胜感激。

我的 pom.xml:

<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/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>XXXX</groupId>
    <artifactId>XXXXX</artifactId>
    <version>1-SNAPSHOT</version>
</parent>

<groupId>XXXXX</groupId>
<artifactId>XXXXXXX</artifactId>
<version>${revision}</version>

<packaging>pom</packaging>

<scm>
    <developerConnection>scm:git:ssh://XXXXXX</developerConnection>
</scm>

<properties>
    <revision>1.0.0-1-SNAPSHOT</revision>
</properties>

<build>

    <plugins>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>flatten-maven-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <id>build</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <target>
                            <exec executable="sh" failonerror="true">
                                <arg line="build.sh"/>
                            </exec>
                        </target>
                    </configuration>
                </execution>
                <execution>
                    <id>prepare-test-package</id>
                    <phase>prepare-test</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <skip>${env.ESX_COMPILATION}</skip>
                        <target>
                            <exec executable="sh" failonerror="true">
                                <arg line="tests.sh"/>
                            </exec>
                            <attachartifact file="${project.build.directory}/archive.tar.gz" type="tar.gz"/>
                        </target>
                    </configuration>
                </execution>
                <execution>
                    <id>attach-to-artifact</id>
                    <phase>attach-artifact</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <classifier>${envClassifier}</classifier>
                        <target>
                            <attachartifact file="${project.build.directory}/archive.tar.gz" type="tar.gz"/>
                        </target>
                    </configuration>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>
<profiles>
    <profile>
        <id>esx</id>
        <activation>
            <property>
                <name>env.ESX_COMPILATION</name>
                <value>true</value>
            </property>
        </activation>
        <properties>
            <envClassifier>esx</envClassifier>
        </properties>
    </profile>
    <profile>
        <id>linux</id>
        <activation>
            <property>
                <name>env.ESX_COMPILATION</name>
                <value>false</value>
            </property>
        </activation>
        <properties>
            <envClassifier>linux</envClassifier>
        </properties>
    </profile>
</profiles>

正如所见,我正在使用“env.ESX_COMPILATION”变量来设置配置文件选择,该选项设置“envClassifier”变量,并在最终执行块中,在我设置“分类器”之前和之下。在目标内部我称之为“attachtoartifact”

在这里做错了什么?

非常感谢任何帮助! 谢谢!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。