summaryrefslogtreecommitdiffstats
path: root/archiva-base
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2008-03-20 12:56:34 +0000
committerBrett Porter <brett@apache.org>2008-03-20 12:56:34 +0000
commite4a54528f3558b895d1614ed68fccc85035eaa55 (patch)
treeef93308133a17508e5e4198f16de3440bdc5d602 /archiva-base
parent5c5b37176537f8a26279af3c1c971bff7627c0b7 (diff)
downloadarchiva-e4a54528f3558b895d1614ed68fccc85035eaa55.tar.gz
archiva-e4a54528f3558b895d1614ed68fccc85035eaa55.zip
[MNG-734] fix plugin-level metadata handling
Merged from: r639260 git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@639273 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-base')
-rw-r--r--archiva-base/archiva-model/src/main/mdo/archiva-base.xml53
-rw-r--r--archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MetadataTransferTest.java267
-rw-r--r--archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-not-on-remotes/maven-metadata.xml29
-rw-r--r--archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-on-local-on-remote/maven-metadata.xml34
-rw-r--r--archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-on-multiple-repos/maven-metadata.xml29
-rw-r--r--archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-project-metadata/maven-metadata.xml29
-rw-r--r--archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-default-layout/maven-metadata.xml29
-rw-r--r--archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-found-in-proxy/maven-metadata.xml29
-rw-r--r--archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-on-local-on-remote/maven-metadata.xml34
-rw-r--r--archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-on-multiple-repos/maven-metadata.xml34
-rw-r--r--archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/groups/get-default-layout/maven-metadata.xml29
-rw-r--r--archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/groups/get-on-multiple-repos/maven-metadata.xml34
-rw-r--r--archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/MetadataTools.java90
-rw-r--r--archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataReader.java10
-rw-r--r--archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataWriter.java16
-rw-r--r--archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/metadata/MetadataToolsTest.java30
16 files changed, 716 insertions, 60 deletions
diff --git a/archiva-base/archiva-model/src/main/mdo/archiva-base.xml b/archiva-base/archiva-model/src/main/mdo/archiva-base.xml
index 663cc4f71..e4286f737 100644
--- a/archiva-base/archiva-model/src/main/mdo/archiva-base.xml
+++ b/archiva-base/archiva-model/src/main/mdo/archiva-base.xml
@@ -641,6 +641,20 @@
</association>
</field>
<field>
+ <name>plugins</name>
+ <identifier>false</identifier>
+ <version>1.0.0+</version>
+ <required>false</required>
+ <description>
+ The available plugins.
+ </description>
+ <association stash.part="true"
+ jpox.join="false">
+ <type>Plugin</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ </field>
+ <field>
<name>availableVersions</name>
<identifier>false</identifier>
<version>1.0.0+</version>
@@ -766,6 +780,45 @@
</codeSegments>
</class>
+ <class stash.storable="true"
+ jpox.not-persisted-fields="modelEncoding"
+ jpox.table="REPOSITORY_METADATA_PLUGINS">
+ <name>Plugin</name>
+ <description>The Plugin</description>
+ <version>1.0.0+</version>
+ <fields>
+ <field stash.maxSize="20"
+ jpox.column="PLUGIN_PREFIX">
+ <name>prefix</name>
+ <type>String</type>
+ <identifier>false</identifier>
+ <required>true</required>
+ <description>
+ The prefix for a plugin
+ </description>
+ </field>
+ <field
+ jpox.column="PLUGIN_ARTIFACT_ID">
+ <name>artifactId</name>
+ <type>String</type>
+ <identifier>true</identifier>
+ <required>true</required>
+ <description>
+ The artifactId for a plugin
+ </description>
+ </field>
+ <field jpox.column="PLUGIN_NAME">
+ <name>name</name>
+ <type>String</type>
+ <identifier>false</identifier>
+ <required>true</required>
+ <description>
+ The name for a plugin
+ </description>
+ </field>
+ </fields>
+ </class>
+
<!-- _______________________________________________________________
____ __
diff --git a/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MetadataTransferTest.java b/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MetadataTransferTest.java
index d46d4e9fd..2496e3b68 100644
--- a/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MetadataTransferTest.java
+++ b/archiva-base/archiva-proxy/src/test/java/org/apache/maven/archiva/proxy/MetadataTransferTest.java
@@ -22,6 +22,7 @@ package org.apache.maven.archiva.proxy;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.common.utils.VersionUtil;
import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
+import org.apache.maven.archiva.model.Plugin;
import org.apache.maven.archiva.model.ProjectReference;
import org.apache.maven.archiva.model.SnapshotVersion;
import org.apache.maven.archiva.model.VersionedReference;
@@ -123,7 +124,7 @@ public class MetadataTransferTest
wagonMockControl.replay();
- assertFetchProject( requestedResource );
+ assertFetchProjectOrGroup( requestedResource );
wagonMockControl.verify();
@@ -148,7 +149,7 @@ public class MetadataTransferTest
assertResourceNotFound( requestedResource );
// No proxy setup, nothing fetched, failure expected.
- assertFetchProjectFailed( requestedResource );
+ assertFetchProjectOrGroupFailed( requestedResource );
// No local artifactId, and no fetch, should equal no metadata file downloaded / created / updated.
assertResourceNotFound( requestedResource );
@@ -164,7 +165,7 @@ public class MetadataTransferTest
assertResourceExists( requestedResource );
// No proxy setup, nothing fetched from remote, but local exists.
- assertFetchProject( requestedResource );
+ assertFetchProjectOrGroup( requestedResource );
// Nothing fetched. Should only contain contents of what is in the repository.
// A metadata update is not performed in this use case. Local metadata content is only
@@ -190,7 +191,7 @@ public class MetadataTransferTest
assertNoRepoMetadata( ID_PROXIED2, requestedResource );
// Two proxies setup, metadata fetched from both remotes.
- assertFetchProject( requestedResource );
+ assertFetchProjectOrGroup( requestedResource );
// Nothing fetched. Should only contain contents of what is in the repository.
assertProjectMetadataContents( requestedResource, new String[] { "1.0", "1.0.1" }, "1.0.1", "1.0.1" );
@@ -216,7 +217,7 @@ public class MetadataTransferTest
assertNoRepoMetadata( ID_PROXIED2, requestedResource );
// Two proxies setup, nothing fetched from remotes, local does not exist.
- assertFetchProjectFailed( requestedResource );
+ assertFetchProjectOrGroupFailed( requestedResource );
// Nothing fetched. Nothing should exist.
assertResourceNotFound( requestedResource );
@@ -239,7 +240,7 @@ public class MetadataTransferTest
assertNoRepoMetadata( ID_PROXIED1, requestedResource );
// One proxy setup, metadata fetched from remote, local does not exist.
- assertFetchProject( requestedResource );
+ assertFetchProjectOrGroup( requestedResource );
// Remote fetched. Local created/updated.
assertProjectMetadataContents( requestedResource, new String[] { "1.0.5" }, "1.0.5", "1.0.5" );
@@ -264,7 +265,7 @@ public class MetadataTransferTest
assertNoRepoMetadata( ID_PROXIED2, requestedResource );
// Two proxies setup, metadata fetched from both remotes.
- assertFetchProject( requestedResource );
+ assertFetchProjectOrGroup( requestedResource );
// metadata fetched from both repos, and merged with local version.
assertProjectMetadataContents( requestedResource, new String[] { "1.0", "1.0.1", "2.0" }, "2.0", "2.0" );
@@ -290,7 +291,7 @@ public class MetadataTransferTest
assertNoRepoMetadata( ID_PROXIED2, requestedResource );
// Two proxies setup, metadata fetch from remotes fail (because they dont exist).
- assertFetchProject( requestedResource );
+ assertFetchProjectOrGroup( requestedResource );
// metadata not fetched from both repos, and local version exists.
// Since there was no updated metadata content from a remote/proxy, a metadata update on
@@ -315,7 +316,7 @@ public class MetadataTransferTest
assertNoRepoMetadata( ID_PROXIED1, requestedResource );
// One proxy setup, metadata fetched from remote, local exists.
- assertFetchProject( requestedResource );
+ assertFetchProjectOrGroup( requestedResource );
// Remote fetched. Local updated.
assertProjectMetadataContents( requestedResource, new String[] { "1.0.8", "1.0.22", "2.0" }, "2.0", "2.0" );
@@ -416,7 +417,7 @@ public class MetadataTransferTest
assertResourceNotFound( requestedResource );
- assertFetchProjectFailed( requestedResource );
+ assertFetchProjectOrGroupFailed( requestedResource );
assertResourceNotFound( requestedResource );
assertNoRepoMetadata( ID_PROXIED1, requestedResource );
@@ -704,13 +705,197 @@ public class MetadataTransferTest
assertRepoSnapshotMetadataContents( ID_PROXIED1, requestedResource, "20050831", "101112", 1 );
}
+ public void testGetGroupMetadataNotProxiedNotLocal()
+ throws Exception
+ {
+ // The artifactId "get-default-metadata-nonexistant" does not exist (intentionally).
+ String requestedResource = "org/apache/maven/test/groups/get-default-metadata-nonexistant/maven-metadata.xml";
+ setupTestableManagedRepository( requestedResource );
+
+ assertResourceNotFound( requestedResource );
+
+ // No proxy setup, nothing fetched, failure expected.
+ assertFetchProjectOrGroupFailed( requestedResource );
+
+ // No local artifactId, and no fetch, should equal no metadata file downloaded / created / updated.
+ assertResourceNotFound( requestedResource );
+ }
+
+ public void testGetGroupMetadataNotProxiedOnLocal()
+ throws Exception
+ {
+ // Project metadata that exists and has multiple versions
+ String requestedResource = "org/apache/maven/test/groups/get-project-metadata/maven-metadata.xml";
+ setupTestableManagedRepository( requestedResource );
+
+ assertResourceExists( requestedResource );
+
+ // No proxy setup, nothing fetched from remote, but local exists.
+ assertFetchProjectOrGroup( requestedResource );
+
+ // Nothing fetched. Should only contain contents of what is in the repository.
+ // A metadata update is not performed in this use case. Local metadata content is only
+ // updated via the metadata updater consumer.
+ assertGroupMetadataContents( requestedResource, new String[] { "plugin1" } );
+ }
+
+ public void testGetGroupMetadataProxiedNotLocalMultipleRemotes()
+ throws Exception
+ {
+ // Project metadata that does not exist locally, but has multiple versions in remote repos
+ String requestedResource = "org/apache/maven/test/groups/get-default-layout/maven-metadata.xml";
+ setupTestableManagedRepository( requestedResource );
+
+ // Configure Connector (usually done within archiva.xml configuration)
+ saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
+ saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
+
+ assertResourceNotFound( requestedResource );
+ assertNoRepoMetadata( ID_PROXIED1, requestedResource );
+ assertNoRepoMetadata( ID_PROXIED2, requestedResource );
+
+ // Two proxies setup, metadata fetched from both remotes.
+ assertFetchProjectOrGroup( requestedResource );
+
+ // Nothing fetched. Should only contain contents of what is in the repository.
+ assertGroupMetadataContents( requestedResource, new String[] { "plugin2", "plugin1" } );
+ assertRepoGroupMetadataContents( ID_PROXIED1, requestedResource, new String[] { "plugin1" } );
+ assertRepoGroupMetadataContents( ID_PROXIED2, requestedResource, new String[] { "plugin2" } );
+ }
+
+ public void testGetGroupsMetadataProxiedNotLocalNotRemote()
+ throws Exception
+ {
+ // Non-existant project metadata that does not exist locally and doesn't exist on remotes.
+ String requestedResource = "org/apache/maven/test/groups/get-bogus-artifact/maven-metadata.xml";
+ setupTestableManagedRepository( requestedResource );
+
+ // Configure Connector (usually done within archiva.xml configuration)
+ saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
+ saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
+
+ assertResourceNotFound( requestedResource );
+ assertNoRepoMetadata( ID_PROXIED1, requestedResource );
+ assertNoRepoMetadata( ID_PROXIED2, requestedResource );
+
+ // Two proxies setup, nothing fetched from remotes, local does not exist.
+ assertFetchProjectOrGroupFailed( requestedResource );
+
+ // Nothing fetched. Nothing should exist.
+ assertResourceNotFound( requestedResource );
+ assertNoRepoMetadata( ID_PROXIED1, requestedResource );
+ assertNoRepoMetadata( ID_PROXIED2, requestedResource );
+ }
+
+ public void testGetGroupMetadataProxiedNotLocalOnRemote()
+ throws Exception
+ {
+ // New project metadata that does not exist locally but exists on remote.
+ String requestedResource = "org/apache/maven/test/groups/get-found-in-proxy/maven-metadata.xml";
+ setupTestableManagedRepository( requestedResource );
+
+ // Configure Connector (usually done within archiva.xml configuration)
+ saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
+
+ assertResourceNotFound( requestedResource );
+ assertNoRepoMetadata( ID_PROXIED1, requestedResource );
+
+ // One proxy setup, metadata fetched from remote, local does not exist.
+ assertFetchProjectOrGroup( requestedResource );
+
+ // Remote fetched. Local created/updated.
+ assertGroupMetadataContents( requestedResource, new String[] { "plugin3" } );
+ assertRepoGroupMetadataContents( ID_PROXIED1, requestedResource, new String[] { "plugin3" } );
+ }
+
+ public void testGetGroupMetadataProxiedOnLocalMultipleRemote()
+ throws Exception
+ {
+ // Project metadata that exist locally, and has multiple versions in remote repos
+ String requestedResource = "org/apache/maven/test/groups/get-on-multiple-repos/maven-metadata.xml";
+ setupTestableManagedRepository( requestedResource );
+
+ // Configure Connector (usually done within archiva.xml configuration)
+ saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
+ saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
+
+ assertGroupMetadataContents( requestedResource, new String[] { "plugin1" } );
+ assertNoRepoMetadata( ID_PROXIED1, requestedResource );
+ assertNoRepoMetadata( ID_PROXIED2, requestedResource );
+
+ // Two proxies setup, metadata fetched from both remotes.
+ assertFetchProjectOrGroup( requestedResource );
+
+ // metadata fetched from both repos, and merged with local version.
+ assertGroupMetadataContents( requestedResource, new String[] { "plugin1", "plugin2", "plugin4" } );
+ assertRepoGroupMetadataContents( ID_PROXIED1, requestedResource, new String[] { "plugin1", "plugin4" } );
+ assertRepoGroupMetadataContents( ID_PROXIED2, requestedResource, new String[] { "plugin1", "plugin2" } );
+ }
+
+ public void testGetGroupMetadataProxiedOnLocalNotRemote()
+ throws Exception
+ {
+ // Project metadata that exist locally, and does not exist in remote repos.
+ String requestedResource = "org/apache/maven/test/groups/get-not-on-remotes/maven-metadata.xml";
+ setupTestableManagedRepository( requestedResource );
+
+ // Configure Connector (usually done within archiva.xml configuration)
+ saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
+ saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED2, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
+
+ assertGroupMetadataContents( requestedResource, new String[] { "plugin5" } );
+ assertNoRepoMetadata( ID_PROXIED1, requestedResource );
+ assertNoRepoMetadata( ID_PROXIED2, requestedResource );
+
+ // Two proxies setup, metadata fetch from remotes fail (because they dont exist).
+ assertFetchProjectOrGroup( requestedResource );
+
+ // metadata not fetched from both repos, and local version exists.
+ // Since there was no updated metadata content from a remote/proxy, a metadata update on
+ // the local file never ran. Local only updates are performed via the metadata updater consumer.
+ assertGroupMetadataContents( requestedResource, new String[] { "plugin5" } );
+ assertNoRepoMetadata( ID_PROXIED1, requestedResource );
+ assertNoRepoMetadata( ID_PROXIED2, requestedResource );
+ }
+
+ public void testGetGroupMetadataProxiedOnLocalOnRemote()
+ throws Exception
+ {
+ // Project metadata that exist locally and exists on remote.
+ String requestedResource = "org/apache/maven/test/groups/get-on-local-on-remote/maven-metadata.xml";
+ setupTestableManagedRepository( requestedResource );
+
+ // Configure Connector (usually done within archiva.xml configuration)
+ saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS,
+ SnapshotsPolicy.ALWAYS, CachedFailuresPolicy.NO );
+
+ assertGroupMetadataContents( requestedResource, new String[] { "plugin6", "plugin7" } );
+ assertNoRepoMetadata( ID_PROXIED1, requestedResource );
+
+ // One proxy setup, metadata fetched from remote, local exists.
+ assertFetchProjectOrGroup( requestedResource );
+
+ // Remote fetched. Local updated.
+ assertGroupMetadataContents( requestedResource, new String[] { "plugin6", "plugin7", "plugin4" } );
+ assertRepoGroupMetadataContents( ID_PROXIED1, requestedResource, new String[] { "plugin7", "plugin4" } );
+ }
+
/**
* Transfer the metadata file.
*
* @param requestedResource the requested resource
* @throws Exception
*/
- private void assertFetchProject( String requestedResource )
+ private void assertFetchProjectOrGroup( String requestedResource )
throws Exception
{
File expectedFile = new File( managedDefaultDir, requestedResource );
@@ -735,7 +920,7 @@ public class MetadataTransferTest
* @param requestedResource the requested resource
* @throws Exception
*/
- private void assertFetchProjectFailed( String requestedResource )
+ private void assertFetchProjectOrGroupFailed( String requestedResource )
throws Exception
{
File expectedFile = new File( managedDefaultDir, requestedResource );
@@ -850,6 +1035,64 @@ public class MetadataTransferTest
assertFalse( "Repo specific metadata should not exist: " + actualFile, actualFile.exists() );
}
+ private void assertGroupMetadataContents( String requestedResource, String expectedPlugins[] )
+ throws Exception
+ {
+ File actualFile = new File( managedDefaultDir, requestedResource );
+ assertTrue( "Snapshot Metadata should exist: " + requestedResource, actualFile.exists() );
+
+ ProjectReference actualMetadata = createGroupReference( requestedResource );
+
+ assertGroupMetadata( actualFile, actualMetadata, expectedPlugins );
+ }
+
+ private ProjectReference createGroupReference( String requestedResource )
+ throws RepositoryMetadataException
+ {
+ ProjectReference projectReference = createProjectReference( requestedResource );
+ projectReference.setGroupId( projectReference.getGroupId() + "." + projectReference.getArtifactId() );
+ projectReference.setArtifactId( null );
+ return projectReference;
+ }
+
+ private void assertRepoGroupMetadataContents( String proxiedRepoId, String requestedResource,
+ String expectedPlugins[] )
+ throws Exception
+ {
+ String proxiedFile = metadataTools.getRepositorySpecificName( proxiedRepoId, requestedResource );
+
+ File actualFile = new File( managedDefaultDir, proxiedFile );
+ assertTrue( "Repo Specific Group Metadata should exist: " + requestedResource, actualFile.exists() );
+
+ ProjectReference actualMetadata = createGroupReference( requestedResource );
+
+ assertGroupMetadata( actualFile, actualMetadata, expectedPlugins );
+ }
+
+ private void assertGroupMetadata( File actualFile, ProjectReference actualMetadata, String expectedPlugins[] )
+ throws Exception
+ {
+ // Build expected metadata XML
+ StringWriter expectedMetadataXml = new StringWriter();
+ ArchivaRepositoryMetadata m = new ArchivaRepositoryMetadata();
+ m.setGroupId( actualMetadata.getGroupId() );
+
+ for ( String pluginId : expectedPlugins )
+ {
+ Plugin p = new Plugin();
+ p.setPrefix( pluginId );
+ p.setArtifactId( pluginId + "-maven-plugin" );
+ p.setName( "The " + pluginId + " Plugin" );
+ m.getPlugins().add( p );
+ }
+
+ m.setModelEncoding( null );
+ RepositoryMetadataWriter.write( m, expectedMetadataXml );
+
+ // Compare the file to the actual contents.
+ assertMetadataEquals( expectedMetadataXml.toString(), actualFile );
+ }
+
/**
* Test for the existance of the requestedResource in the default managed repository, and if it exists,
* does it contain the specified list of expected versions?
diff --git a/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-not-on-remotes/maven-metadata.xml b/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-not-on-remotes/maven-metadata.xml
new file mode 100644
index 000000000..6053adcf4
--- /dev/null
+++ b/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-not-on-remotes/maven-metadata.xml
@@ -0,0 +1,29 @@
+<!--
+ ~ 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.
+ -->
+
+<metadata>
+ <groupId>org.apache.maven.test.groups.get-not-on-remotes</groupId>
+ <plugins>
+ <plugin>
+ <prefix>plugin5</prefix>
+ <artifactId>plugin5-maven-plugin</artifactId>
+ <name>The plugin5 Plugin</name>
+ </plugin>
+ </plugins>
+</metadata>
diff --git a/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-on-local-on-remote/maven-metadata.xml b/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-on-local-on-remote/maven-metadata.xml
new file mode 100644
index 000000000..14196bdc1
--- /dev/null
+++ b/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-on-local-on-remote/maven-metadata.xml
@@ -0,0 +1,34 @@
+<!--
+ ~ 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.
+ -->
+
+<metadata>
+ <groupId>org.apache.maven.test.groups.get-on-local-on-remote</groupId>
+ <plugins>
+ <plugin>
+ <prefix>plugin6</prefix>
+ <artifactId>plugin6-maven-plugin</artifactId>
+ <name>The plugin6 Plugin</name>
+ </plugin>
+ <plugin>
+ <prefix>plugin7</prefix>
+ <artifactId>plugin7-maven-plugin</artifactId>
+ <name>The plugin7 Plugin</name>
+ </plugin>
+ </plugins>
+</metadata>
diff --git a/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-on-multiple-repos/maven-metadata.xml b/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-on-multiple-repos/maven-metadata.xml
new file mode 100644
index 000000000..a04428913
--- /dev/null
+++ b/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-on-multiple-repos/maven-metadata.xml
@@ -0,0 +1,29 @@
+<!--
+ ~ 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.
+ -->
+
+<metadata>
+ <groupId>org.apache.maven.test.groups.get-on-multiple-repos</groupId>
+ <plugins>
+ <plugin>
+ <prefix>plugin1</prefix>
+ <artifactId>plugin1-maven-plugin</artifactId>
+ <name>The plugin1 Plugin</name>
+ </plugin>
+ </plugins>
+</metadata>
diff --git a/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-project-metadata/maven-metadata.xml b/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-project-metadata/maven-metadata.xml
new file mode 100644
index 000000000..e0829c112
--- /dev/null
+++ b/archiva-base/archiva-proxy/src/test/repositories/managed/org/apache/maven/test/groups/get-project-metadata/maven-metadata.xml
@@ -0,0 +1,29 @@
+<!--
+ ~ 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.
+ -->
+
+<metadata>
+ <groupId>org.apache.maven.test.groups.get-project-metadata</groupId>
+ <plugins>
+ <plugin>
+ <prefix>plugin1</prefix>
+ <artifactId>plugin1-maven-plugin</artifactId>
+ <name>The plugin1 Plugin</name>
+ </plugin>
+ </plugins>
+</metadata>
diff --git a/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-default-layout/maven-metadata.xml b/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-default-layout/maven-metadata.xml
new file mode 100644
index 000000000..9f6bf9239
--- /dev/null
+++ b/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-default-layout/maven-metadata.xml
@@ -0,0 +1,29 @@
+<!--
+ ~ 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.
+ -->
+
+<metadata>
+ <groupId>org.apache.maven.test.groups.get-default-layout</groupId>
+ <plugins>
+ <plugin>
+ <prefix>plugin1</prefix>
+ <artifactId>plugin1-maven-plugin</artifactId>
+ <name>The plugin1 Plugin</name>
+ </plugin>
+ </plugins>
+</metadata>
diff --git a/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-found-in-proxy/maven-metadata.xml b/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-found-in-proxy/maven-metadata.xml
new file mode 100644
index 000000000..90102867a
--- /dev/null
+++ b/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-found-in-proxy/maven-metadata.xml
@@ -0,0 +1,29 @@
+<!--
+ ~ 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.
+ -->
+
+<metadata>
+ <groupId>org.apache.maven.test.groups.get-found-in-proxy</groupId>
+ <plugins>
+ <plugin>
+ <prefix>plugin3</prefix>
+ <artifactId>plugin3-maven-plugin</artifactId>
+ <name>The plugin3 Plugin</name>
+ </plugin>
+ </plugins>
+</metadata>
diff --git a/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-on-local-on-remote/maven-metadata.xml b/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-on-local-on-remote/maven-metadata.xml
new file mode 100644
index 000000000..23f12bbf1
--- /dev/null
+++ b/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-on-local-on-remote/maven-metadata.xml
@@ -0,0 +1,34 @@
+<!--
+ ~ 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.
+ -->
+
+<metadata>
+ <groupId>org.apache.maven.test.groups.get-on-local-on-remote</groupId>
+ <plugins>
+ <plugin>
+ <prefix>plugin7</prefix>
+ <artifactId>plugin7-maven-plugin</artifactId>
+ <name>The plugin7 Plugin</name>
+ </plugin>
+ <plugin>
+ <prefix>plugin4</prefix>
+ <artifactId>plugin4-maven-plugin</artifactId>
+ <name>The plugin4 Plugin</name>
+ </plugin>
+ </plugins>
+</metadata>
diff --git a/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-on-multiple-repos/maven-metadata.xml b/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-on-multiple-repos/maven-metadata.xml
new file mode 100644
index 000000000..3abe069e7
--- /dev/null
+++ b/archiva-base/archiva-proxy/src/test/repositories/proxied1/org/apache/maven/test/groups/get-on-multiple-repos/maven-metadata.xml
@@ -0,0 +1,34 @@
+<!--
+ ~ 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.
+ -->
+
+<metadata>
+ <groupId>org.apache.maven.test.groups.get-on-multiple-repos</groupId>
+ <plugins>
+ <plugin>
+ <prefix>plugin1</prefix>
+ <artifactId>plugin1-maven-plugin</artifactId>
+ <name>The plugin1 Plugin</name>
+ </plugin>
+ <plugin>
+ <prefix>plugin4</prefix>
+ <artifactId>plugin4-maven-plugin</artifactId>
+ <name>The plugin4 Plugin</name>
+ </plugin>
+ </plugins>
+</metadata>
diff --git a/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/groups/get-default-layout/maven-metadata.xml b/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/groups/get-default-layout/maven-metadata.xml
new file mode 100644
index 000000000..41109859e
--- /dev/null
+++ b/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/groups/get-default-layout/maven-metadata.xml
@@ -0,0 +1,29 @@
+<!--
+ ~ 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.
+ -->
+
+<metadata>
+ <groupId>org.apache.maven.test.groups.get-default-layout</groupId>
+ <plugins>
+ <plugin>
+ <prefix>plugin2</prefix>
+ <artifactId>plugin2-maven-plugin</artifactId>
+ <name>The plugin2 Plugin</name>
+ </plugin>
+ </plugins>
+</metadata>
diff --git a/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/groups/get-on-multiple-repos/maven-metadata.xml b/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/groups/get-on-multiple-repos/maven-metadata.xml
new file mode 100644
index 000000000..b7db006fe
--- /dev/null
+++ b/archiva-base/archiva-proxy/src/test/repositories/proxied2/org/apache/maven/test/groups/get-on-multiple-repos/maven-metadata.xml
@@ -0,0 +1,34 @@
+<!--
+ ~ 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.
+ -->
+
+<metadata>
+ <groupId>org.apache.maven.test.groups.get-on-multiple-repos</groupId>
+ <plugins>
+ <plugin>
+ <prefix>plugin1</prefix>
+ <artifactId>plugin1-maven-plugin</artifactId>
+ <name>The plugin1 Plugin</name>
+ </plugin>
+ <plugin>
+ <prefix>plugin2</prefix>
+ <artifactId>plugin2-maven-plugin</artifactId>
+ <name>The plugin2 Plugin</name>
+ </plugin>
+ </plugins>
+</metadata>
diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/MetadataTools.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/MetadataTools.java
index 960f3d798..35af14277 100644
--- a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/MetadataTools.java
+++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/MetadataTools.java
@@ -30,6 +30,7 @@ import org.apache.maven.archiva.configuration.FileTypes;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
import org.apache.maven.archiva.model.ArtifactReference;
+import org.apache.maven.archiva.model.Plugin;
import org.apache.maven.archiva.model.ProjectReference;
import org.apache.maven.archiva.model.SnapshotVersion;
import org.apache.maven.archiva.model.VersionedReference;
@@ -56,6 +57,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -394,14 +396,16 @@ public class MetadataTools
}
/**
- * Update the metadata to represent the all versions of
- * the provided groupId:artifactId project reference,
+ * Update the metadata to represent the all versions/plugins of
+ * the provided groupId:artifactId project or group reference,
* based off of information present in the repository,
* the maven-metadata.xml files, and the proxy/repository specific
* metadata file contents.
*
+ * We must treat this as a group or a project metadata file as there is no way to know in advance
+ *
* @param managedRepository the managed repository where the metadata is kept.
- * @param reference the versioned referencfe to update.
+ * @param reference the reference to update.
* @throws LayoutException
* @throws RepositoryMetadataException
* @throws IOException
@@ -421,6 +425,19 @@ public class MetadataTools
// Gather up all versions found in the managed repository.
Set<String> allVersions = managedRepository.getVersions( reference );
+ // Gather up all plugins found in the managed repository.
+ // TODO: do we know this information instead?
+// Set<Plugin> allPlugins = managedRepository.getPlugins( reference );
+ Set<Plugin> allPlugins;
+ if ( metadataFile.exists() )
+ {
+ allPlugins = new LinkedHashSet<Plugin>( RepositoryMetadataReader.read( metadataFile ).getPlugins() );
+ }
+ else
+ {
+ allPlugins = new LinkedHashSet<Plugin>();
+ }
+
// Does this repository have a set of remote proxied repositories?
Set<String> proxiedRepoIds = this.proxies.get( managedRepository.getId() );
@@ -436,6 +453,7 @@ public class MetadataTools
if ( proxyMetadata != null )
{
allVersions.addAll( proxyMetadata.getAvailableVersions() );
+ allPlugins.addAll( proxyMetadata.getPlugins() );
long proxyLastUpdated = getLastUpdated( proxyMetadata );
lastUpdated = Math.max( lastUpdated, proxyLastUpdated );
@@ -443,47 +461,55 @@ public class MetadataTools
}
}
- if ( allVersions.size() == 0 )
+ if ( !allVersions.isEmpty() )
{
- throw new IOException( "No versions found for reference." );
- }
-
- // Sort the versions
- List<String> sortedVersions = new ArrayList<String>( allVersions );
- Collections.sort( sortedVersions, VersionComparator.getInstance() );
+ // Sort the versions
+ List<String> sortedVersions = new ArrayList<String>( allVersions );
+ Collections.sort( sortedVersions, VersionComparator.getInstance() );
- // Split the versions into released and snapshots.
- List<String> releasedVersions = new ArrayList<String>();
- List<String> snapshotVersions = new ArrayList<String>();
+ // Split the versions into released and snapshots.
+ List<String> releasedVersions = new ArrayList<String>();
+ List<String> snapshotVersions = new ArrayList<String>();
- for ( String version : sortedVersions )
- {
- if ( VersionUtil.isSnapshot( version ) )
+ for ( String version : sortedVersions )
{
- snapshotVersions.add( version );
+ if ( VersionUtil.isSnapshot( version ) )
+ {
+ snapshotVersions.add( version );
+ }
+ else
+ {
+ releasedVersions.add( version );
+ }
}
- else
+
+ Collections.sort( releasedVersions, VersionComparator.getInstance() );
+ Collections.sort( snapshotVersions, VersionComparator.getInstance() );
+
+ String latestVersion = sortedVersions.get( sortedVersions.size() - 1 );
+ String releaseVersion = null;
+
+ if ( CollectionUtils.isNotEmpty( releasedVersions ) )
{
- releasedVersions.add( version );
+ releaseVersion = releasedVersions.get( releasedVersions.size() - 1 );
}
- }
-
- Collections.sort( releasedVersions, VersionComparator.getInstance() );
- Collections.sort( snapshotVersions, VersionComparator.getInstance() );
- String latestVersion = sortedVersions.get( sortedVersions.size() - 1 );
- String releaseVersion = null;
+ // Add the versions to the metadata model.
+ metadata.setAvailableVersions( sortedVersions );
- if ( CollectionUtils.isNotEmpty( releasedVersions ) )
- {
- releaseVersion = releasedVersions.get( releasedVersions.size() - 1 );
+ metadata.setLatestVersion( latestVersion );
+ metadata.setReleasedVersion( releaseVersion );
}
+ else
+ {
+ // Add the plugins to the metadata model.
+ metadata.setPlugins( new ArrayList<Plugin>( allPlugins ) );
- // Add the versions to the metadata model.
- metadata.setAvailableVersions( sortedVersions );
+ // artifact ID was actually the last part of the group
+ metadata.setGroupId( metadata.getGroupId() + "." + metadata.getArtifactId() );
+ metadata.setArtifactId( null );
+ }
- metadata.setLatestVersion( latestVersion );
- metadata.setReleasedVersion( releaseVersion );
if ( lastUpdated > 0 )
{
metadata.setLastUpdatedTimestamp( toLastUpdatedDate( lastUpdated ) );
diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataReader.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataReader.java
index 5d24df835..1e18caf86 100644
--- a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataReader.java
+++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataReader.java
@@ -21,6 +21,7 @@ package org.apache.maven.archiva.repository.metadata;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
+import org.apache.maven.archiva.model.Plugin;
import org.apache.maven.archiva.model.SnapshotVersion;
import org.apache.maven.archiva.xml.XMLException;
import org.apache.maven.archiva.xml.XMLReader;
@@ -78,6 +79,15 @@ public class RepositoryMetadataReader
metadata.setSnapshotVersion( snapshot );
}
+ for ( Element plugin : xml.getElementList( "//metadata/plugins/plugin" ) )
+ {
+ Plugin p = new Plugin();
+ p.setPrefix( plugin.elementTextTrim( "prefix" ) );
+ p.setArtifactId( plugin.elementTextTrim( "artifactId" ) );
+ p.setName( plugin.elementTextTrim( "name" ) );
+ metadata.addPlugin( p );
+ }
+
return metadata;
}
catch ( XMLException e )
diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataWriter.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataWriter.java
index fb99fb235..9b0d1b283 100644
--- a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataWriter.java
+++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataWriter.java
@@ -23,6 +23,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
+import org.apache.maven.archiva.model.Plugin;
import org.apache.maven.archiva.xml.XMLException;
import org.apache.maven.archiva.xml.XMLWriter;
import org.dom4j.Document;
@@ -34,6 +35,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Iterator;
+import java.util.List;
/**
* RepositoryMetadataWriter
@@ -73,9 +75,21 @@ public class RepositoryMetadataWriter
doc.setRootElement( root );
root.addElement( "groupId" ).setText( metadata.getGroupId() );
- root.addElement( "artifactId" ).setText( metadata.getArtifactId() );
+ addOptionalElementText( root, "artifactId", metadata.getArtifactId() );
addOptionalElementText( root, "version", metadata.getVersion() );
+ if ( CollectionUtils.isNotEmpty( metadata.getPlugins() ) )
+ {
+ Element plugins = root.addElement( "plugins" );
+ for ( Plugin plugin : (List<Plugin>)metadata.getPlugins() )
+ {
+ Element p = plugins.addElement( "plugin" );
+ p.addElement( "prefix" ).setText( plugin.getPrefix() );
+ p.addElement( "artifactId" ).setText( plugin.getArtifactId() );
+ addOptionalElementText( p, "name", plugin.getName() );
+ }
+ }
+
if ( CollectionUtils.isNotEmpty( metadata.getAvailableVersions() )
|| StringUtils.isNotBlank( metadata.getReleasedVersion() )
|| StringUtils.isNotBlank( metadata.getLatestVersion() )
diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/metadata/MetadataToolsTest.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/metadata/MetadataToolsTest.java
index 223238da2..892cbe748 100644
--- a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/metadata/MetadataToolsTest.java
+++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/metadata/MetadataToolsTest.java
@@ -37,6 +37,7 @@ import org.custommonkey.xmlunit.DetailedDiff;
import org.custommonkey.xmlunit.Diff;
import org.xml.sax.SAXException;
+import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -44,8 +45,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
-import javax.xml.parsers.ParserConfigurationException;
-
/**
* MetadataToolsTest
*
@@ -114,19 +113,20 @@ public class MetadataToolsTest
assertMetadataPath( "commons-lang/commons-lang/maven-metadata-central.xml", convertedName );
}
- public void testUpdateProjectBadArtifact()
- throws Exception
- {
- try
- {
- assertUpdatedProjectMetadata( "bad_artifact", null );
- fail( "Should have thrown an IOException on a bad artifact." );
- }
- catch ( IOException e )
- {
- // Expected path
- }
- }
+ // TODO: replace with group tests
+// public void testUpdateProjectBadArtifact()
+// throws Exception
+// {
+// try
+// {
+// assertUpdatedProjectMetadata( "bad_artifact", null );
+// fail( "Should have thrown an IOException on a bad artifact." );
+// }
+// catch ( IOException e )
+// {
+// // Expected path
+// }
+// }
public void testUpdateProjectMissingMultipleVersions()
throws Exception