/nexus-format-archetype

Archetype for creating Nexus format plugin

Primary LanguageJava

nexus-format-archetype

Maven Central CircleCI Join the chat at https://gitter.im/sonatype/nexus-developers DepShield Badge

A Maven Archetype for creating a Nexus format plugin with a lot of the boilerplate required to start development already created.

See the nexus-development-guides for more information about developing a plugin for a new format.

How to create a format

  1. Change directory to a new folder where you wish to generate the format boilerplate code.

    NOTE: In all the commands below where you see -DarchetypeVersion=1.0.REPLACE_WITH_LATEST_ARCHETYPE_VERSION please be sure you replace 1.0.REPLACE_WITH_LATEST_ARCHETYPE_VERSION with the latest version of the archetype, like the numeric part of the version shown on the "Maven Central" badge above.

  2. Generating a format plugin is as easy as running the following:

    mvn archetype:generate -DarchetypeArtifactId=nexus-format-archetype -DarchetypeGroupId=org.sonatype.nexus.archetypes -DarchetypeVersion=1.0.REPLACE_WITH_LATEST_ARCHETYPE_VERSION -DpluginFormat=foo -DpluginClass=Foo      
    

Required parameters:

Coordinates of the archetype:

archetypeArtifactId = Must be: nexus-format-archetype

archetypeGroupId = Must be: org.sonatype.nexus.archetypes

archetypeVersion = The version of this archetype (e.g. 1.0.REPLACE_WITH_LATEST_ARCHETYPE_VERSION)

It is recommended to keep the naming of the following parameters consistent with the plugin you wish to develop:

pluginFormat = A name with no whitespace that best describes the format (e.g. raw, yum, npm etc.)

pluginClass = The class name that will be used to generate the plugin boilerplate code (e.g. Raw, Yum, Npm etc.)

Optional parameters:

nexusPluginsVersion = The version of Nexus to use in the format to be developed (default: Declared as a property in the archetype pom.xml ~line 65-> defaultNexusPluginsVersion)

artifactId = The artifactId of the format to be developed (default: nexus-repository-${pluginFormat})

groupId = The groupId (and package) of the format to be developed (default: org.sonatype.nexus.plugins)

version = The version of the format to be developed (default: 0.0.1-SNAPSHOT)

How to contribute to this archetype

Once the code has been checked out.

Build the archetype:

mvn clean install

The standard Maven Archetype Plugin docs are a good place to start.

We also use the archetype integration-test goal to verify the archetype works as expected. You may need to update some of the reference files after changes are made that affect generated source code.

Currently, the archetype integration test requires Java 8 (as does Nexus Repository Manager) to run.

You can manually run the archetype integration tests via:

mvn clean package archetype:integration-test

Archetype IT Debugging notes

After running the above ... package archetype:integration-test command, you may see integration test errors like:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.1.1:integration-test (default-cli) on project nexus-format-archetype: 
[ERROR] Archetype IT 'it1' failed: Some content are not equals

This occurs when archetype-resources files have been changed, but the IT reference source files no longer match the output produced by the archetype. Any changes made to the files in the archetype-resources folder will have to be made to the corresponding files in the reference folder. One quick way to find out which files differ is to compare the following two directories:

$ diff -r target/test-classes/projects/it1/reference/ target/test-classes/projects/it1/project/nexus-repository-foo/
diff -r target/test-classes/projects/it1/reference/pom.xml target/test-classes/projects/it1/project/nexus-repository-foo/pom.xml
29c29
<   <packaging>zzzbundle</packaging>
---
>   <packaging>bundle</packaging>

In the command above, the first directory holds the "expected" (reference) output. The second directory holds the "actual" output generated by running the archetype integration test.

ITreferenceDiff

Releasing

Releases occur automatically after a commit to the main branch.

To avoid performing a release after a commit to main, be sure your commit message includes [skip ci] .