使用 Jenkins 将二进制文件与 JAR 文件一起发布到 Maven artifactory

Publish binary file to maven artifactory along with JAR files using Jenkins

我正在尝试使用 Jenkins 将 Java 库发布到 artifactory。目前,它只发布 .jar 文件到 artifactory。我有一个二进制文件 (.bin),我想将其与 .jar 文件一起发布。有谁知道我需要在我的 POM 文件中插入什么才能完成这项工作?

例如,我希望 artifactory 中的文件结构如下所示:

test-0.1.jar
test.bin
...

这是我的 POM 文件:

<?xml version="1.0" encoding="UTF-8"?>
<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>

    <groupId>com.github.test</groupId>
    <artifactId>test</artifactId>
    <version>0.1</version>
    <name>Test Lib </name>
    <packaging>jar</packaging>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <!-- Avoid Java 8's strict doc generator-->
    <profiles>
        <profile>
            <id>disable-java8-doclint</id>
            <activation>
                <jdk>[1.8,)</jdk>
            </activation>
            <properties>
                <additionalparam>-Xdoclint:none</additionalparam>
            </properties>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <source>8</source>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

构建助手 maven 插件允许您附加其他工件,请参阅

https://www.mojohaus.org/build-helper-maven-plugin/usage.html

低于 "Attach additional artifacts to your project" 或

https://www.mojohaus.org/build-helper-maven-plugin/attach-artifact-mojo.html