Skip to content

Uploading 3rd party library to maven central

Roman Ivanov edited this page May 16, 2014 · 3 revisions

For uplouding 3rd party library to central we need bundle.jar. It has to contain following files:

project-1.0.pom
project-1.0.pom.asc
project-1.0.jar
project-1.0.jar.asc
project-1.0-sources.jar
project-1.0-sources.jar.asc
project-1.0-javadoc.jar
project-1.0-javadoc.jar.asc

If you use maven project you may use maven-source-plugin and maven-javadoc-plugin. Just add it to your pom file:

<project>
        <build>
            ...
	    <plugins>
                ...
                <plugin>
	            <groupId>org.apache.maven.plugins</groupId>
	            <artifactId>maven-source-plugin</artifactId>
	            <version>2.2.1</version>
	            <executions>
	                <execution>
	                    <id>attach-sources</id>
	                    <phase>package</phase>
	                    <goals>
	                        <goal>jar</goal>
	                    </goals>
	                </execution>
	            </executions>
	        </plugin>

	        <plugin>
	            <groupId>org.apache.maven.plugins</groupId>
	            <artifactId>maven-javadoc-plugin</artifactId>
	            <version>2.9</version>
	            <executions>
	                <execution>
	                    <id>attach-javadocs</id>
	                    <phase>package</phase>
	                    <goals>
	                        <goal>jar</goal>
	                    </goals>
	                </execution>
	            </executions>
	        </plugin>
            </plugins>
        </build>
</project>

If not - make it manually.

How to sign files with gpg to create asc files.

Now you can create bundle.

jar -cvf bundle.jar project-1.0.pom project-1.0.pom.asc project-1.0.jar project-1.0.jar.asc project-1.0-javadoc.jar project-1.0-javadoc.jar.asc project-1.0-sources.jar project-1.0-sources.jar.asc

After that you should uploud it to sonytype repository. Go to https://oss.sonatype.org/, login (right top angle) with your sonatype jira accaunt.

login pigture

Select staging upload.

Upload picture

Upload Mode: Artifact bundle.

Uploading bundle

And press Upload bundle.

Now create ticket on Sonatype Jira into OSSRH section. Finished. Wait a few hours and artifact will be avaliable in central.