How to use Maven to only sign three jars and push them to Maven Central?

前端 未结 1 1111
庸人自扰
庸人自扰 2021-01-25 06:53

UPDATE: See followup question


I have a Java library whose build process is entirely written in Ant. The project\'s sandbox (the source directory, in which

相关标签:
1条回答
  • 2021-01-25 07:46

    If you are building your artifacts outside of Maven you need to reference them in your .pom file

    At first, set the packaging of your project to pom so Maven will not attempt to compile anything.

    Then use the build-helper-maven-plugin to attach your artifact files to the project. Here is an example:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <id>attach-artifacts</id>
                    <phase>package</phase>
                    <goals>
                        <goal>attach-artifact</goal>
                    </goals>
                    <configuration>
                        <artifacts>
                            <artifact>
                                <file>build/xbnjava-0.1.1/download/mylibrary-0.1.1.jar</file>
                                <type>jar</type>
                            </artifact>
                            <artifact>
                                <file>build/xbnjava-0.1.1/download/mylibrary-0.1.1-javadoc.jar</file>
                                <type>jar</type>
                                <classifier>javadoc</classifier>
                            </artifact>
                            <artifact>
                                <file>build/xbnjava-0.1.1/download/mylibrary-0.1.1-sources.jar</file>
                                <type>jar</type>
                                <classifier>sources</classifier>
                            </artifact>
                        </artifacts>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    

    Finally, add the distributionManagement section to your .pom file as specified here.

    You can refer to my own Maven project setup at github which was created to upload manually built .jar files on Maven central.

    0 讨论(0)
提交回复
热议问题