Writing a Consumer Plugin
For a sample custom consumer, you can checkout the archiva-consumer-plugin at the archiva sandbox in the SVN repository: Starting with release 1.4, plexus components are not anymore supported, you must use Spring components.
Writing manually
Below are the steps on how to create a custom repository consumer and plug it in Archiva:
- Create a project for your component.
- Declare your class or in this case, consumer as a component as shown in the example below. This should be put at the class level.
Ex. @Service("knownRepositoryContentConsumer#discover-new-artifact") @Scope("prototype") where, Service: unique id for your consumer. Scope: the creation strategy prototype or singleton.
- Package your project by executing 'mvn clean package'
- Let's say you are using the apache-archiva-3.0.0-SNAPSHOT-bin.tar.gz to run Archiva. Unpack the binaries then go to bin/linux-x86-32/ (assuming you are running on Linux), then execute './run.sh console'. Then stop or shutdown Archiva after it started. (This is necessary to unpack the war file.)
- Copy the jar file you created in step 4 in apache-archiva-3.0.0-SNAPSHOT/apps/archiva/webapp/lib/
- Add the necessary configurations in archiva.xml (in this case, add 'discover-new-artifact' as a knownContentConsumer)
- Start up Archiva again.
Use the archetype
Prior to version 1.4-M2, you can use an archetype.
mvn archetype:generate \ -DarchetypeRepository=repo1.maven.org \ -DarchetypeGroupId=org.apache.archiva \ -DarchetypeArtifactId=archiva-consumer-archetype \ -DarchetypeVersion=3.0.0-SNAPSHOT
Note: if you want to use a SNAPSHOT version, replace with the following parameter: -DarchetypeRepository=https://archiva-repository.apache.org/archiva/repository/snapshots/ \