------ Writing a Consumer Plugin ------ Maria Odea Ching Olivier Lamy ------ 2012-12-20 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ NOTE: For help with the syntax of this file, see: ~~ http://maven.apache.org/guides/mini/guide-apt-format.html Writing a Consumer Plugin For a sample custom consumer, you can checkout the archiva-consumer-plugin at the archiva sandbox in the SVN repository: Prior to 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: [[1]] Create a project for your component. [[2]] 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. +----+ [[4]] Package your project by executing 'mvn clean package' [[5]] Let's say you are using the apache-archiva-${project.version}-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.) [[6]] Copy the jar file you created in step 4 in apache-archiva-${project.version}/apps/archiva/webapp/lib/ [[7]] Add the necessary configurations in archiva.xml (in this case, add 'discover-new-artifact' as a ) [[8]] 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=${project.version} +----+ Note: if you want to use a SNAPSHOT version, replace with the following parameter: -DarchetypeRepository=https://archiva-repository.apache.org/archiva/repository/snapshots/ \