Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Step 5: Make sure your project is a Maven project or follow the migration process.

Step 6: Make sure coordinates are correct (rename packages if necessary).

...


Step 13:
Publish the GPG key pair and distribute your key to GPG servers:

gpg - -list-keys

gpg –keyserver gpg  - -keyserver [KEY_SERVER] –send- -send-key [KEY_ID]

Some of the key servers are: 

...

https://oss.sonatype.org/#nexus-search;quick~your-group-id

For Ant project plugins

You can also deploy your plugin to the Maven Central Repository without converting it to a Maven project.

First of all, please do the same steps as above until step 14 except step5.

Step 15: Add the Maven Ant Tasks to the lib directory.

e.g. yourproject/lib/maven-ant-tasks-2.1.3.jar

Step 16: Modify the build.xml

Please don't forget to add " xmlns:artifact="antlib:org.apache.maven.artifact.ant" to the project tag.

Please change the following:

  • your-group-id
  • your-artifact-id
  • your-version
  • your-code-name-base(changed dots to hyphens)

Note: You have to set the same version as build.xml to the manifest.mf and pom.xml.

Code Block
languagexml
titlebuild.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="your-code-name-base" default="netbeans" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant">
    <description>Builds, tests, and runs the project .</description>
    <import file="nbproject/build-impl.xml"/>

    <path id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.1.3.jar" />
    <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="maven-ant-tasks.classpath" />

    <!-- define Maven coordinates -->
    <property name="build" value="build" />
    <property name="groupId" value="your-group-id" />
    <property name="artifactId" value="your-artifact-id" />
    <!-- don't forget change the versions of pom.xml and manifest.mf -->
    <property name="version" value="your-version" />
    <!-- defined maven snapshots and staging repository id and url -->
    <property name="ossrh-snapshots-repository-url"
              value="https://oss.sonatype.org/content/repositories/snapshots/" />
    <property name="ossrh-staging-repository-url"
              value="https://oss.sonatype.org/service/local/staging/deploy/maven2/" />
    <!-- there server id in the Maven settings.xml -->
    <property name="ossrh-server-id" value="ossrh" />
    <property name="code-name-base" value="your-code-name-base(changed dots to hyphens)" />
    <property name="nbm-path" value="${build}/${artifactId}-${version}" />

    <!-- Need close and release on https://oss.sonatype.org after the nbm is uploaded -->
    <target name="deploy" depends="clean,nbm" description="deploy release version to Maven repository">
        <move file="${build}/${code-name-base}.nbm" toFile="${nbm-path}.nbm"/>
        <artifact:mvn>
            <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
            <arg value="-Durl=${ossrh-staging-repository-url}" />
            <arg value="-DrepositoryId=${ossrh-server-id}" />
            <arg value="-DpomFile=pom.xml" />
            <arg value="-Dfile=${nbm-path}.nbm" />
            <arg value="-Pgpg" />
        </artifact:mvn>
    </target>
</project>

Step 17: Modify .gitignore

Add the following:

Code Block
lib
pom.xml.asc

Step 18: Deploy to the Maven repository

Code Block
languagebash
cd /path/to/your/project
ant deploy


Code Block
deploy:
     [move] Moving 1 file to /path/to/build
[artifact:mvn] [INFO] Scanning for projects...
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] Building 
[artifact:mvn] [INFO]    task-segment: [org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file] (aggregator-style)
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] [gpg:sign-and-deploy-file]
[artifact:mvn] gpg: *警告*: "--no-use-agent"は、使われなくなったオプションです - なんの効果もありません
[artifact:mvn] gpg: *警告*: "--no-use-agent"は、使われなくなったオプションです - なんの効果もありません
[artifact:mvn] Uploading: https://oss.sonatype.org/service/local/staging/deploy/maven2//your/group/id/your-artifactId/<version-number>/your-artifactId-<version-number>.nbm
[artifact:mvn] 640K uploaded
[artifact:mvn] [INFO] Retrieving previous metadata from ossrh
[artifact:mvn] [INFO] repository metadata for: 'artifact your-groupId:your-artifactId' could not be found on repository: ossrh, so will be created
[artifact:mvn] [INFO] Uploading repository metadata for: 'artifact your-groupId:your-artifactId'
[artifact:mvn] [INFO] Uploading project information for your-artifactId <version-number>
[artifact:mvn] [INFO] Uploading your-artifactId-<version-number>.pom.asc
[artifact:mvn] [INFO] Uploading your-artifactId-<version-number>.nbm.asc
[artifact:mvn] [INFO] Metadata[artifact your-groupId:your-artifactId].filename = maven-metadata.xml
[artifact:mvn] [INFO] Metadata[project your-groupId:your-artifactId].filename = your-artifactId-<version-number>.pom
[artifact:mvn] [INFO] Metadata[gpg signature your-groupId:your-artifactId:nbm:null:pom].filename = your-artifactId-<version-number>.pom.asc
[artifact:mvn] [INFO] Metadata[gpg signature your-groupId:your-artifactId:nbm:null].filename = your-artifactId-<version-number>.nbm.asc
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] BUILD SUCCESSFUL
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] Total time: 42 seconds
[artifact:mvn] [INFO] Finished at: Mon Jun 22 07:06:51 JST 2020
[artifact:mvn] [INFO] Final Memory: 27M/604M
[artifact:mvn] [INFO] ------------------------------------------------------------------------

BUILD SUCCESSFUL
Total time: 44 seconds

Step 19: Close and release on https://oss.sonatype.org

Also, see the following:


What's next?

Knowing your groupId and artifactId pair consider registering your plugin in Apache NetBeans Plugin Portal using this instruction.

...