mirror of https://github.com/apache/archiva.git
[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
This commit is contained in:
parent
5c5b371765
commit
e4a54528f3
|
@ -640,6 +640,20 @@
|
|||
<multiplicity>1</multiplicity>
|
||||
</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>
|
||||
|
@ -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>
|
||||
|
||||
|
||||
<!-- _______________________________________________________________
|
||||
____ __
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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 );
|
||||
}
|
||||
|
||||
// Add the versions to the metadata model.
|
||||
metadata.setAvailableVersions( sortedVersions );
|
||||
|
||||
metadata.setLatestVersion( latestVersion );
|
||||
metadata.setReleasedVersion( releaseVersion );
|
||||
}
|
||||
|
||||
Collections.sort( releasedVersions, VersionComparator.getInstance() );
|
||||
Collections.sort( snapshotVersions, VersionComparator.getInstance() );
|
||||
|
||||
String latestVersion = sortedVersions.get( sortedVersions.size() - 1 );
|
||||
String releaseVersion = null;
|
||||
|
||||
if ( CollectionUtils.isNotEmpty( releasedVersions ) )
|
||||
else
|
||||
{
|
||||
releaseVersion = releasedVersions.get( releasedVersions.size() - 1 );
|
||||
// Add the plugins to the metadata model.
|
||||
metadata.setPlugins( new ArrayList<Plugin>( allPlugins ) );
|
||||
|
||||
// artifact ID was actually the last part of the group
|
||||
metadata.setGroupId( metadata.getGroupId() + "." + metadata.getArtifactId() );
|
||||
metadata.setArtifactId( null );
|
||||
}
|
||||
|
||||
// Add the versions to the metadata model.
|
||||
metadata.setAvailableVersions( sortedVersions );
|
||||
|
||||
metadata.setLatestVersion( latestVersion );
|
||||
metadata.setReleasedVersion( releaseVersion );
|
||||
if ( lastUpdated > 0 )
|
||||
{
|
||||
metadata.setLastUpdatedTimestamp( toLastUpdatedDate( lastUpdated ) );
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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() )
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.meterware.httpunit.GetMethodWebRequest;
|
|||
import com.meterware.httpunit.HttpUnitOptions;
|
||||
import com.meterware.httpunit.WebRequest;
|
||||
import com.meterware.httpunit.WebResponse;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.custommonkey.xmlunit.DetailedDiff;
|
||||
|
@ -145,6 +144,34 @@ public abstract class AbstractRepositoryServletProxiedMetadataTestCase
|
|||
return buf.toString();
|
||||
}
|
||||
|
||||
protected String createGroupMetadata( String groupId, String[] plugins )
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
buf.append( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" );
|
||||
buf.append( "<metadata>\n" );
|
||||
buf.append( " <groupId>" ).append( groupId ).append( "</groupId>\n" );
|
||||
|
||||
boolean hasPlugins = !ArrayUtils.isEmpty( plugins );
|
||||
|
||||
if ( hasPlugins )
|
||||
{
|
||||
buf.append( " <plugins>\n" );
|
||||
for ( String plugin : plugins )
|
||||
{
|
||||
buf.append( " <plugin>\n" );
|
||||
buf.append( " <prefix>" ).append( plugin ).append( "</prefix>\n" );
|
||||
buf.append( " <artifactId>" ).append( plugin + "-maven-plugin" ).append( "</artifactId>\n" );
|
||||
buf.append( " <name>" ).append( "The " + plugin + " Plugin" ).append( "</name>\n" );
|
||||
buf.append( " </plugin>\n" );
|
||||
}
|
||||
buf.append( " </plugins>\n" );
|
||||
}
|
||||
buf.append( "</metadata>" );
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
protected void setupPrivateSnapshotsRemoteRepo()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.apache.maven.archiva.web.repository;
|
|||
import com.meterware.httpunit.GetMethodWebRequest;
|
||||
import com.meterware.httpunit.WebRequest;
|
||||
import com.meterware.httpunit.WebResponse;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -72,6 +71,24 @@ public class RepositoryServletNoProxyMetadataTest
|
|||
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
|
||||
}
|
||||
|
||||
public void testGetGroupMetadataDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
String commonsLangMetadata = "commons-lang/maven-metadata.xml";
|
||||
String expectedMetadataContents = "metadata-for-commons-lang-group";
|
||||
|
||||
File checksumFile = new File( repoRootInternal, commonsLangMetadata );
|
||||
checksumFile.getParentFile().mkdirs();
|
||||
|
||||
FileUtils.writeStringToFile( checksumFile, expectedMetadataContents, null );
|
||||
|
||||
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
|
||||
WebResponse response = sc.getResponse( request );
|
||||
assertResponseOK( response );
|
||||
|
||||
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
|
||||
}
|
||||
|
||||
public void testGetSnapshotVersionMetadataDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.apache.maven.archiva.web.repository;
|
|||
import com.meterware.httpunit.GetMethodWebRequest;
|
||||
import com.meterware.httpunit.WebRequest;
|
||||
import com.meterware.httpunit.WebResponse;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -107,6 +106,24 @@ public class RepositoryServletNoProxyTest
|
|||
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
|
||||
}
|
||||
|
||||
public void testGetNoProxyGroupMetadataDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
String commonsLangMetadata = "commons-lang/maven-metadata.xml";
|
||||
String expectedMetadataContents = "dummy-group-metadata";
|
||||
|
||||
File metadataFile = new File( repoRootInternal, commonsLangMetadata );
|
||||
metadataFile.getParentFile().mkdirs();
|
||||
|
||||
FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, null );
|
||||
|
||||
WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangMetadata );
|
||||
WebResponse response = sc.getResponse( request );
|
||||
assertResponseOK( response );
|
||||
|
||||
assertEquals( "Expected file contents", expectedMetadataContents, response.getText() );
|
||||
}
|
||||
|
||||
public void testGetNoProxyArtifactDefaultLayout()
|
||||
throws Exception
|
||||
{
|
||||
|
|
|
@ -95,4 +95,24 @@ public class RepositoryServletProxiedMetadataLocalOnlyTest
|
|||
// --- Verification
|
||||
assertExpectedMetadata( expectedMetadata, actualMetadata );
|
||||
}
|
||||
|
||||
public void testGetProxiedGroupMetadataLocalOnly()
|
||||
throws Exception
|
||||
{
|
||||
// --- Setup
|
||||
setupSnapshotsRemoteRepo();
|
||||
setupPrivateSnapshotsRemoteRepo();
|
||||
setupCleanInternalRepo();
|
||||
|
||||
String path = "org/apache/archiva/maven-metadata.xml";
|
||||
String expectedMetadata = createGroupMetadata( "org.apache.archiva", new String[] { "archivatest-maven-plugin" } );
|
||||
|
||||
populateRepo( repoRootInternal, path, expectedMetadata );
|
||||
|
||||
// --- Execution
|
||||
String actualMetadata = requestMetadataOK( path );
|
||||
|
||||
// --- Verification
|
||||
assertExpectedMetadata( expectedMetadata, actualMetadata );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,4 +139,28 @@ public class RepositoryServletProxiedMetadataRemoteOnlyTest
|
|||
// --- Verification
|
||||
assertExpectedMetadata( expectedMetadata, actualMetadata );
|
||||
}
|
||||
|
||||
public void testGetProxiedGroupMetadataRemoteOnly()
|
||||
throws Exception
|
||||
{
|
||||
// --- Setup
|
||||
setupSnapshotsRemoteRepo();
|
||||
setupPrivateSnapshotsRemoteRepo();
|
||||
setupCleanInternalRepo();
|
||||
|
||||
String path = "org/apache/archiva/maven-metadata.xml";
|
||||
String expectedMetadata = createGroupMetadata( "org.apache.archiva", new String[] { "archivatest-maven-plugin" } );
|
||||
|
||||
File managedFile = populateRepo( remoteSnapshots, path, expectedMetadata );
|
||||
|
||||
setupConnector( REPOID_INTERNAL, remoteSnapshots );
|
||||
setupConnector( REPOID_INTERNAL, remotePrivateSnapshots );
|
||||
saveConfiguration();
|
||||
|
||||
// --- Execution
|
||||
String actualMetadata = requestMetadataOK( path );
|
||||
|
||||
// --- Verification
|
||||
assertExpectedMetadata( expectedMetadata, actualMetadata );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue