]> source.dussan.org Git - archiva.git/commitdiff
[MRM-980] ability to merge repositories
authorMaria Odea B. Ching <oching@apache.org>
Fri, 2 Jul 2010 07:18:44 +0000 (07:18 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Fri, 2 Jul 2010 07:18:44 +0000 (07:18 +0000)
submitted by Patti Arachchige Eshan Sudharaka (for GSoC)

o added new plugin module for repository merge

git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-MRM-980@959880 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/plugins/pom.xml
archiva-modules/plugins/stage-repository-merge/.project [new file with mode: 0644]
archiva-modules/plugins/stage-repository-merge/pom.xml [new file with mode: 0644]
archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/repodetails/SourceAritfacts.java [new file with mode: 0644]
archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/repomerge/ArtifactsMerger.java [new file with mode: 0644]
archiva-modules/plugins/stage-repository-merge/src/test/java/org/apache/archiva/stagerepository/merge/repodetails/SourceArtifactsTest.java [new file with mode: 0644]
archiva-modules/plugins/stage-repository-merge/src/test/java/org/apache/archiva/stagerepository/merge/repomerge/ArtifactsMergerTest.java [new file with mode: 0644]
archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.jar [new file with mode: 0755]
archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.pom [new file with mode: 0755]
archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/1.2.1/maven-metadata.xml [new file with mode: 0755]
archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/maven-metadata.xml [new file with mode: 0755]

index 6f24b170f4463c65b59df86c4c81a0022e68e402..60064b8f0c8b05f8b5e055cf1ce613adb3e21535 100644 (file)
@@ -35,6 +35,7 @@
     <!-- TODO: eventually not a core plugin, needs to be moved to a separate tree, with it's own Selenium tests -->
     <module>npanday-support</module>
     <module>maven1-repository</module>
+    <module>stage-repository-merge</module>
     <module>generic-metadata-support</module>
   </modules>
-</project>
\ No newline at end of file
+</project>
diff --git a/archiva-modules/plugins/stage-repository-merge/.project b/archiva-modules/plugins/stage-repository-merge/.project
new file mode 100644 (file)
index 0000000..c7409c4
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>stage-repository-merge</name>
+       <comment>Archiva is an application for managing one or more remote
+    repositories, including administration, artifact handling,
+    browsing and searching. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
+       <projects>
+               <project>archiva-checksum</project>
+               <project>archiva-common</project>
+               <project>archiva-configuration</project>
+               <project>archiva-consumer-api</project>
+               <project>archiva-model</project>
+               <project>archiva-policies</project>
+               <project>archiva-repository-layer</project>
+               <project>archiva-xml-tools</project>
+               <project>maven2-repository</project>
+               <project>metadata-model</project>
+               <project>metadata-repository-api</project>
+               <project>problem-reports</project>
+               <project>test-repository</project>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/archiva-modules/plugins/stage-repository-merge/pom.xml b/archiva-modules/plugins/stage-repository-merge/pom.xml
new file mode 100644 (file)
index 0000000..4e273bf
--- /dev/null
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+       xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>plugins</artifactId>
+    <groupId>org.apache.archiva</groupId>
+    <version>1.4-SNAPSHOT</version>
+  </parent>
+  <groupId>org.apache.archiva</groupId>
+  <artifactId>stage-repository-merge</artifactId>
+  <name>stage-repository-merge</name>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.5</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-spring</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>metadata-repository-api</artifactId>
+      <version>1.4-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-repository-layer</artifactId>
+      <version>1.4-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>maven2-repository</artifactId>
+      <version>1.4-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-model</artifactId>
+      <version>1.4-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
+      <version>1.8.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>test-repository</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-jdk14</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>test-repository</id>
+            <phase>generate-test-resources</phase>
+            <goals>
+              <goal>unpack-dependencies</goal>
+            </goals>
+            <configuration>
+              <includeArtifactIds>test-repository</includeArtifactIds>
+              <outputDirectory>target/test-repository</outputDirectory>
+              <excludes>META-INF/**</excludes>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.codehaus.plexus</groupId>
+          <artifactId>plexus-component-metadata</artifactId>
+          <version>1.0-beta-3.0.5</version>
+          <executions>
+            <execution>
+              <id>process-classes</id>
+              <goals>
+                <goal>generate-metadata</goal>
+              </goals>
+            </execution>
+            <execution>
+              <id>process-test-classes</id>
+              <goals>
+                <goal>generate-test-metadata</goal>
+              </goals>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
diff --git a/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/repodetails/SourceAritfacts.java b/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/repodetails/SourceAritfacts.java
new file mode 100644 (file)
index 0000000..513f060
--- /dev/null
@@ -0,0 +1,161 @@
+package org.apache.archiva.stagerepository.merge.repodetails;
+
+/*
+ * 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.
+ */
+
+import org.apache.archiva.metadata.repository.MetadataResolver;
+import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+
+import java.util.List;
+import java.util.Collection;
+import java.util.ArrayList;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @plexus.component role="org.apache.archiva.stagerepository.merge.repodetails.SourceAritfacts"
+ */
+public class SourceAritfacts
+{
+
+    /**
+     * @plexus.requirement
+     */    
+    private MetadataResolver metadataResolver;
+
+    private ArrayList<String> rootNameSpacesList;
+
+    private ArrayList<String> gruopIdList;
+
+    private ArrayList<String> artifactsList;
+
+    private ArrayList<String> artifactsVersionsList;
+
+    private List<ArchivaArtifact> artifactsListWithDetails;
+
+    private String repoId;
+
+    private static final Logger log = LoggerFactory.getLogger( SourceAritfacts.class );
+
+    public String getRepoId()
+    {
+        return repoId;
+    }
+
+    public void setRepoId( String repoId )
+    {
+        this.repoId = repoId;
+    }
+
+    // this methos returns a ArtifactMetaData List.(i guess no harm due to hardcoding the Artifact type and version)
+    public Collection<ArtifactMetadata> getSourceArtifactsMetaData( ArchivaArtifact artifact )
+    {
+
+        return metadataResolver.getArtifacts( artifact.getRepositoryId(), artifact.getGroupId(),
+                                              artifact.getArtifactId(), artifact.getVersion() );
+    }
+
+    public Collection<ArchivaArtifact> getSourceArtifactList()
+    {
+        artifactsListWithDetails = new ArrayList<ArchivaArtifact>();
+
+        process();
+
+        return artifactsListWithDetails;
+    }
+
+    public void setMetadataResolver( MetadataResolver metadataResolver )
+    {
+        this.metadataResolver = metadataResolver;
+    }
+
+    private void process()
+    {
+        // this will get the root name spaces eg : org, com
+        rootNameSpacesList = (ArrayList<String>) metadataResolver.getRootNamespaces( repoId );
+
+        gruopIdList = new ArrayList<String>();
+
+        artifactsList = new ArrayList<String>();
+
+        // following iterates through the root name spaces list and get the gruo id of relavet root name spaces.
+        for ( String namespace : rootNameSpacesList )
+        {
+            // this will get the gruop id list of relavant name space . eg : org > archiva(gruop id)
+            gruopIdList = (ArrayList<String>) metadataResolver.getNamespaces( repoId, namespace );
+
+            // following will iterates through the particular gruop id 's
+            for ( String gruopId : gruopIdList )
+            {
+                // parse the parameters "repoId" and "namespace + gruop id "to artifacts list. eg : params = ("internal"
+                // , "org.archiva")
+                artifactsList = (ArrayList<String>) metadataResolver.getNamespaces( repoId, namespace + "." + gruopId );
+
+                for ( String artifact : artifactsList )
+                {
+                    // iterates through the artifacts and get the available versions of a particular artifact
+                    artifactsVersionsList =
+                        (ArrayList<String>) metadataResolver.getProjectVersions( repoId, namespace + "." + gruopId,
+                                                                                 artifact );
+
+                    for ( String version : artifactsVersionsList )
+                    {
+                        // assign gathered attributes Artifact object and add it in to the list
+                        artifactsListWithDetails.addAll( getArtifactMetadata( repoId, gruopId, artifact, version ) );
+
+                    }
+                }
+            }
+        }
+
+    }
+
+    private Collection<ArchivaArtifact> getArtifactMetadata( String repoId, String gruopId, String artifactId,
+                                                             String version )
+    {
+        MavenArtifactFacet facet = null;
+
+        List<ArchivaArtifact> artifactList = new ArrayList<ArchivaArtifact>();
+
+        ArrayList<ArtifactMetadata> artifactMetaDataList =
+            (ArrayList<ArtifactMetadata>) metadataResolver.getArtifacts( repoId, gruopId, artifactId, version );
+
+        for ( ArtifactMetadata artifactMetadata : artifactMetaDataList )
+        {
+
+            facet = (MavenArtifactFacet) artifactMetadata.getFacet( MavenArtifactFacet.FACET_ID );
+
+            if ( facet != null )
+            {
+                artifactList.add( new ArchivaArtifact( gruopId, artifactId, version, facet.getClassifier(),
+                                                       facet.getType(), repoId ) );
+
+            }
+            else
+            {
+                artifactList.add( new ArchivaArtifact( gruopId, artifactId, version, "", "jar", repoId ) );
+            }
+
+        }
+        return artifactList;
+    }
+}
diff --git a/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/repomerge/ArtifactsMerger.java b/archiva-modules/plugins/stage-repository-merge/src/main/java/org/apache/archiva/stagerepository/merge/repomerge/ArtifactsMerger.java
new file mode 100644 (file)
index 0000000..9e24c8d
--- /dev/null
@@ -0,0 +1,407 @@
+package org.apache.archiva.stagerepository.merge.repomerge;
+
+/*
+ * 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.
+ */
+
+import org.apache.archiva.stagerepository.merge.repodetails.SourceAritfacts;
+import org.apache.archiva.metadata.repository.MetadataResolver;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.repository.ManagedRepositoryContent;
+import org.apache.maven.archiva.repository.RepositoryContentFactory;
+import org.apache.maven.archiva.repository.RepositoryNotFoundException;
+import org.apache.maven.archiva.repository.RepositoryException;
+import org.apache.maven.archiva.repository.metadata.MetadataTools;
+import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException;
+import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader;
+import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter;
+import org.apache.maven.archiva.common.utils.VersionComparator;
+import org.apache.maven.archiva.common.utils.VersionUtil;
+
+import java.util.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+/**
+ * @plexus.component role="org.apache.archiva.stagerepository.merge.repomerge.ArtifactsMerger"
+ */
+public class ArtifactsMerger
+{
+
+    /**
+     * @plexus.requirement
+     */
+    private MetadataResolver metadataResolver;
+
+    /**
+     * @plexus.requirement
+     */
+    private RepositoryContentFactory repositoryFactory;
+
+    /**
+     * @plexus.requirement role-hint="default"
+     */
+    private ArchivaConfiguration configuration;
+
+    private SourceAritfacts sourceArtifacts;
+
+    private String targetRepo;
+
+    private String sourceRepo;
+
+    private ArrayList<ArchivaArtifact> sourceArtifactsList;
+
+    private Configuration config;
+
+    private ManagedRepositoryConfiguration targetRepoConfig;
+
+    private ManagedRepositoryConfiguration sourceRepoConfig;
+
+    private ManagedRepositoryContent targetRepository;
+
+    private ManagedRepositoryContent sourceRepository;
+
+    private final static String PATH_SEPERATOR = "/";
+
+    public void setMetadataResolver( MetadataResolver metadataResolver )
+    {
+        this.metadataResolver = metadataResolver;
+    }
+
+    public void setSourceArtifacts( SourceAritfacts sourceArtifacts )
+    {
+        this.sourceArtifacts = sourceArtifacts;
+        setSourceArtifactsList();
+    }
+
+    public void setConfiguration( ArchivaConfiguration configuration )
+    {
+        this.configuration = configuration;
+    }
+
+    public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
+    {
+        this.repositoryFactory = repositoryFactory;
+    }
+
+    public ArtifactsMerger( String targetRepo, String sourceRepo )
+    {
+        this.targetRepo = targetRepo;
+        this.sourceRepo = sourceRepo;
+
+    }
+
+    private void setSourceArtifactsList()
+    {
+        sourceArtifacts.setRepoId( sourceRepo );
+        sourceArtifactsList = (ArrayList) sourceArtifacts.getSourceArtifactList();
+    }
+
+    private boolean isArtifactAvailableIntagerRepo( ArchivaArtifact artifact )
+    {
+
+        boolean isAvailable = false;
+
+        Collection<ArtifactMetadata> list =
+            metadataResolver.getArtifacts( targetRepo, artifact.getGroupId(), artifact.getArtifactId(),
+                                           artifact.getVersion() );
+
+        if ( list.isEmpty() )
+        {
+            isAvailable = false;
+        }
+        else
+        {
+            isAvailable = true;
+        }
+        return isAvailable;
+    }
+
+    public void doMerge()
+        throws Exception
+    {
+        try
+        {
+            config = configuration.getConfiguration();
+
+            targetRepoConfig = config.findManagedRepositoryById( targetRepo );
+
+            targetRepository = repositoryFactory.getManagedRepositoryContent( targetRepo );
+
+            sourceRepoConfig = config.findManagedRepositoryById( sourceRepo );
+
+            sourceRepository = repositoryFactory.getManagedRepositoryContent( sourceRepo );
+
+            // iterates through available arfifacts list
+            for ( ArchivaArtifact sourceArtifact : sourceArtifactsList )
+            {
+
+                if ( isArtifactAvailableIntagerRepo( sourceArtifact ) )
+                {
+                    // TODO here we need to implement replacing the exixting one
+                }
+                else
+                {
+                    // when the artifact does not exist in the repo folder structure creation is done
+                    createFolderStructure( sourceArtifact );
+                }
+            }
+        }
+        catch ( RepositoryNotFoundException re )
+        {
+            throw re;
+        }
+        catch ( RepositoryException rep )
+        {
+            throw rep;
+        }
+    }
+
+    private void createFolderStructure( ArchivaArtifact artifact )
+        throws IOException, RepositoryMetadataException
+    {
+
+        Date lastUpdatedTimestamp = Calendar.getInstance().getTime();
+
+        TimeZone timezone = TimeZone.getTimeZone( "UTC" );
+
+        DateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
+
+        fmt.setTimeZone( timezone );
+
+        String timestamp = fmt.format( lastUpdatedTimestamp );
+
+        String targetRepoPath = targetRepoConfig.getLocation();
+
+        String sourceRepoPath = sourceRepoConfig.getLocation();
+
+        String artifactPath = sourceRepository.toPath( artifact );
+
+        File sourceArtifactFile = new File( sourceRepoPath, artifactPath );
+
+        File targetArtifactFile = new File( targetRepoPath, artifactPath );
+
+        int lastIndex = artifactPath.lastIndexOf( '/' );
+
+        // create a file object to the artifact version directory eg
+        // :/boot/gsoc/apps/apache-archiva-1.4-SNAPSHOT/data/repositories/internal/ant/ant/1.5.1
+        File targetFile = new File( targetRepoPath, artifactPath.substring( 0, lastIndex ) );
+
+        if ( !targetFile.exists() )
+        {
+            // create the folder structure when it does not exist
+            targetFile.mkdirs();
+        }
+
+        // artifact copying
+        copyFile( sourceArtifactFile, targetArtifactFile );
+        // pom file copying
+        String index = artifactPath.substring( lastIndex + 1 );
+        int last = index.lastIndexOf( '.' );
+        File sourcePomFile =
+            new File( sourceRepoPath, artifactPath.substring( 0, lastIndex ) + "/"
+                + artifactPath.substring( lastIndex + 1 ).substring( 0, last ) + ".pom" );
+        File targetPomFile =
+            new File( targetRepoPath, artifactPath.substring( 0, lastIndex ) + "/"
+                + artifactPath.substring( lastIndex + 1 ).substring( 0, last ) + ".pom" );
+
+        if ( !targetPomFile.exists() )
+        {
+            copyFile( sourcePomFile, targetPomFile );
+        }
+
+        // explicitly update only if metadata-updater consumer is not enabled!
+        if ( !config.getRepositoryScanning().getKnownContentConsumers().contains( "metadata-updater" ) )
+        {
+
+            // maven version meta data file copying
+
+            File versionMetadataFileInSourceArtifact =
+                new File( sourceRepoPath, artifactPath.substring( 0, lastIndex ) + "/" + MetadataTools.MAVEN_METADATA );
+
+            File versionMetadataFileInTargetArtifact = null;
+
+            // check metadata xml is available in source repo. if there is a metadata xml we are going to merge is as
+            // well
+            if ( versionMetadataFileInSourceArtifact.exists() )
+            {
+                versionMetadataFileInTargetArtifact =
+                    new File( targetRepoPath, artifactPath.substring( 0, lastIndex ) + "/"
+                        + MetadataTools.MAVEN_METADATA );
+
+                // check metadata xml is available in target repo. if it is not available copy it from the source
+                // artifact
+                if ( !versionMetadataFileInTargetArtifact.exists() )
+                {
+                    copyFile( versionMetadataFileInSourceArtifact, versionMetadataFileInTargetArtifact );
+                }
+                else
+                {
+                    // if version metadata file exists then update it.
+                    updateVersionMetadata( versionMetadataFileInTargetArtifact, artifact, lastUpdatedTimestamp,
+                                           timestamp );
+                }
+            }
+
+            // project level maven meta data xml copying
+            String projectDirectoryInSourceRepo =
+                new File( versionMetadataFileInSourceArtifact.getParent() ).getParent();
+            File projectMetadataFileInSourceArtifact =
+                new File( projectDirectoryInSourceRepo, MetadataTools.MAVEN_METADATA );
+
+            // check metadata xml is available in source repo. if there is a metadata xml we are going to merge is as
+            // well
+            if ( projectMetadataFileInSourceArtifact.exists() )
+            {
+
+                String projectDirectoryInTargetRepo =
+                    new File( versionMetadataFileInTargetArtifact.getParent() ).getParent();
+                File projectMetadataFileInTargetArtifact =
+                    new File( projectDirectoryInTargetRepo, MetadataTools.MAVEN_METADATA );
+                // check metadata xml is available in target repo.if it is not available copy it from the source
+                // artifact
+                if ( !projectMetadataFileInTargetArtifact.exists() )
+                {
+                    copyFile( projectMetadataFileInSourceArtifact, projectMetadataFileInTargetArtifact );
+                }
+                else
+                {
+                    // // if project metadata file exists then update it.
+                    updateProjectMetadata( projectMetadataFileInTargetArtifact, artifact, lastUpdatedTimestamp,
+                                           timestamp );
+                }
+            }
+        }
+    }
+
+    private void copyFile( File sourceFile, File targetFile )
+        throws IOException
+    {
+
+        FileOutputStream out = new FileOutputStream( targetFile );
+        FileInputStream input = new FileInputStream( sourceFile );
+
+        try
+        {
+            int i;
+            while ( ( i = input.read() ) != -1 )
+            {
+                out.write( i );
+            }
+            out.flush();
+        }
+        finally
+        {
+            out.close();
+            input.close();
+        }
+    }
+
+    /**
+     * Update artifact level metadata.
+     */
+    private void updateProjectMetadata( File projectMetaDataFileIntargetRepo, ArchivaArtifact artifact,
+                                        Date lastUpdatedTimestamp, String timestamp )
+        throws RepositoryMetadataException
+    {
+        ArrayList<String> availableVersions = new ArrayList<String>();
+        String latestVersion = "";
+
+        ArchivaRepositoryMetadata projectMetadata = getMetadata( projectMetaDataFileIntargetRepo );
+
+        if ( projectMetaDataFileIntargetRepo.exists() )
+        {
+            availableVersions = (ArrayList<String>) projectMetadata.getAvailableVersions();
+
+            Collections.sort( availableVersions, VersionComparator.getInstance() );
+
+            if ( !availableVersions.contains( artifact.getVersion() ) )
+            {
+                availableVersions.add( artifact.getVersion() );
+            }
+
+            latestVersion = availableVersions.get( availableVersions.size() - 1 );
+        }
+        else
+        {
+            availableVersions.add( artifact.getVersion() );
+            projectMetadata.setGroupId( artifact.getGroupId() );
+            projectMetadata.setArtifactId( artifact.getArtifactId() );
+        }
+
+        if ( projectMetadata.getGroupId() == null )
+        {
+            projectMetadata.setGroupId( artifact.getGroupId() );
+        }
+
+        if ( projectMetadata.getArtifactId() == null )
+        {
+            projectMetadata.setArtifactId( artifact.getArtifactId() );
+        }
+
+        projectMetadata.setLatestVersion( latestVersion );
+        projectMetadata.setAvailableVersions( availableVersions );
+        projectMetadata.setLastUpdated( timestamp );
+        projectMetadata.setLastUpdatedTimestamp( lastUpdatedTimestamp );
+
+        if ( !VersionUtil.isSnapshot( artifact.getVersion() ) )
+        {
+            projectMetadata.setReleasedVersion( latestVersion );
+        }
+
+        RepositoryMetadataWriter.write( projectMetadata, projectMetaDataFileIntargetRepo );
+
+    }
+
+    private void updateVersionMetadata( File versionMetaDataFileInTargetRepo, ArchivaArtifact artifact,
+                                        Date lastUpdatedTimestamp, String timestamp )
+        throws RepositoryMetadataException
+    {
+        ArchivaRepositoryMetadata versionMetadata = getMetadata( versionMetaDataFileInTargetRepo );
+        if ( !versionMetaDataFileInTargetRepo.exists() )
+        {
+            versionMetadata.setGroupId( artifact.getGroupId() );
+            versionMetadata.setArtifactId( artifact.getArtifactId() );
+            versionMetadata.setVersion( artifact.getVersion() );
+        }
+
+        // versionMetadata.getSnapshotVersion().setTimestamp(timestamp);
+        versionMetadata.setLastUpdatedTimestamp( lastUpdatedTimestamp );
+        RepositoryMetadataWriter.write( versionMetadata, versionMetaDataFileInTargetRepo );
+    }
+
+    private ArchivaRepositoryMetadata getMetadata( File metadataFile )
+        throws RepositoryMetadataException
+    {
+        ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
+        if ( metadataFile.exists() )
+        {
+            metadata = RepositoryMetadataReader.read( metadataFile );
+        }
+        return metadata;
+    }
+}
diff --git a/archiva-modules/plugins/stage-repository-merge/src/test/java/org/apache/archiva/stagerepository/merge/repodetails/SourceArtifactsTest.java b/archiva-modules/plugins/stage-repository-merge/src/test/java/org/apache/archiva/stagerepository/merge/repodetails/SourceArtifactsTest.java
new file mode 100644 (file)
index 0000000..8c045a7
--- /dev/null
@@ -0,0 +1,134 @@
+package org.apache.archiva.stagerepository.merge.repodetails;
+
+/*
+ * 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.
+ */
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.junit.Test;
+
+import org.apache.archiva.metadata.repository.MetadataResolver;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+
+import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.easymock.MockControl;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class SourceArtifactsTest
+    extends PlexusInSpringTestCase
+{
+
+    private Logger log = LoggerFactory.getLogger( SourceArtifactsTest.class );
+
+    private MockControl metadataResolverControl;
+
+    private MetadataResolver metadataResolver;
+
+    private static final String TEST_REPO_ID = "internal";
+
+    private SourceAritfacts sourceArtifacts;
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        sourceArtifacts = new SourceAritfacts();
+        sourceArtifacts.setRepoId( TEST_REPO_ID );
+        metadataResolverControl = MockControl.createControl( MetadataResolver.class );
+        metadataResolver = (MetadataResolver) metadataResolverControl.getMock();
+        sourceArtifacts.setMetadataResolver( metadataResolver );
+    }
+
+    @Test
+    public void testSourceArtifacts()
+    {
+
+        metadataResolverControl.expectAndReturn( metadataResolver.getRootNamespaces( TEST_REPO_ID ), getRootNameSpace() );
+
+        metadataResolverControl.expectAndReturn( metadataResolver.getNamespaces( TEST_REPO_ID, "org" ), getNameSpace() );
+
+        metadataResolverControl.expectAndReturn( metadataResolver.getNamespaces( TEST_REPO_ID, "org" + "." + "apache" ),
+                                                 getProject() );
+
+        metadataResolverControl.expectAndReturn( metadataResolver.getProjectVersions( TEST_REPO_ID, "org" + "."
+            + "apache", "archiva" ), getProjectVersions() );
+
+        metadataResolverControl.expectAndReturn( metadataResolver.getArtifacts( TEST_REPO_ID, "apache", "archiva",
+                                                                                "1.6" ), getArtiFactMetaData() );
+
+        metadataResolverControl.expectAndReturn( metadataResolver.getArtifacts( TEST_REPO_ID, "apache", "archiva",
+                                                                                "1.6" ), getArtiFactMetaData() );
+
+        metadataResolverControl.replay();
+
+        Collection<ArchivaArtifact> list = sourceArtifacts.getSourceArtifactList();
+        assertEquals( false, list.isEmpty() );
+
+        ArrayList<ArtifactMetadata> metadataList =
+            (ArrayList) sourceArtifacts.getSourceArtifactsMetaData( list.iterator().next() );
+        assertEquals( 2, metadataList.size() );
+
+        metadataResolverControl.verify();
+
+    }
+
+    private Collection<String> getRootNameSpace()
+    {
+        List<String> artifactList = new ArrayList<String>();
+        artifactList.add( "org" );
+        return artifactList;
+    }
+
+    private Collection<String> getNameSpace()
+    {
+        List<String> namespace = new ArrayList<String>();
+        namespace.add( "apache" );
+        return namespace;
+    }
+
+    private Collection<String> getProject()
+    {
+        List<String> namespace = new ArrayList<String>();
+        namespace.add( "archiva" );
+        return namespace;
+    }
+
+    private Collection<String> getProjectVersions()
+    {
+        List<String> versionList = new ArrayList<String>();
+        versionList.add( "1.6" );
+        return versionList;
+    }
+
+    private Collection<ArtifactMetadata> getArtiFactMetaData()
+    {
+        List<ArtifactMetadata> metaDataList = new ArrayList<ArtifactMetadata>();
+        ArtifactMetadata metaDataOne = new ArtifactMetadata();
+        ArtifactMetadata metaDataTwo = new ArtifactMetadata();
+        metaDataList.add( metaDataOne );
+        metaDataList.add( metaDataTwo );
+        return metaDataList;
+    }
+}
diff --git a/archiva-modules/plugins/stage-repository-merge/src/test/java/org/apache/archiva/stagerepository/merge/repomerge/ArtifactsMergerTest.java b/archiva-modules/plugins/stage-repository-merge/src/test/java/org/apache/archiva/stagerepository/merge/repomerge/ArtifactsMergerTest.java
new file mode 100644 (file)
index 0000000..4f39b0e
--- /dev/null
@@ -0,0 +1,181 @@
+package org.apache.archiva.stagerepository.merge.repomerge;
+
+/*
+ * 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.
+ */
+
+import static org.junit.Assert.assertNotNull;
+import org.junit.Before;
+import org.junit.Test;
+import static org.mockito.Mockito.stub;
+
+import static org.mockito.Mockito.verify;
+import org.mockito.MockitoAnnotations;
+import static org.mockito.Mockito.*;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+import org.apache.maven.archiva.repository.RepositoryContentFactory;
+import org.apache.maven.archiva.repository.ManagedRepositoryContent;
+import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.archiva.stagerepository.merge.repodetails.SourceAritfacts;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.repository.MetadataResolver;
+//import com.sun.xml.internal.ws.api.wsdl.parser.MetaDataResolver;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.io.File;
+
+public class ArtifactsMergerTest
+    extends PlexusInSpringTestCase
+{
+
+    private static final String SOURCE_REPOSITORY_ID = "test-repository";
+
+    private static final String TARGET_REPOSITORY_ID = "target-repo";
+
+    // private static final String TARGET_REPOSITORY_ID = "target-repo";
+
+    private Configuration config;
+
+    @MockitoAnnotations.Mock
+    private MetadataResolver metadataResolver;
+
+    private RepositoryContentFactory repositoryFactory;
+
+    private ArchivaConfiguration configuration;
+
+    private SourceAritfacts sourceArtifacts;
+
+    private ArtifactsMerger merger;
+
+    @Before
+    public void setUp()
+    {
+        MockitoAnnotations.initMocks( this );
+        metadataResolver = mock( MetadataResolver.class );
+        repositoryFactory = mock( RepositoryContentFactory.class );
+        configuration = mock( ArchivaConfiguration.class );
+        sourceArtifacts = mock( SourceAritfacts.class );
+        sourceArtifacts.setRepoId( SOURCE_REPOSITORY_ID );
+        sourceArtifacts.setMetadataResolver( metadataResolver );
+        setRepositoryConfigurations();
+        merger = new ArtifactsMerger( TARGET_REPOSITORY_ID, SOURCE_REPOSITORY_ID );
+        merger.setConfiguration( configuration );
+        merger.setRepositoryFactory( repositoryFactory );
+        merger.setMetadataResolver( metadataResolver );
+        setSourceArtifacts();
+    }
+
+    @Test
+    public void setSourceArtifacts()
+    {
+        when( sourceArtifacts.getSourceArtifactList() ).thenReturn( getArtifacts() );
+        merger.setSourceArtifacts( sourceArtifacts );
+        verify( sourceArtifacts ).getSourceArtifactList();
+    }
+
+    @Test
+    public void testDomerge()
+        throws Exception
+    {
+        ManagedRepositoryContent sourceRepoContent = new ManagedDefaultRepositoryContent();
+        sourceRepoContent.setRepository( config.findManagedRepositoryById( SOURCE_REPOSITORY_ID ) );
+
+        ManagedRepositoryContent targetRepoContent = new ManagedDefaultRepositoryContent();
+        sourceRepoContent.setRepository( config.findManagedRepositoryById( TARGET_REPOSITORY_ID ) );
+
+        when( configuration.getConfiguration() ).thenReturn( config );
+        when( repositoryFactory.getManagedRepositoryContent( SOURCE_REPOSITORY_ID ) ).thenReturn( sourceRepoContent );
+        when( repositoryFactory.getManagedRepositoryContent( TARGET_REPOSITORY_ID ) ).thenReturn( targetRepoContent );
+        when( sourceArtifacts.getSourceArtifactList() ).thenReturn( getArtifacts() );
+        when( metadataResolver.getArtifacts( TARGET_REPOSITORY_ID, "archiva", "archiva", "1.2.1" ) ).thenReturn( getMetaDataList() );
+        merger.doMerge();
+
+        // verify(configuration);
+        // verify(repositoryFactory);
+        // verify(repositoryFactory);
+        // verify(sourceArtifacts);
+        verify( configuration ).getConfiguration();
+        verify( repositoryFactory ).getManagedRepositoryContent( SOURCE_REPOSITORY_ID );
+        verify( repositoryFactory ).getManagedRepositoryContent( TARGET_REPOSITORY_ID );
+        verify( sourceArtifacts ).getSourceArtifactList();
+        verify( metadataResolver ).getArtifacts( TARGET_REPOSITORY_ID, "org.apache.archiva", "archiva", "1.2.1" );
+    }
+
+    public Collection<ArchivaArtifact> getArtifacts()
+    {
+        ArchivaArtifact a1 =
+            new ArchivaArtifact( "org.apache.archiva", "archiva", "1.2.1", "", "jar", SOURCE_REPOSITORY_ID );
+        ArchivaArtifact a2 =
+            new ArchivaArtifact( "org.apache.archiva", "archiva", "1.5", "", "jar", SOURCE_REPOSITORY_ID );
+        ArrayList<ArchivaArtifact> list = new ArrayList<ArchivaArtifact>();
+        list.add( a1 );
+        // list.add(a2) ;
+        return list;
+    }
+
+    public Collection<ArtifactMetadata> getMetaDataList()
+    {
+        ArtifactMetadata m1 = new ArtifactMetadata();
+        m1.setNamespace( "org.apache.archiva" );
+        m1.setProject( "archiva" );
+        m1.setVersion( "1.2.1" );
+        ArrayList<ArtifactMetadata> list = new ArrayList<ArtifactMetadata>();
+        list.add( m1 );
+        return list;
+    }
+
+    public void setRepositoryConfigurations()
+    {
+        File sourceRepoFile = new File( getBasedir(), "src/test/resources/test-repository" );
+        File targetRepoFile = new File( getBasedir(), "src/test/resources/target-repo" );
+        // sourceRepoFile.mkdirs();
+        // targetRepoFile.mkdirs();
+
+        assertTrue( sourceRepoFile.exists() );
+        this.config = new Configuration();
+        RepositoryScanningConfiguration repoScanConfig = new RepositoryScanningConfiguration();
+        List<String> knownContentConsumers = new ArrayList<String>();
+        knownContentConsumers.add( "metadata-updater12" );
+        repoScanConfig.setKnownContentConsumers( knownContentConsumers );
+        config.setRepositoryScanning( repoScanConfig );
+        // config.setManagedRepositories();
+        ManagedRepositoryConfiguration sourceRepoConfig = new ManagedRepositoryConfiguration();
+        sourceRepoConfig.setId( SOURCE_REPOSITORY_ID );
+        sourceRepoConfig.setLayout( "default" );
+        sourceRepoConfig.setLocation( sourceRepoFile.getPath() );
+        sourceRepoConfig.setName( SOURCE_REPOSITORY_ID );
+        sourceRepoConfig.setBlockRedeployments( true );
+
+        ManagedRepositoryConfiguration targetRepoConfig = new ManagedRepositoryConfiguration();
+        targetRepoConfig.setId( TARGET_REPOSITORY_ID );
+        targetRepoConfig.setLayout( "default" );
+        targetRepoConfig.setLocation( targetRepoFile.getPath() );
+        targetRepoConfig.setName( TARGET_REPOSITORY_ID );
+        targetRepoConfig.setBlockRedeployments( true );
+
+        this.config.addManagedRepository( sourceRepoConfig );
+        this.config.addManagedRepository( targetRepoConfig );
+    }
+}
diff --git a/archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.jar b/archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.jar
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.pom b/archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/1.2.1/archiva-1.2.1.pom
new file mode 100755 (executable)
index 0000000..cccf517
--- /dev/null
@@ -0,0 +1,1199 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>2.0.6</maven>
+  </prerequisites>
+
+  <parent>
+    <groupId>org.apache.archiva</groupId>
+    <artifactId>archiva-parent</artifactId>
+    <version>3</version>
+    <relativePath>../parent/pom.xml</relativePath>
+  </parent>
+  <name>Archiva</name>
+  <artifactId>archiva</artifactId>
+  <packaging>pom</packaging>
+  <version>1.2.1</version>
+  <url>http://archiva.apache.org</url>
+  <scm>
+    <connection>scm:svn:http://svn.apache.org/repos/asf/archiva/tags/archiva-1.2.1</connection>
+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/archiva/tags/archiva-1.2.1</developerConnection>
+    <url>http://svn.apache.org/viewvc/archiva/tags/archiva-1.2.1</url>
+  </scm>
+
+  <build>
+    <plugins>
+      <!-- We want to package up license resources in the JARs produced -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-remote-resources-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>process</goal>
+            </goals>
+            <configuration>
+              <resourceBundles>
+                <resourceBundle>org.apache:apache-jar-resource-bundle:1.3</resourceBundle>
+              </resourceBundles>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <version>1.0-alpha-4</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <configuration>
+              <rules>
+                <bannedDependencies>
+                  <excludes>
+                    <exclude>org.codehaus.plexus:plexus-container-default</exclude>
+                    <exclude>org.codehaus.plexus:plexus-log4j-logging</exclude>
+                    <exclude>commons-logging:commons-logging</exclude>
+                    <exclude>velocity:velocity-dep</exclude>
+                    <exclude>classworlds:classworlds</exclude>
+                    <exclude>javax.transaction:jta</exclude>
+                    <exclude>javax.sql:jdbc-stdext</exclude>
+                    <exclude>ant:ant-optional</exclude>
+                    <exclude>xom:xom</exclude>
+                    <exclude>org.codehaus.plexus:plexus-xwork-integration</exclude>
+                  </excludes>
+                </bannedDependencies>
+              </rules>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-component-metadata</artifactId>
+        <version>1.0-beta-3.0.5</version>
+        <executions>
+          <execution>
+            <id>generate</id>
+            <goals>
+              <goal>generate-metadata</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.codehaus.modello</groupId>
+          <artifactId>modello-maven-plugin</artifactId>
+          <version>1.0</version>
+          <configuration>
+            <useJava5>true</useJava5>
+          </configuration>
+          <dependencies>
+            <dependency>
+              <groupId>org.codehaus.modello</groupId>
+              <artifactId>modello-plugin-plexus-registry</artifactId>
+              <version>1.0-alpha-21</version>
+            </dependency>
+            <dependency>
+              <groupId>org.codehaus.modello</groupId>
+              <artifactId>modello-plugin-jpox</artifactId>
+              <version>1.0-alpha-21</version>
+            </dependency>
+          </dependencies>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-assembly-plugin</artifactId>
+          <version>2.2-beta-3</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>2.0.2</version>
+          <configuration>
+            <source>1.5</source>
+            <target>1.5</target>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-remote-resources-plugin</artifactId>
+          <version>1.0-beta-2</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-deploy-plugin</artifactId>
+          <version>2.3</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-gpg-plugin</artifactId>
+          <version>1.0-alpha-4</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-install-plugin</artifactId>
+          <version>2.2</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-jar-plugin</artifactId>
+          <version>2.2</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-release-plugin</artifactId>
+          <version>2.0-beta-7</version>
+          <configuration>
+            <tagBase>https://svn.apache.org/repos/asf/archiva/tags</tagBase>
+            <useReleaseProfile>false</useReleaseProfile>
+            <goals>deploy</goals>
+            <preparationGoals>clean install</preparationGoals>
+            <arguments>-Prelease</arguments>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-resources-plugin</artifactId>
+          <version>2.2</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <version>2.4.2</version>
+          <configuration>
+            <redirectTestOutputToFile>true</redirectTestOutputToFile>
+          </configuration>
+        </plugin>
+        <plugin>
+          <artifactId>maven-idea-plugin</artifactId>
+          <configuration>
+            <jdkLevel>1.5</jdkLevel>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+  <modules>
+    <module>archiva-cli</module>
+    <module>archiva-docs</module>
+    <module>archiva-jetty</module>
+    <module>archiva-modules</module>
+  </modules>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>easymock</groupId>
+      <artifactId>easymock</artifactId>
+      <version>1.2_Java1.3</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>easymock</groupId>
+      <artifactId>easymockclassextension</artifactId>
+      <version>1.2</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>httpunit</groupId>
+        <artifactId>httpunit</artifactId>
+        <version>1.6.2</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.jackrabbit</groupId>
+        <artifactId>jackrabbit-webdav</artifactId>
+        <version>1.5.0</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>xerces</groupId>
+        <artifactId>xercesImpl</artifactId>
+        <version>2.8.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.sonatype.nexus</groupId>
+        <artifactId>nexus-indexer</artifactId>
+        <version>2.0.0</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-container-default</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>classworlds</groupId>
+            <artifactId>classworlds</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>velocity</groupId>
+            <artifactId>velocity-dep</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-registry</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-settings</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>javax.activation</groupId>
+        <artifactId>activation</artifactId>
+        <version>1.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-applet</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-artifact-converter</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-artifact-reports</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-checksum</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-common</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-configuration</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-consumer-api</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-converter</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-dependency-graph</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-core</artifactId>
+        <version>1.2-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-core-consumers</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-database</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-database-consumers</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-indexer</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-lucene-consumers</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-model</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-policies</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-proxy</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-report-manager</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-repository-layer</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-scheduled</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-security</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-signature-consumers</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-transaction</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-docs</artifactId>
+        <version>1.2.1</version>
+        <type>zip</type>
+        <classifier>docs</classifier>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-webapp</artifactId>
+        <version>1.2.1</version>
+        <type>war</type>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-xml-tools</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-webdav</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-rss</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>      
+        <artifactId>archiva-xmlrpc-api</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-xmlrpc-services</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-xmlrpc-security</artifactId>
+        <version>1.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-spring</artifactId>
+        <version>1.2</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-container-default</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>stax</groupId>
+        <artifactId>stax</artifactId>
+        <version>1.2.0</version>
+      </dependency>
+      <dependency>
+        <groupId>commons-codec</groupId>
+        <artifactId>commons-codec</artifactId>
+        <version>1.3</version>
+      </dependency>
+      <dependency>
+        <groupId>commons-collections</groupId>
+        <artifactId>commons-collections</artifactId>
+        <version>3.2</version>
+      </dependency>
+      <dependency>
+        <groupId>commons-fileupload</groupId>
+        <artifactId>commons-fileupload</artifactId>
+        <version>1.2</version>
+      </dependency>
+      <dependency>
+        <groupId>commons-io</groupId>
+        <artifactId>commons-io</artifactId>
+        <version>1.4</version>
+      </dependency>
+      <dependency>
+        <groupId>commons-lang</groupId>
+        <artifactId>commons-lang</artifactId>
+        <version>2.2</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.derby</groupId>
+        <artifactId>derby</artifactId>
+        <version>10.1.3.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.derby</groupId>
+        <artifactId>derbytools</artifactId>
+        <version>10.1.3.1</version>
+      </dependency>
+      <dependency>
+        <groupId>dom4j</groupId>
+        <artifactId>dom4j</artifactId>
+        <version>1.6.1</version>
+      </dependency>
+      <dependency>
+        <groupId>hsqldb</groupId>
+        <artifactId>hsqldb</artifactId>
+        <version>1.8.0.7</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>jaxen</groupId>
+        <artifactId>jaxen</artifactId>
+        <version>1.1</version>
+        <exclusions>
+          <exclusion>
+            <groupId>xom</groupId>
+            <artifactId>xom</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>javax.jdo</groupId>
+        <artifactId>jdo2-api</artifactId>
+        <version>2.0</version>
+      </dependency>
+      <dependency>
+        <groupId>jpox</groupId>
+        <artifactId>jpox</artifactId>
+        <version>1.1.9</version>
+        <exclusions>
+          <exclusion>
+            <groupId>javax.transaction</groupId>
+            <artifactId>jta</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>javax.servlet</groupId>
+        <artifactId>jsp-api</artifactId>
+        <version>2.0</version>
+        <scope>provided</scope>
+      </dependency>
+      <dependency>
+        <groupId>javax.servlet</groupId>
+        <artifactId>jstl</artifactId>
+        <version>1.1.2</version>
+      </dependency>
+      <dependency>
+        <groupId>log4j</groupId>
+        <artifactId>log4j</artifactId>
+        <version>1.2.14</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.lucene</groupId>
+        <artifactId>lucene-core</artifactId>
+        <version>2.4.0</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.lucene</groupId>
+        <artifactId>lucene-queries</artifactId>
+        <version>2.4.0</version>
+      </dependency>
+      <dependency>
+        <groupId>javax.mail</groupId>
+        <artifactId>mail</artifactId>
+        <version>1.4</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.xmlrpc</groupId>
+        <artifactId>xmlrpc-server</artifactId>
+        <version>3.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.maven</groupId>
+        <artifactId>maven-artifact-manager</artifactId>
+        <version>${maven.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-container-default</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.maven</groupId>
+        <artifactId>maven-model</artifactId>
+        <version>${maven.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.maven</groupId>
+        <artifactId>maven-repository-metadata</artifactId>
+        <version>${maven.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-component-api</artifactId>
+        <version>1.0-alpha-22</version>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-digest</artifactId>
+        <version>1.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-expression-evaluator</artifactId>
+        <version>1.0-rc1</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-container-default</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-i18n</artifactId>
+        <version>1.0-beta-6</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-container-default</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-jdo2</artifactId>
+        <version>1.0-alpha-8</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-container-default</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-quartz</artifactId>
+        <version>1.0-alpha-3</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-container-default</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-slf4j-logging</artifactId>
+        <version>1.1-alpha-1</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-container-default</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-taskqueue</artifactId>
+        <version>1.0-alpha-8</version>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-utils</artifactId>
+        <version>1.4.5</version>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus.cache</groupId>
+        <artifactId>plexus-cache-api</artifactId>
+        <version>1.0-alpha-2</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-container-default</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus.cache</groupId>
+        <artifactId>plexus-cache-ehcache</artifactId>
+        <version>1.0-alpha-2</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-container-default</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      
+      <!-- redback -->
+      
+      <dependency>
+        <groupId>org.codehaus.redback</groupId>
+        <artifactId>redback-rbac-memory</artifactId>
+        <version>${redback.version}</version>
+        <scope>test</scope>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.redback</groupId>
+        <artifactId>redback-users-memory</artifactId>
+        <version>${redback.version}</version>
+        <scope>test</scope>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.redback</groupId>
+        <artifactId>redback-keys-memory</artifactId>
+        <version>${redback.version}</version>
+        <scope>test</scope>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.redback</groupId>
+        <artifactId>redback-rbac-model</artifactId>
+        <version>${redback.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.redback</groupId>
+        <artifactId>redback-authorization-rbac</artifactId>
+        <version>${redback.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.redback</groupId>
+        <artifactId>redback-rbac-role-manager</artifactId>
+        <version>${redback.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.redback</groupId>
+        <artifactId>redback-system</artifactId>
+        <version>${redback.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.redback</groupId>
+        <artifactId>redback-common-integrations</artifactId>
+        <version>${redback.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.redback</groupId>
+        <artifactId>redback-struts2-content</artifactId>
+        <version>${redback.version}</version>
+        <type>war</type>
+        <exclusions>
+          <exclusion>
+            <groupId>classworlds</groupId>
+            <artifactId>classworlds</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.redback</groupId>
+        <artifactId>redback-struts2-integration</artifactId>
+        <version>${redback.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>classworlds</groupId>
+            <artifactId>classworlds</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>velocity</groupId>
+            <artifactId>velocity-dep</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>  
+        </exclusions>
+      </dependency>
+      
+      <!-- redback -->
+      
+      <dependency>
+        <groupId>org.codehaus.plexus.registry</groupId>
+        <artifactId>plexus-registry-api</artifactId>
+        <version>1.0-alpha-2</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-container-default</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus.registry</groupId>
+        <artifactId>plexus-registry-commons</artifactId>
+        <version>1.0-alpha-2</version>
+        <exclusions>
+          <exclusion>
+            <groupId>ant</groupId>
+            <artifactId>ant-optional</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>jdom</groupId>
+            <artifactId>jdom</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging-api</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>javax.servlet</groupId>
+        <artifactId>servlet-api</artifactId>
+        <version>2.4</version>
+      </dependency>
+      <dependency>
+        <groupId>opensymphony</groupId>
+        <artifactId>sitemesh</artifactId>
+        <version>2.2.1</version>
+      </dependency>
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>jcl104-over-slf4j</artifactId>
+        <version>1.5.0</version>
+        <scope>runtime</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-api</artifactId>
+        <version>1.5.0</version>
+      </dependency>
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-simple</artifactId>
+        <version>1.5.0</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-log4j12</artifactId>
+        <version>1.5.0</version>
+        <scope>runtime</scope>
+      </dependency>
+      <dependency>
+        <groupId>taglibs</groupId>
+        <artifactId>standard</artifactId>
+        <version>1.1.2</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.maven.wagon</groupId>
+        <artifactId>wagon-file</artifactId>
+        <version>${wagon.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.maven.wagon</groupId>
+        <artifactId>wagon-http-lightweight</artifactId>
+        <version>${wagon.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>nekohtml</groupId>
+            <artifactId>xercesMinimal</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.maven.wagon</groupId>
+        <artifactId>wagon-provider-api</artifactId>
+        <version>${wagon.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.struts</groupId>
+        <artifactId>struts2-core</artifactId>
+        <version>2.0.11.2</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.struts</groupId>
+        <artifactId>struts2-spring-plugin</artifactId>
+        <version>2.0.11.2</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>xmlunit</groupId>
+        <artifactId>xmlunit</artifactId>
+        <version>1.0</version>
+      </dependency>
+      <dependency>
+        <groupId>joda-time</groupId>
+        <artifactId>joda-time</artifactId>
+        <version>1.5.2</version>
+      </dependency>
+      <dependency>
+        <groupId>org.mortbay.jetty</groupId>
+        <artifactId>jetty</artifactId>
+        <version>${jetty.version}</version>
+      </dependency>
+
+      <!-- xmlrpc -->
+      <dependency>
+        <groupId>com.atlassian.xmlrpc</groupId>
+        <artifactId>atlassian-xmlrpc-binder-annotations</artifactId>
+        <version>${binder.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>com.atlassian.xmlrpc</groupId>
+        <artifactId>atlassian-xmlrpc-binder-server-spring</artifactId>
+        <version>${binder.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>com.atlassian.xmlrpc</groupId>
+        <artifactId>atlassian-xmlrpc-binder</artifactId>
+        <version>${binder.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>com.atlassian.xmlrpc</groupId>
+        <artifactId>atlassian-xmlrpc-binder-testing</artifactId>
+        <version>${binder.version}</version>
+        <scope>test</scope>
+      </dependency>
+
+      <!-- Transitive versions to manage -->
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-context</artifactId>
+        <version>${spring.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-web</artifactId>
+        <version>${spring.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-beans</artifactId>
+        <version>${spring.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <!-- use spring test in xmlrpc?
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-test</artifactId>
+        <version>2.5.1</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+       -->
+      <dependency>
+        <groupId>org.apache.maven</groupId>
+        <artifactId>maven-artifact</artifactId>
+        <version>${maven.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.maven</groupId>
+        <artifactId>maven-project</artifactId>
+        <version>${maven.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-container-default</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>jdom</groupId>
+        <artifactId>jdom</artifactId>
+        <version>1.0</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.maven.shared</groupId>
+        <artifactId>maven-model-converter</artifactId>
+        <version>2.1</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-container-default</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      <dependency>
+        <groupId>net.sf.ehcache</groupId>
+        <artifactId>ehcache</artifactId>
+        <version>1.3.0</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+  <properties>
+    <maven.version>2.0.8</maven.version>
+    <wagon.version>1.0-beta-5</wagon.version>
+    <redback.version>1.2.1</redback.version>
+    <jetty.version>6.1.6</jetty.version>
+    <binder.version>0.9</binder.version>
+    <spring.version>2.5.6</spring.version>
+  </properties>
+  <profiles>
+    <profile>
+      <id>release</id>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-assembly-plugin</artifactId>
+            <inherited>false</inherited>
+            <configuration>
+              <descriptors>
+                <descriptor>src/main/assembly/src.xml</descriptor>
+              </descriptors>
+              <tarLongFileMode>gnu</tarLongFileMode>
+              <finalName>apache-archiva-${project.version}-src</finalName>
+            </configuration>
+            <executions>
+              <execution>
+                <id>make-assembly</id>
+                <phase>package</phase>
+                <goals>
+                  <goal>single</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+          <!-- We want to sign the artifact, the POM, and all attached artifacts -->
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-gpg-plugin</artifactId>
+            <configuration>
+              <passphrase>${gpg.passphrase}</passphrase>
+            </configuration>
+            <executions>
+              <execution>
+                <goals>
+                  <goal>sign</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+          <!-- We want to deploy the artifact to a staging location for perusal -->
+          <plugin>
+            <inherited>true</inherited>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-deploy-plugin</artifactId>
+            <configuration>
+              <altDeploymentRepository>${deploy.altRepository}</altDeploymentRepository>
+              <updateReleaseInfo>true</updateReleaseInfo>
+            </configuration>
+          </plugin>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-source-plugin</artifactId>
+            <version>2.0.4</version>
+            <executions>
+              <execution>
+                <id>attach-sources</id>
+                <goals>
+                  <goal>jar</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-javadoc-plugin</artifactId>
+            <version>2.4</version>
+            <executions>
+              <execution>
+                <id>attach-javadocs</id>
+                <goals>
+                  <goal>jar</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+  <repositories>
+    <repository>
+      <releases>
+        <enabled>true</enabled>
+      </releases>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+      <id>sonatype.public</id>
+      <name>Sonatype Public Repo</name>
+      <url>http://repository.sonatype.org/content/repositories/sonatype-apache-releases</url>
+    </repository> 
+    <repository>
+      <releases>
+        <enabled>false</enabled>
+      </releases>
+      <snapshots>
+        <enabled>true</enabled>
+      </snapshots>
+      <id>codehaus.org.snapshots</id>
+      <name>Codehaus Snapshots Repository</name>
+      <url>http://snapshots.repository.codehaus.org</url>
+    </repository> 
+  </repositories>
+</project>
diff --git a/archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/1.2.1/maven-metadata.xml b/archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/1.2.1/maven-metadata.xml
new file mode 100755 (executable)
index 0000000..574abc2
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<metadata>
+  <groupId>org.apache.archiva</groupId>
+  <artifactId>archiva</artifactId>
+  <version>1.2.1</version>
+  <versioning>
+    <lastUpdated>20100702064543</lastUpdated>
+  </versioning>
+</metadata>
diff --git a/archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/maven-metadata.xml b/archiva-modules/plugins/stage-repository-merge/src/test/resources/target-repo/org/apache/archiva/archiva/maven-metadata.xml
new file mode 100755 (executable)
index 0000000..96384b6
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<metadata>
+  <groupId>org.apache.archiva</groupId>
+  <artifactId>archiva</artifactId>
+  <versioning>
+    <latest>1.2.1</latest>
+    <release>1.2.1</release>
+    <versions>
+      <version>1.2.1</version>
+    </versions>
+    <lastUpdated>20100702064543</lastUpdated>
+  </versioning>
+</metadata>