Repository Management with Nexus
21.4. Using the Nexus Plugin Archetype

To create a new Nexus Plugin, you can use the Nexus Plugin Archetype by with the Maven Archtetype Plugins generate goal with the filter set to "nexus-plugin-archetype" as displayed in Creating a Sample Nexus Plugin using the Archetype.
Enter the number of the nexus-plugin-archetype at the first prompt and select the version corresponding to the version of Nexus you are using. Supply the desired values for the groupId, artifactId, version, and package name for the generated plugin next and confirm you values provided.
Creating a Sample Nexus Plugin using the Archetype.
$ mvn archetype:generate -Dfilter=nexus-plugin-archetype
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------
...
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart
(org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: remote -> org.sonatype.nexus.archetypes:nexus-plugin-archetype (-)
Choose a number or apply filter (format: [groupId:]artifactId,
case sensitive contains): : 1
Choose org.sonatype.nexus.archetypes:nexus-plugin-archetype version:
1: 1.0
2: 1.1
3: 1.2
4: 2.1-RC1
5: 2.1
6: 2.1.1
7: 2.1.2
8: 2.2-SNAPSHOT
9: 2.2
10: 2.2-01
11: 2.2.1
Choose a number: 11: 11
Define value for property 'groupId': : org.sonatype.nexus.plugins
Define value for property 'artifactId': : sample-plugin
Define value for property 'version': 1.0-SNAPSHOT: :
Define value for property 'package': org.sonatype.nexus.plugins: :
[INFO] Using property: nexusVersion = 2.2.1
Confirm properties configuration:
groupId: org.sonatype.nexus.plugins
artifactId: sample-plugin
version: 1.0-SNAPSHOT
package: org.sonatype.nexus.plugins
nexusVersion: 2.2.1
Y: :
[INFO] --------------------------------------------------
[INFO] Using following parameters for creating project from Archetype:
nexus-plugin-archetype:2.2.1
[INFO] --------------------------------------------------
[INFO] Parameter: groupId, Value: org.sonatype.nexus.plugins
[INFO] Parameter: artifactId, Value: sample-plugin
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: org.sonatype.nexus.plugins
[INFO] Parameter: packageInPathFormat, Value: org/sonatype/nexus/plugins
[INFO] Parameter: package, Value: org.sonatype.nexus.plugins
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: nexusVersion, Value: 2.2.1
[INFO] Parameter: groupId, Value: org.sonatype.nexus.plugins
[INFO] Parameter: artifactId, Value: sample-plugin
[INFO] project created from Archetype in dir:
/Users/manfred/Projects/sample-plugin
[INFO] --------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] --------------------------------------------------
[INFO] Total time: 45.655s
[INFO] Finished at: Thu Nov 08 20:55:03 PST 2012
[INFO] Final Memory: 15M/153M
[INFO] --------------------------------------------------
Once the Archetype plugin has created the project, you will have a project with the layout shown in Layout of a Nexus Plugin Project in a directory using the name of the artifactId value supplied.
Layout of a Nexus Plugin Project.
pom.xml
src
main
java
org
sonatype
nexus
plugins
VirusScanner.java
VirusScannerRepositoryCustomizer.java
VirusScannerRequestProcessor.java
XYVirusScanner.java
events
InfectedItemFoundEvent.java
rest
HelloWorldPlexusResource.java
The generated project contains the following classes:
- VirusScanner
- A VirusScanner interface described in Section 21.7, “Creating a Complex Plugin”.
- VirusScannerRepositoryCustomizer
- A class which customizes the repositories affected by the VirusScanner
- VirusScannerRequestProcessor
- A class which customizes the request handling process in Nexus
- XYVirusScanner
- An implementation of the VirusScanner Interface
- InfectedItemFoundEvent
- A simple event which is fired by the VirusScanner
- HelloWorldPlexusResource
- what is that.. TODO
