From 3205ed65f78b54e082e2f23bbca902cb41abaf36 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Wed, 28 Jun 2006 08:34:20 +0000 Subject: [PATCH] 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 --- .../converter/DefaultRepositoryConverter.java | 38 +++++-------------- .../v4artifact-source-merging-metadata.xml | 10 ----- .../converter/RepositoryConverterTest.java | 33 ---------------- .../1.0.0/correctArtifactMetadata-1.0.0.jar | 1 - .../1.0.0/correctArtifactMetadata-1.0.0.pom | 22 ----------- .../maven-metadata.xml | 26 ------------- 6 files changed, 10 insertions(+), 120 deletions(-) delete mode 100644 maven-repository-converter/src/test/expected-files/v4artifact-source-merging-metadata.xml delete mode 100644 maven-repository-converter/src/test/source-modern-repository/test/correctArtifactMetadata/1.0.0/correctArtifactMetadata-1.0.0.jar delete mode 100644 maven-repository-converter/src/test/source-modern-repository/test/correctArtifactMetadata/1.0.0/correctArtifactMetadata-1.0.0.pom delete mode 100644 maven-repository-converter/src/test/source-modern-repository/test/correctArtifactMetadata/maven-metadata.xml diff --git a/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java b/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java index f0cc1248c..57ee50685 100644 --- a/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java +++ b/maven-repository-converter/src/main/java/org/apache/maven/repository/converter/DefaultRepositoryConverter.java @@ -95,11 +95,6 @@ public class DefaultRepositoryConverter */ private boolean dryrun; - /** - * @plexus.configuration default-value="true" - */ - private boolean mergeWithSourceMetadata; - /** * @plexus.requirement */ @@ -125,8 +120,8 @@ public class DefaultRepositoryConverter Versioning versioning = new Versioning(); versioning.addVersion( artifact.getBaseVersion() ); metadata.setVersioning( versioning ); - updateMetadata( new ArtifactRepositoryMetadata( artifact ), artifact.getRepository(), - targetRepository, metadata, transaction ); + updateMetadata( new ArtifactRepositoryMetadata( artifact ), targetRepository, metadata, + transaction ); metadata = createBaseMetadata( artifact ); metadata.setVersion( artifact.getBaseVersion() ); @@ -141,9 +136,10 @@ public class DefaultRepositoryConverter versioning.setSnapshot( snapshot ); } + // TODO: merge latest/release/snapshot from source instead metadata.setVersioning( versioning ); - updateMetadata( new SnapshotArtifactRepositoryMetadata( artifact ), artifact.getRepository(), - targetRepository, metadata, transaction ); + updateMetadata( new SnapshotArtifactRepositoryMetadata( artifact ), targetRepository, metadata, + transaction ); if ( !dryrun ) { @@ -163,17 +159,16 @@ public class DefaultRepositoryConverter return metadata; } - private void updateMetadata( RepositoryMetadata artifactMetadata, ArtifactRepository sourceRepository, - ArtifactRepository targetRepository, Metadata newMetadata, - FileTransaction transaction ) + private void updateMetadata( RepositoryMetadata artifactMetadata, ArtifactRepository targetRepository, + Metadata newMetadata, FileTransaction transaction ) throws RepositoryConversionException { + File file = new File( targetRepository.getBasedir(), + targetRepository.pathOfRemoteRepositoryMetadata( artifactMetadata ) ); + Metadata metadata; boolean changed; - //merge with target repository metadata - File file = new File( targetRepository.getBasedir(), - targetRepository.pathOfRemoteRepositoryMetadata( artifactMetadata ) ); if ( file.exists() ) { metadata = readMetadata( file ); @@ -185,19 +180,6 @@ public class DefaultRepositoryConverter 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 ) { StringWriter writer = null; diff --git a/maven-repository-converter/src/test/expected-files/v4artifact-source-merging-metadata.xml b/maven-repository-converter/src/test/expected-files/v4artifact-source-merging-metadata.xml deleted file mode 100644 index f6fb7b1d9..000000000 --- a/maven-repository-converter/src/test/expected-files/v4artifact-source-merging-metadata.xml +++ /dev/null @@ -1,10 +0,0 @@ - - test - correctArtifactMetadata - - - 1.0.0 - 2.0 - - - \ No newline at end of file diff --git a/maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java b/maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java index 21b199bc5..c60331de5 100644 --- a/maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java +++ b/maven-repository-converter/src/test/java/org/apache/maven/repository/converter/RepositoryConverterTest.java @@ -732,39 +732,6 @@ public class RepositoryConverterTest 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() throws Exception, MalformedURLException { diff --git a/maven-repository-converter/src/test/source-modern-repository/test/correctArtifactMetadata/1.0.0/correctArtifactMetadata-1.0.0.jar b/maven-repository-converter/src/test/source-modern-repository/test/correctArtifactMetadata/1.0.0/correctArtifactMetadata-1.0.0.jar deleted file mode 100644 index 72af4bc10..000000000 --- a/maven-repository-converter/src/test/source-modern-repository/test/correctArtifactMetadata/1.0.0/correctArtifactMetadata-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -incorrectMd5 diff --git a/maven-repository-converter/src/test/source-modern-repository/test/correctArtifactMetadata/1.0.0/correctArtifactMetadata-1.0.0.pom b/maven-repository-converter/src/test/source-modern-repository/test/correctArtifactMetadata/1.0.0/correctArtifactMetadata-1.0.0.pom deleted file mode 100644 index a258834c1..000000000 --- a/maven-repository-converter/src/test/source-modern-repository/test/correctArtifactMetadata/1.0.0/correctArtifactMetadata-1.0.0.pom +++ /dev/null @@ -1,22 +0,0 @@ - - - - 4.0.0 - correctArtifactMetadata - test - 1.0.0 - diff --git a/maven-repository-converter/src/test/source-modern-repository/test/correctArtifactMetadata/maven-metadata.xml b/maven-repository-converter/src/test/source-modern-repository/test/correctArtifactMetadata/maven-metadata.xml deleted file mode 100644 index bfef089f3..000000000 --- a/maven-repository-converter/src/test/source-modern-repository/test/correctArtifactMetadata/maven-metadata.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - test - correctArtifactMetadata - - - 1.0.0 - 2.0 - - - \ No newline at end of file