15 January 2018

What to do to deliver a jar to maven central?

Basically follow some open source logic and follow sonatype issues.

  1. Project in a git

Create your own project with really new name.

  1. Choose an open source license

Only a usually one, e.g. BSD-2-cause, Apache-2, Gpl-3.
In doubt go to spdx.org to get details.
Follow the rules.

But BSD-2-cause has consequences for you to done.
Just list toplevel in the project.

  1. Create your new project

For organization order there rules or follow (just structure)
https://github.com/openCage/roast

  1. Get gpg

Todo what and how

  1. Some Information in pom.xml

pfabulist-parent
the parent pom for all bigger pfabulist projects, with all checks
http://www.github.com/openCage/pfabulist-parent

<artifactId>pfabulist-parent</artifactId>
<version>3.2.6</version>
<packaging>pom</packaging>

<licenses>
    <license>
        <name>bsd-2-clause</name>
        <comments>Copyright 2017 Stephan Pfab</comments>
    </license>
</licenses>

<scm>
    <url>git://git@github.com:openCage/pfabulist-parent.git</url>
    <connection>scm:git:git@github.com:openCage/pfabulist-parent</connection>
    <developerConnection>scm:git:git@github.com:openCage/pfabulist-parent.git</developerConnection>
</scm>

  <profiles>
        <profile>
            <id>oss</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>


    <distributionManagement>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>
  1. Get or have your own page.

That might cost you money.

  1. Work with sonatype

http://todo list the rules.

  1. Bring to maven-central

First or later delivery is the same.

You need a project that is clean.
a) all dependencies are public available
b) the version number is new
c) all your test work (run install first)
d) mvn deploy

The last transports all to maven-central