mirror of https://github.com/apache/archiva.git
revert r412961 - it wasn't working as designed and the test failed in a clean environment. The TODO is meant to indicate to replace the parsing of the filename to obtain snapshot metadata with retrieving it from the source metadata file instead of attempting to merge all. The tests did not test snapshot metadata at all.
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@417698 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
794b829284
commit
3205ed65f7
|
@ -95,11 +95,6 @@ public class DefaultRepositoryConverter
|
||||||
*/
|
*/
|
||||||
private boolean dryrun;
|
private boolean dryrun;
|
||||||
|
|
||||||
/**
|
|
||||||
* @plexus.configuration default-value="true"
|
|
||||||
*/
|
|
||||||
private boolean mergeWithSourceMetadata;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @plexus.requirement
|
* @plexus.requirement
|
||||||
*/
|
*/
|
||||||
|
@ -125,8 +120,8 @@ public class DefaultRepositoryConverter
|
||||||
Versioning versioning = new Versioning();
|
Versioning versioning = new Versioning();
|
||||||
versioning.addVersion( artifact.getBaseVersion() );
|
versioning.addVersion( artifact.getBaseVersion() );
|
||||||
metadata.setVersioning( versioning );
|
metadata.setVersioning( versioning );
|
||||||
updateMetadata( new ArtifactRepositoryMetadata( artifact ), artifact.getRepository(),
|
updateMetadata( new ArtifactRepositoryMetadata( artifact ), targetRepository, metadata,
|
||||||
targetRepository, metadata, transaction );
|
transaction );
|
||||||
|
|
||||||
metadata = createBaseMetadata( artifact );
|
metadata = createBaseMetadata( artifact );
|
||||||
metadata.setVersion( artifact.getBaseVersion() );
|
metadata.setVersion( artifact.getBaseVersion() );
|
||||||
|
@ -141,9 +136,10 @@ public class DefaultRepositoryConverter
|
||||||
versioning.setSnapshot( snapshot );
|
versioning.setSnapshot( snapshot );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: merge latest/release/snapshot from source instead
|
||||||
metadata.setVersioning( versioning );
|
metadata.setVersioning( versioning );
|
||||||
updateMetadata( new SnapshotArtifactRepositoryMetadata( artifact ), artifact.getRepository(),
|
updateMetadata( new SnapshotArtifactRepositoryMetadata( artifact ), targetRepository, metadata,
|
||||||
targetRepository, metadata, transaction );
|
transaction );
|
||||||
|
|
||||||
if ( !dryrun )
|
if ( !dryrun )
|
||||||
{
|
{
|
||||||
|
@ -163,17 +159,16 @@ public class DefaultRepositoryConverter
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMetadata( RepositoryMetadata artifactMetadata, ArtifactRepository sourceRepository,
|
private void updateMetadata( RepositoryMetadata artifactMetadata, ArtifactRepository targetRepository,
|
||||||
ArtifactRepository targetRepository, Metadata newMetadata,
|
Metadata newMetadata, FileTransaction transaction )
|
||||||
FileTransaction transaction )
|
|
||||||
throws RepositoryConversionException
|
throws RepositoryConversionException
|
||||||
{
|
{
|
||||||
|
File file = new File( targetRepository.getBasedir(),
|
||||||
|
targetRepository.pathOfRemoteRepositoryMetadata( artifactMetadata ) );
|
||||||
|
|
||||||
Metadata metadata;
|
Metadata metadata;
|
||||||
boolean changed;
|
boolean changed;
|
||||||
|
|
||||||
//merge with target repository metadata
|
|
||||||
File file = new File( targetRepository.getBasedir(),
|
|
||||||
targetRepository.pathOfRemoteRepositoryMetadata( artifactMetadata ) );
|
|
||||||
if ( file.exists() )
|
if ( file.exists() )
|
||||||
{
|
{
|
||||||
metadata = readMetadata( file );
|
metadata = readMetadata( file );
|
||||||
|
@ -185,19 +180,6 @@ public class DefaultRepositoryConverter
|
||||||
metadata = newMetadata;
|
metadata = newMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
//merge with source repository metadata
|
|
||||||
if ( mergeWithSourceMetadata )
|
|
||||||
{
|
|
||||||
File srcfile = new File( sourceRepository.getBasedir(),
|
|
||||||
sourceRepository.pathOfRemoteRepositoryMetadata( artifactMetadata ) );
|
|
||||||
|
|
||||||
if ( srcfile.exists() )
|
|
||||||
{
|
|
||||||
Metadata sourceMetadata = readMetadata( srcfile );
|
|
||||||
changed = changed || metadata.merge( sourceMetadata );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( changed )
|
if ( changed )
|
||||||
{
|
{
|
||||||
StringWriter writer = null;
|
StringWriter writer = null;
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
<metadata>
|
|
||||||
<groupId>test</groupId>
|
|
||||||
<artifactId>correctArtifactMetadata</artifactId>
|
|
||||||
<versioning>
|
|
||||||
<versions>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<version>2.0</version>
|
|
||||||
</versions>
|
|
||||||
</versioning>
|
|
||||||
</metadata>
|
|
|
@ -732,39 +732,6 @@ public class RepositoryConverterTest
|
||||||
assertFalse( "Check metadata not created", metadataFile.exists() );
|
assertFalse( "Check metadata not created", metadataFile.exists() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSourceArtifactMetadataMerging()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
// test metadata in target repository is merged with the metadata in the source repository
|
|
||||||
|
|
||||||
createModernSourceRepository();
|
|
||||||
|
|
||||||
Artifact artifact = createArtifact( "test", "correctArtifactMetadata", "1.0.0" );
|
|
||||||
|
|
||||||
repositoryConverter.convert( artifact, targetRepository, reporter );
|
|
||||||
checkSuccess();
|
|
||||||
|
|
||||||
File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
|
|
||||||
assertTrue( "Check artifact created", artifactFile.exists() );
|
|
||||||
assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) );
|
|
||||||
|
|
||||||
artifact = createPomArtifact( artifact );
|
|
||||||
File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
|
|
||||||
File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) );
|
|
||||||
assertTrue( "Check POM created", pomFile.exists() );
|
|
||||||
|
|
||||||
compareFiles( sourcePomFile, pomFile );
|
|
||||||
|
|
||||||
ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact );
|
|
||||||
File artifactMetadataFile = new File( targetRepository.getBasedir(),
|
|
||||||
targetRepository.pathOfRemoteRepositoryMetadata( artifactMetadata ) );
|
|
||||||
assertTrue( "Check artifact metadata created", artifactMetadataFile.exists() );
|
|
||||||
|
|
||||||
File expectedMetadataFile = getTestFile( "src/test/expected-files/v4artifact-source-merging-metadata.xml" );
|
|
||||||
|
|
||||||
compareFiles( expectedMetadataFile, artifactMetadataFile );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testInvalidSourceSnapshotMetadata()
|
public void testInvalidSourceSnapshotMetadata()
|
||||||
throws Exception, MalformedURLException
|
throws Exception, MalformedURLException
|
||||||
{
|
{
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
incorrectMd5
|
|
|
@ -1,22 +0,0 @@
|
||||||
<!--
|
|
||||||
~ Copyright 2005-2006 The Apache Software Foundation.
|
|
||||||
~
|
|
||||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
~ you may not use this file except in compliance with the License.
|
|
||||||
~ You may obtain a copy of the License at
|
|
||||||
~
|
|
||||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
~
|
|
||||||
~ Unless required by applicable law or agreed to in writing, software
|
|
||||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
~ See the License for the specific language governing permissions and
|
|
||||||
~ limitations under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<project>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<artifactId>correctArtifactMetadata</artifactId>
|
|
||||||
<groupId>test</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</project>
|
|
|
@ -1,26 +0,0 @@
|
||||||
<!--
|
|
||||||
~ Copyright 2005-2006 The Apache Software Foundation.
|
|
||||||
~
|
|
||||||
~ Licensed 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>test</groupId>
|
|
||||||
<artifactId>correctArtifactMetadata</artifactId>
|
|
||||||
<versioning>
|
|
||||||
<versions>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<version>2.0</version>
|
|
||||||
</versions>
|
|
||||||
</versioning>
|
|
||||||
</metadata>
|
|
Loading…
Reference in New Issue