From 099c5383c26d473767c04df128b13bbfd555b2b4 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Sat, 7 May 2005 05:45:20 +0000 Subject: [PATCH] o Refactored RepositoryCleaner to use DiscoveryPhase and RewritePhase. o Added the ability to read a pom and figure out whether it's a v4 pom (based on presence of modelVersion) o Added a more accurate counter for artifacts that are actually rewritten successfully, rather than just the ones that enter the rewriting process. o Probably need to add the phases still... git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@169041 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/maven/model/v3_0_0/Branch.java | 1 - .../org/apache/maven/model/v3_0_0/Build.java | 1 - .../maven/model/v3_0_0/Contributor.java | 1 - .../apache/maven/model/v3_0_0/Dependency.java | 1 - .../apache/maven/model/v3_0_0/Developer.java | 1 - .../apache/maven/model/v3_0_0/FileSet.java | 1 - .../apache/maven/model/v3_0_0/License.java | 1 - .../maven/model/v3_0_0/MailingList.java | 1 - .../maven/model/v3_0_0/Organization.java | 1 - .../maven/model/v3_0_0/PackageGroup.java | 1 - .../apache/maven/model/v3_0_0/Repository.java | 1 - .../apache/maven/model/v3_0_0/Resource.java | 1 - .../model/v3_0_0/SourceModification.java | 1 - .../apache/maven/model/v3_0_0/UnitTest.java | 1 - .../apache/maven/model/v3_0_0/Version.java | 1 - .../model/v3_0_0/io/xpp3/MavenXpp3Reader.java | 54 ++- .../model/v3_0_0/io/xpp3/MavenXpp3Writer.java | 96 ++-- .../apache/maven/tools/repoclean/Main.java | 36 +- .../tools/repoclean/RepositoryCleaner.java | 414 ++---------------- .../RepositoryCleanerConfiguration.java | 12 - .../artifact/handler/DtdHandler.java | 3 +- .../artifact/handler/EarHandler.java | 3 +- .../artifact/handler/JarDistroHandler.java | 3 +- .../artifact/handler/LegacyPluginHandler.java | 3 +- .../artifact/handler/RarHandler.java | 3 +- .../artifact/handler/SarHandler.java | 3 +- .../artifact/handler/TgzDistroHandler.java | 3 +- .../artifact/handler/TldHandler.java | 3 +- .../artifact/handler/ZipDistroHandler.java | 3 +- .../layout/AlphaBridgingRepositoryLayout.java | 3 +- .../artifact/metadata/ProjectMetadata.java | 3 +- .../repoclean/digest/DigestException.java | 3 +- .../digest/DigestVerificationException.java | 3 +- .../repoclean/digest/DigestVerifier.java | 8 +- .../tools/repoclean/digest/Digestor.java | 6 +- .../discover/AbstractArtifactDiscoverer.java | 7 +- .../discover/ArtifactDiscoverer.java | 29 +- .../discover/DefaultArtifactDiscoverer.java | 5 +- .../discover/LegacyArtifactDiscoverer.java | 57 +-- .../repoclean/index/ArtifactIndexer.java | 6 +- .../tools/repoclean/report/FileReporter.java | 12 +- .../report/ReportWriteException.java | 3 +- .../rewrite/ArtifactPomRewriter.java | 11 +- .../repoclean/rewrite/V3PomRewriter.java | 73 +-- .../repoclean/rewrite/V4PomRewriter.java | 58 +-- .../transaction/RewriteTransaction.java | 4 +- .../transaction/RollbackException.java | 3 +- .../translate/PomTranslationException.java | 3 +- .../translate/PomV3ToV4Translator.java | 53 ++- 49 files changed, 336 insertions(+), 668 deletions(-) diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Branch.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Branch.java index 174ae4c086..dc5bfc8a17 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Branch.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Branch.java @@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0; //- Imported classes and packages -/ //---------------------------------/ - /** * Class Branch. * diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Build.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Build.java index 0604e8d7c5..5c9f7c396f 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Build.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Build.java @@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0; //- Imported classes and packages -/ //---------------------------------/ - /** * Class Build. * diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Contributor.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Contributor.java index e3a17eeb39..f83642dff6 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Contributor.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Contributor.java @@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0; //- Imported classes and packages -/ //---------------------------------/ - /** * Class Contributor. * diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Dependency.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Dependency.java index 4cdce0ec04..fb06dc27cf 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Dependency.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Dependency.java @@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0; //- Imported classes and packages -/ //---------------------------------/ - /** * Class Dependency. * diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Developer.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Developer.java index 5caba145b0..dc1cd60591 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Developer.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Developer.java @@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0; //- Imported classes and packages -/ //---------------------------------/ - /** * Class Developer. * diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/FileSet.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/FileSet.java index 6c98461b19..6447f1c132 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/FileSet.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/FileSet.java @@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0; //- Imported classes and packages -/ //---------------------------------/ - /** * Class FileSet. * diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/License.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/License.java index cde75e6c26..ad394cebc8 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/License.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/License.java @@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0; //- Imported classes and packages -/ //---------------------------------/ - /** * Class License. * diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/MailingList.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/MailingList.java index 4b0952e6f6..2f420b647c 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/MailingList.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/MailingList.java @@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0; //- Imported classes and packages -/ //---------------------------------/ - /** * Class MailingList. * diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Organization.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Organization.java index 71aac2a1a7..5b97856a21 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Organization.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Organization.java @@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0; //- Imported classes and packages -/ //---------------------------------/ - /** * Class Organization. * diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/PackageGroup.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/PackageGroup.java index 65e5064e12..26062277a8 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/PackageGroup.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/PackageGroup.java @@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0; //- Imported classes and packages -/ //---------------------------------/ - /** * Class PackageGroup. * diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Repository.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Repository.java index e2b4d88d37..fa19ac14c9 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Repository.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Repository.java @@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0; //- Imported classes and packages -/ //---------------------------------/ - /** * Class Repository. * diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Resource.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Resource.java index 9fe7ef1bbb..1171679742 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Resource.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Resource.java @@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0; //- Imported classes and packages -/ //---------------------------------/ - /** * Class Resource. * diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/SourceModification.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/SourceModification.java index 1c8f077911..7676c995f6 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/SourceModification.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/SourceModification.java @@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0; //- Imported classes and packages -/ //---------------------------------/ - /** * Class SourceModification. * diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/UnitTest.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/UnitTest.java index f7283d38e6..32ad0cef6d 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/UnitTest.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/UnitTest.java @@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0; //- Imported classes and packages -/ //---------------------------------/ - /** * Class UnitTest. * diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Version.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Version.java index 97c40aaa18..f910f6a84f 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Version.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/Version.java @@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0; //- Imported classes and packages -/ //---------------------------------/ - /** * Class Version. * diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/io/xpp3/MavenXpp3Reader.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/io/xpp3/MavenXpp3Reader.java index 77be70c2f2..c816983773 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/io/xpp3/MavenXpp3Reader.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/io/xpp3/MavenXpp3Reader.java @@ -72,7 +72,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private Branch parseBranch( String tagName, XmlPullParser parser ) throws Exception + private Branch parseBranch( String tagName, XmlPullParser parser ) + throws Exception { Branch branch = new Branch(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -98,7 +99,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private Build parseBuild( String tagName, XmlPullParser parser ) throws Exception + private Build parseBuild( String tagName, XmlPullParser parser ) + throws Exception { Build build = new Build(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -176,7 +178,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private Contributor parseContributor( String tagName, XmlPullParser parser ) throws Exception + private Contributor parseContributor( String tagName, XmlPullParser parser ) + throws Exception { Contributor contributor = new Contributor(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -234,7 +237,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private Dependency parseDependency( String tagName, XmlPullParser parser ) throws Exception + private Dependency parseDependency( String tagName, XmlPullParser parser ) + throws Exception { Dependency dependency = new Dependency(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -293,7 +297,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private Developer parseDeveloper( String tagName, XmlPullParser parser ) throws Exception + private Developer parseDeveloper( String tagName, XmlPullParser parser ) + throws Exception { Developer developer = new Developer(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -355,7 +360,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private FileSet parseFileSet( String tagName, XmlPullParser parser ) throws Exception + private FileSet parseFileSet( String tagName, XmlPullParser parser ) + throws Exception { FileSet fileSet = new FileSet(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -413,7 +419,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private License parseLicense( String tagName, XmlPullParser parser ) throws Exception + private License parseLicense( String tagName, XmlPullParser parser ) + throws Exception { License license = new License(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -451,7 +458,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private MailingList parseMailingList( String tagName, XmlPullParser parser ) throws Exception + private MailingList parseMailingList( String tagName, XmlPullParser parser ) + throws Exception { MailingList mailingList = new MailingList(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -489,7 +497,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private Model parseModel( String tagName, XmlPullParser parser ) throws Exception + private Model parseModel( String tagName, XmlPullParser parser ) + throws Exception { Model model = new Model(); int eventType = parser.getEventType(); @@ -753,7 +762,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private Organization parseOrganization( String tagName, XmlPullParser parser ) throws Exception + private Organization parseOrganization( String tagName, XmlPullParser parser ) + throws Exception { Organization organization = new Organization(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -787,7 +797,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private PackageGroup parsePackageGroup( String tagName, XmlPullParser parser ) throws Exception + private PackageGroup parsePackageGroup( String tagName, XmlPullParser parser ) + throws Exception { PackageGroup packageGroup = new PackageGroup(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -817,7 +828,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private PatternSet parsePatternSet( String tagName, XmlPullParser parser ) throws Exception + private PatternSet parsePatternSet( String tagName, XmlPullParser parser ) + throws Exception { PatternSet patternSet = new PatternSet(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -871,7 +883,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private Repository parseRepository( String tagName, XmlPullParser parser ) throws Exception + private Repository parseRepository( String tagName, XmlPullParser parser ) + throws Exception { Repository repository = new Repository(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -905,7 +918,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private Resource parseResource( String tagName, XmlPullParser parser ) throws Exception + private Resource parseResource( String tagName, XmlPullParser parser ) + throws Exception { Resource resource = new Resource(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -971,7 +985,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private SourceModification parseSourceModification( String tagName, XmlPullParser parser ) throws Exception + private SourceModification parseSourceModification( String tagName, XmlPullParser parser ) + throws Exception { SourceModification sourceModification = new SourceModification(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -1037,7 +1052,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private UnitTest parseUnitTest( String tagName, XmlPullParser parser ) throws Exception + private UnitTest parseUnitTest( String tagName, XmlPullParser parser ) + throws Exception { UnitTest unitTest = new UnitTest(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -1107,7 +1123,8 @@ public class MavenXpp3Reader * @param tagName * @param parser */ - private Version parseVersion( String tagName, XmlPullParser parser ) throws Exception + private Version parseVersion( String tagName, XmlPullParser parser ) + throws Exception { Version version = new Version(); while ( parser.nextTag() == XmlPullParser.START_TAG ) @@ -1140,7 +1157,8 @@ public class MavenXpp3Reader * * @param reader */ - public Model read( Reader reader ) throws Exception + public Model read( Reader reader ) + throws Exception { XmlPullParser parser = new MXParser(); parser.setInput( reader ); diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/io/xpp3/MavenXpp3Writer.java b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/io/xpp3/MavenXpp3Writer.java index 107d9553b2..705c918eee 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/io/xpp3/MavenXpp3Writer.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/model/v3_0_0/io/xpp3/MavenXpp3Writer.java @@ -63,7 +63,8 @@ public class MavenXpp3Writer * @param writer * @param model */ - public void write( Writer writer, Model model ) throws Exception + public void write( Writer writer, Model model ) + throws Exception { serializer = new MXSerializer(); serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " ); @@ -79,7 +80,8 @@ public class MavenXpp3Writer * @param serializer * @param tagName */ - private void writeBranch( Branch branch, String tagName, XmlSerializer serializer ) throws Exception + private void writeBranch( Branch branch, String tagName, XmlSerializer serializer ) + throws Exception { if ( branch != null ) { @@ -99,7 +101,8 @@ public class MavenXpp3Writer * @param serializer * @param tagName */ - private void writeBuild( Build build, String tagName, XmlSerializer serializer ) throws Exception + private void writeBuild( Build build, String tagName, XmlSerializer serializer ) + throws Exception { if ( build != null ) { @@ -107,28 +110,28 @@ public class MavenXpp3Writer if ( build.getNagEmailAddress() != null ) { serializer.startTag( NAMESPACE, "nagEmailAddress" ).text( build.getNagEmailAddress() ) - .endTag( NAMESPACE, "nagEmailAddress" ); + .endTag( NAMESPACE, "nagEmailAddress" ); } if ( build.getSourceDirectory() != null ) { serializer.startTag( NAMESPACE, "sourceDirectory" ).text( build.getSourceDirectory() ) - .endTag( NAMESPACE, "sourceDirectory" ); + .endTag( NAMESPACE, "sourceDirectory" ); } if ( build.getUnitTestSourceDirectory() != null ) { serializer.startTag( NAMESPACE, "unitTestSourceDirectory" ).text( build.getUnitTestSourceDirectory() ) - .endTag( NAMESPACE, "unitTestSourceDirectory" ); + .endTag( NAMESPACE, "unitTestSourceDirectory" ); } if ( build.getAspectSourceDirectory() != null ) { serializer.startTag( NAMESPACE, "aspectSourceDirectory" ).text( build.getAspectSourceDirectory() ) - .endTag( NAMESPACE, "aspectSourceDirectory" ); + .endTag( NAMESPACE, "aspectSourceDirectory" ); } if ( build.getIntegrationUnitTestSourceDirectory() != null ) { serializer.startTag( NAMESPACE, "integrationUnitTestSourceDirectory" ) - .text( build.getIntegrationUnitTestSourceDirectory() ) - .endTag( NAMESPACE, "integrationUnitTestSourceDirectory" ); + .text( build.getIntegrationUnitTestSourceDirectory() ) + .endTag( NAMESPACE, "integrationUnitTestSourceDirectory" ); } if ( build.getSourceModifications() != null && build.getSourceModifications().size() > 0 ) { @@ -165,7 +168,8 @@ public class MavenXpp3Writer * @param serializer * @param tagName */ - private void writeContributor( Contributor contributor, String tagName, XmlSerializer serializer ) throws Exception + private void writeContributor( Contributor contributor, String tagName, XmlSerializer serializer ) + throws Exception { if ( contributor != null ) { @@ -185,7 +189,7 @@ public class MavenXpp3Writer if ( contributor.getOrganization() != null ) { serializer.startTag( NAMESPACE, "organization" ).text( contributor.getOrganization() ) - .endTag( NAMESPACE, "organization" ); + .endTag( NAMESPACE, "organization" ); } if ( contributor.getRoles() != null && contributor.getRoles().size() > 0 ) { @@ -213,7 +217,8 @@ public class MavenXpp3Writer * @param serializer * @param tagName */ - private void writeDependency( Dependency dependency, String tagName, XmlSerializer serializer ) throws Exception + private void writeDependency( Dependency dependency, String tagName, XmlSerializer serializer ) + throws Exception { if ( dependency != null ) { @@ -271,7 +276,8 @@ public class MavenXpp3Writer * @param serializer * @param tagName */ - private void writeDeveloper( Developer developer, String tagName, XmlSerializer serializer ) throws Exception + private void writeDeveloper( Developer developer, String tagName, XmlSerializer serializer ) + throws Exception { if ( developer != null ) { @@ -295,7 +301,7 @@ public class MavenXpp3Writer if ( developer.getOrganization() != null ) { serializer.startTag( NAMESPACE, "organization" ).text( developer.getOrganization() ) - .endTag( NAMESPACE, "organization" ); + .endTag( NAMESPACE, "organization" ); } if ( developer.getRoles() != null && developer.getRoles().size() > 0 ) { @@ -323,7 +329,8 @@ public class MavenXpp3Writer * @param serializer * @param tagName */ - private void writeFileSet( FileSet fileSet, String tagName, XmlSerializer serializer ) throws Exception + private void writeFileSet( FileSet fileSet, String tagName, XmlSerializer serializer ) + throws Exception { if ( fileSet != null ) { @@ -364,7 +371,8 @@ public class MavenXpp3Writer * @param serializer * @param tagName */ - private void writeLicense( License license, String tagName, XmlSerializer serializer ) throws Exception + private void writeLicense( License license, String tagName, XmlSerializer serializer ) + throws Exception { if ( license != null ) { @@ -380,7 +388,7 @@ public class MavenXpp3Writer if ( license.getDistribution() != null ) { serializer.startTag( NAMESPACE, "distribution" ).text( license.getDistribution() ) - .endTag( NAMESPACE, "distribution" ); + .endTag( NAMESPACE, "distribution" ); } if ( license.getComments() != null ) { @@ -398,7 +406,8 @@ public class MavenXpp3Writer * @param serializer * @param tagName */ - private void writeMailingList( MailingList mailingList, String tagName, XmlSerializer serializer ) throws Exception + private void writeMailingList( MailingList mailingList, String tagName, XmlSerializer serializer ) + throws Exception { if ( mailingList != null ) { @@ -415,7 +424,7 @@ public class MavenXpp3Writer if ( mailingList.getUnsubscribe() != null ) { serializer.startTag( NAMESPACE, "unsubscribe" ).text( mailingList.getUnsubscribe() ) - .endTag( NAMESPACE, "unsubscribe" ); + .endTag( NAMESPACE, "unsubscribe" ); } if ( mailingList.getArchive() != null ) { @@ -433,7 +442,8 @@ public class MavenXpp3Writer * @param serializer * @param tagName */ - private void writeModel( Model model, String tagName, XmlSerializer serializer ) throws Exception + private void writeModel( Model model, String tagName, XmlSerializer serializer ) + throws Exception { if ( model != null ) { @@ -467,12 +477,12 @@ public class MavenXpp3Writer if ( model.getCurrentVersion() != null ) { serializer.startTag( NAMESPACE, "currentVersion" ).text( model.getCurrentVersion() ) - .endTag( NAMESPACE, "currentVersion" ); + .endTag( NAMESPACE, "currentVersion" ); } if ( model.getShortDescription() != null ) { serializer.startTag( NAMESPACE, "shortDescription" ).text( model.getShortDescription() ) - .endTag( NAMESPACE, "shortDescription" ); + .endTag( NAMESPACE, "shortDescription" ); } if ( model.getDescription() != null ) { @@ -490,17 +500,17 @@ public class MavenXpp3Writer if ( model.getIssueTrackingUrl() != null ) { serializer.startTag( NAMESPACE, "issueTrackingUrl" ).text( model.getIssueTrackingUrl() ) - .endTag( NAMESPACE, "issueTrackingUrl" ); + .endTag( NAMESPACE, "issueTrackingUrl" ); } if ( model.getInceptionYear() != null ) { serializer.startTag( NAMESPACE, "inceptionYear" ).text( model.getInceptionYear() ) - .endTag( NAMESPACE, "inceptionYear" ); + .endTag( NAMESPACE, "inceptionYear" ); } if ( model.getGumpRepositoryId() != null ) { serializer.startTag( NAMESPACE, "gumpRepositoryId" ).text( model.getGumpRepositoryId() ) - .endTag( NAMESPACE, "gumpRepositoryId" ); + .endTag( NAMESPACE, "gumpRepositoryId" ); } if ( model.getSiteAddress() != null ) { @@ -510,17 +520,17 @@ public class MavenXpp3Writer if ( model.getSiteDirectory() != null ) { serializer.startTag( NAMESPACE, "siteDirectory" ).text( model.getSiteDirectory() ) - .endTag( NAMESPACE, "siteDirectory" ); + .endTag( NAMESPACE, "siteDirectory" ); } if ( model.getDistributionSite() != null ) { serializer.startTag( NAMESPACE, "distributionSite" ).text( model.getDistributionSite() ) - .endTag( NAMESPACE, "distributionSite" ); + .endTag( NAMESPACE, "distributionSite" ); } if ( model.getDistributionDirectory() != null ) { serializer.startTag( NAMESPACE, "distributionDirectory" ).text( model.getDistributionDirectory() ) - .endTag( NAMESPACE, "distributionDirectory" ); + .endTag( NAMESPACE, "distributionDirectory" ); } if ( model.getMailingLists() != null && model.getMailingLists().size() > 0 ) { @@ -638,7 +648,7 @@ public class MavenXpp3Writer if ( model.getPackageName() != null ) { serializer.startTag( NAMESPACE, "package" ).text( model.getPackageName() ) - .endTag( NAMESPACE, "package" ); + .endTag( NAMESPACE, "package" ); } serializer.endTag( NAMESPACE, tagName ); } @@ -706,7 +716,8 @@ public class MavenXpp3Writer * @param serializer * @param tagName */ - private void writePatternSet( PatternSet patternSet, String tagName, XmlSerializer serializer ) throws Exception + private void writePatternSet( PatternSet patternSet, String tagName, XmlSerializer serializer ) + throws Exception { if ( patternSet != null ) { @@ -742,7 +753,8 @@ public class MavenXpp3Writer * @param serializer * @param tagName */ - private void writeRepository( Repository repository, String tagName, XmlSerializer serializer ) throws Exception + private void writeRepository( Repository repository, String tagName, XmlSerializer serializer ) + throws Exception { if ( repository != null ) { @@ -755,7 +767,7 @@ public class MavenXpp3Writer if ( repository.getDeveloperConnection() != null ) { serializer.startTag( NAMESPACE, "developerConnection" ).text( repository.getDeveloperConnection() ) - .endTag( NAMESPACE, "developerConnection" ); + .endTag( NAMESPACE, "developerConnection" ); } if ( repository.getUrl() != null ) { @@ -772,7 +784,8 @@ public class MavenXpp3Writer * @param serializer * @param tagName */ - private void writeResource( Resource resource, String tagName, XmlSerializer serializer ) throws Exception + private void writeResource( Resource resource, String tagName, XmlSerializer serializer ) + throws Exception { if ( resource != null ) { @@ -785,7 +798,7 @@ public class MavenXpp3Writer if ( resource.isFiltering() != false ) { serializer.startTag( NAMESPACE, "filtering" ).text( String.valueOf( resource.isFiltering() ) ) - .endTag( NAMESPACE, "filtering" ); + .endTag( NAMESPACE, "filtering" ); } if ( resource.getDirectory() != null ) { @@ -824,7 +837,8 @@ public class MavenXpp3Writer * @param tagName */ private void writeSourceModification( SourceModification sourceModification, String tagName, - XmlSerializer serializer ) throws Exception + XmlSerializer serializer ) + throws Exception { if ( sourceModification != null ) { @@ -832,17 +846,17 @@ public class MavenXpp3Writer if ( sourceModification.getClassName() != null ) { serializer.startTag( NAMESPACE, "className" ).text( sourceModification.getClassName() ) - .endTag( NAMESPACE, "className" ); + .endTag( NAMESPACE, "className" ); } if ( sourceModification.getProperty() != null ) { serializer.startTag( NAMESPACE, "property" ).text( sourceModification.getProperty() ) - .endTag( NAMESPACE, "property" ); + .endTag( NAMESPACE, "property" ); } if ( sourceModification.getDirectory() != null ) { serializer.startTag( NAMESPACE, "directory" ).text( sourceModification.getDirectory() ) - .endTag( NAMESPACE, "directory" ); + .endTag( NAMESPACE, "directory" ); } if ( sourceModification.getIncludes() != null && sourceModification.getIncludes().size() > 0 ) { @@ -875,7 +889,8 @@ public class MavenXpp3Writer * @param serializer * @param tagName */ - private void writeUnitTest( UnitTest unitTest, String tagName, XmlSerializer serializer ) throws Exception + private void writeUnitTest( UnitTest unitTest, String tagName, XmlSerializer serializer ) + throws Exception { if ( unitTest != null ) { @@ -921,7 +936,8 @@ public class MavenXpp3Writer * @param serializer * @param tagName */ - private void writeVersion( Version version, String tagName, XmlSerializer serializer ) throws Exception + private void writeVersion( Version version, String tagName, XmlSerializer serializer ) + throws Exception { if ( version != null ) { diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/Main.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/Main.java index 5be2c0ff4a..65a221ed5e 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/Main.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/Main.java @@ -136,15 +136,14 @@ public class Main RepositoryCleanerConfiguration config = new RepositoryCleanerConfiguration(); config.setSourceRepositoryPath( props.getProperty( "sourceRepositoryPath" ) ); config.setSourceRepositoryLayout( props.getProperty( "sourceRepositoryLayout", "legacy" ) ); - config.setSourcePomVersion( props.getProperty( "sourcePomVersion", "v3" ) ); config.setTargetRepositoryPath( props.getProperty( "targetRepositoryPath" ) ); config.setTargetRepositoryLayout( props.getProperty( "targetRepositoryLayout", "default" ) ); config.setReportsPath( props.getProperty( "reportsPath" ) ); config.setBlacklistedPatterns( props.getProperty( "blacklistedPatterns" ) ); config.setReportOnly( Boolean.valueOf( props.getProperty( "reportOnly" ) ).booleanValue() ); - config.setMailErrorReport( - Boolean.valueOf( props.getProperty( "errorReport.mailOnError", "false" ) ).booleanValue() ); + config.setMailErrorReport( Boolean.valueOf( props.getProperty( "errorReport.mailOnError", "false" ) ) + .booleanValue() ); config.setErrorReportFromAddress( props.getProperty( "errorReport.fromAddress" ) ); config.setErrorReportFromName( props.getProperty( "errorReport.fromName" ) ); config.setErrorReportSubject( props.getProperty( "errorReport.subject" ) ); @@ -157,25 +156,34 @@ public class Main private static void printHelp() { - System.out.println( "repoclean: Repository Cleaner/Converter.\n\n" + - "Usage: repoclean -h|-template|\n\n" + - "---------------------------------------------------------------------------\n" + - " Use the '-template' option to see sample configuration file options.\n" + "\n" ); + System.out.println( "repoclean: Repository Cleaner/Converter.\n\n" + + "Usage: repoclean -h|-template|\n\n" + + "---------------------------------------------------------------------------\n" + + " Use the '-template' option to see sample configuration file options.\n" + "\n" ); } private static void printTemplate() { - System.out.println( "# ---------------------------------------------------------------------------\n" + - "# repoclean: Repository Cleaner/Converter.\n" + "# This configuration auto-generated on: " + new java.util.Date() + "\n" + - "# ---------------------------------------------------------------------------\n\n" + - "# [REQUIRED OPTIONS]\n" + "sourceRepositoryPath=/path/to/repository/root\n" + "targetRepositoryPath=/path/to/repository/root\n" + "reportsPath=/path/to/reports/directory\n" + "reportOnly=[true|false]\n" + "\n" + "errorReport.mailOnError=[true|false]\n" + "errorReport.fromAddress=admin@somewhere.com\n" + "errorReport.fromName=Admin\n" + "errorReport.subject=[REPOCLEAN] Error!\n" + "errorReport.toAddress=dev@somewhere.com\n" + "errorReport.toName=Developers List\n" + "\n" + "# [DEFAULT VALUE: legacy]\n" + "#sourceRepositoryLayout=[legacy|default]\n\n" + "# [DEFAULT VALUE: v3]\n" + "#sourcePomType=[v3|v4]\n\n" + "# [DEFAULT VALUE: default]\n" + "#targetRepositoryLayout=[legacy|default]\n" + "# [DEFAULT VALUE: localhost]\n" + "#errorReport.smtpHost=\n" + "\n" ); + System.out.println( "# ---------------------------------------------------------------------------\n" + + "# repoclean: Repository Cleaner/Converter.\n" + "# This configuration auto-generated on: " + + new java.util.Date() + "\n" + + "# ---------------------------------------------------------------------------\n\n" + + "# [REQUIRED OPTIONS]\n" + "sourceRepositoryPath=/path/to/repository/root\n" + + "targetRepositoryPath=/path/to/repository/root\n" + "reportsPath=/path/to/reports/directory\n" + + "reportOnly=[true|false]\n" + "\n" + "errorReport.mailOnError=[true|false]\n" + + "errorReport.fromAddress=admin@somewhere.com\n" + "errorReport.fromName=Admin\n" + + "errorReport.subject=[REPOCLEAN] Error!\n" + "errorReport.toAddress=dev@somewhere.com\n" + + "errorReport.toName=Developers List\n" + "\n" + "# [DEFAULT VALUE: legacy]\n" + + "#sourceRepositoryLayout=[legacy|default]\n\n" + "# [DEFAULT VALUE: v3]\n" + + "# [DEFAULT VALUE: default]\n" + "#targetRepositoryLayout=[legacy|default]\n" + + "# [DEFAULT VALUE: localhost]\n" + "#errorReport.smtpHost=\n" + "\n" ); } private static void printUsage() { - System.out.println( "Required input is missing.\n\n" + "Usage:\n" + - "--------------------------------------------------\n\n" + - "repoclean -h|-template|\n" ); + System.out.println( "Required input is missing.\n\n" + "Usage:\n" + + "--------------------------------------------------\n\n" + + "repoclean -h|-template|\n" ); } } \ No newline at end of file diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleaner.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleaner.java index 2a9adc4af9..622fdd57d8 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleaner.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleaner.java @@ -15,21 +15,12 @@ package org.apache.maven.tools.repoclean; * the License. ==================================================================== */ -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.tools.repoclean.artifact.metadata.ProjectMetadata; -import org.apache.maven.tools.repoclean.digest.DigestVerifier; -import org.apache.maven.tools.repoclean.discover.ArtifactDiscoverer; import org.apache.maven.tools.repoclean.index.ArtifactIndexer; +import org.apache.maven.tools.repoclean.phase.DiscoveryPhase; +import org.apache.maven.tools.repoclean.phase.RewritePhase; import org.apache.maven.tools.repoclean.report.FileReporter; -import org.apache.maven.tools.repoclean.report.PathLister; -import org.apache.maven.tools.repoclean.report.ReportWriteException; -import org.apache.maven.tools.repoclean.report.Reporter; -import org.apache.maven.tools.repoclean.rewrite.ArtifactPomRewriter; -import org.apache.maven.tools.repoclean.transaction.RewriteTransaction; -import org.apache.maven.tools.repoclean.transaction.RollbackException; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.context.Context; @@ -40,39 +31,32 @@ import org.codehaus.plexus.mailsender.MailMessage; import org.codehaus.plexus.mailsender.MailSender; import org.codehaus.plexus.mailsender.MailSenderException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; -import org.codehaus.plexus.util.IOUtil; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.Iterator; import java.util.List; /** * @author jdcasey */ -public class RepositoryCleaner extends AbstractLogEnabled implements Contextualizable +public class RepositoryCleaner + extends AbstractLogEnabled + implements Contextualizable { public static final String ROLE = RepositoryCleaner.class.getName(); private static final String REPORTS_DIR_DATE_FORMAT = "dd-MMM-yyyy_hh.mm.ss"; - private DigestVerifier digestVerifier; - - private ArtifactRepositoryLayout bridgingLayout; - private MailSender mailSender; private ArtifactIndexer artifactIndexer; + private DiscoveryPhase discoveryPhase; + + private RewritePhase rewritePhase; + private PlexusContainer container; private String dateSubdir; @@ -97,90 +81,41 @@ public class RepositoryCleaner extends AbstractLogEnabled implements Contextuali { repoReporter = new FileReporter( reportsBase, "repository.report.txt" ); - ArtifactDiscoverer artifactDiscoverer = null; + List artifacts; - List artifacts = null; + artifacts = discoveryPhase.execute( reportsBase, sourceRepositoryBase, configuration, repoReporter ); - PathLister kickoutLister = null; - PathLister excludeLister = null; - - try - { - artifactDiscoverer = (ArtifactDiscoverer) container.lookup( ArtifactDiscoverer.ROLE, - configuration.getSourceRepositoryLayout() ); - - if ( logger.isDebugEnabled() ) - { - logger.debug( "Discovering artifacts." ); - } - - try - { - File kickoutsList = new File( reportsBase, "kickouts.txt" ); - File excludesList = new File( reportsBase, "excludes.txt" ); - - kickoutLister = new PathLister( kickoutsList ); - excludeLister = new PathLister( excludesList ); - - artifacts = artifactDiscoverer.discoverArtifacts( sourceRepositoryBase, repoReporter, - configuration.getBlacklistedPatterns(), - excludeLister, kickoutLister ); - } - catch ( Exception e ) - { - repoReporter.error( "Error discovering artifacts in source repository.", e ); - - throw e; - } - - } - finally - { - if ( artifactDiscoverer != null ) - { - container.release( artifactDiscoverer ); - } - - if ( excludeLister != null ) - { - excludeLister.close(); - } - - if ( kickoutLister != null ) - { - kickoutLister.close(); - } - } - - if ( artifacts != null ) + if ( !artifacts.isEmpty() ) { ArtifactRepositoryLayout sourceLayout = null; ArtifactRepositoryLayout targetLayout = null; try { sourceLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE, - configuration.getSourceRepositoryLayout() ); + configuration + .getSourceRepositoryLayout() ); - ArtifactRepository sourceRepo = new ArtifactRepository( "source", "file://" + - sourceRepositoryBase.getAbsolutePath(), - sourceLayout ); + ArtifactRepository sourceRepo = new ArtifactRepository( "source", "file://" + + sourceRepositoryBase.getAbsolutePath(), sourceLayout ); targetLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE, - configuration.getTargetRepositoryLayout() ); + configuration + .getTargetRepositoryLayout() ); - ArtifactRepository targetRepo = new ArtifactRepository( "target", "file://" + - targetRepositoryBase.getAbsolutePath(), - targetLayout ); + ArtifactRepository targetRepo = new ArtifactRepository( "target", "file://" + + targetRepositoryBase.getAbsolutePath(), targetLayout ); if ( logger.isDebugEnabled() ) { logger.debug( "Rewriting POMs and artifact files." ); } - artifactIndexer.writeAritfactIndex( artifacts, targetRepositoryBase ); + // List originalArtifacts = new ArrayList( artifacts ); - rewriteArtifactsAndPoms( artifacts, sourceRepo, targetRepo, configuration, reportsBase, - sourceRepositoryBase, targetRepositoryBase, repoReporter ); + List rewritten = rewritePhase.execute( artifacts, sourceRepo, targetRepo, configuration, + reportsBase, repoReporter ); + + artifactIndexer.writeAritfactIndex( rewritten, targetRepositoryBase ); } finally { @@ -203,8 +138,8 @@ public class RepositoryCleaner extends AbstractLogEnabled implements Contextuali if ( repoReporter.hasWarning() && logger.isDebugEnabled() ) { - logger.debug( - "Warning encountered while rewriting one or more artifacts from source repository to target repository." ); + logger + .warn( "Warning encountered while rewriting one or more artifacts from source repository to target repository." ); } } finally @@ -215,7 +150,8 @@ public class RepositoryCleaner extends AbstractLogEnabled implements Contextuali } } - // if we wrote a repository report, and the configuration says to email the report, then do it. + // if we wrote a repository report with an error in it, and the configuration says to email the report, + // then do it. if ( repoReporter.hasError() && configuration.mailErrorReport() ) { logger.debug( "Sending error report to " + configuration.getErrorReportToName() + " via email." ); @@ -224,10 +160,10 @@ public class RepositoryCleaner extends AbstractLogEnabled implements Contextuali StringBuffer contentBuffer = new StringBuffer(); - contentBuffer.append( "Errors occurred while performing maven-1 to maven-2 repository conversion.\n\n" + - "For more details, see:\n\n" ); + contentBuffer.append( "Errors occurred while performing maven-1 to maven-2 repository conversion.\n\n" + + "For more details, see:\n\n" ); - contentBuffer.append( configuration.getErrorReportLink().replaceAll("#date", dateSubdir) ); + contentBuffer.append( configuration.getErrorReportLink().replaceAll( "#date", dateSubdir ) ); message.setContent( contentBuffer.toString() ); message.setSubject( configuration.getErrorReportSubject() ); @@ -242,7 +178,7 @@ public class RepositoryCleaner extends AbstractLogEnabled implements Contextuali catch ( MailSenderException e ) { logger.error( "An error occurred while trying to email repoclean report.", e ); - + throw e; } } @@ -250,286 +186,6 @@ public class RepositoryCleaner extends AbstractLogEnabled implements Contextuali } - private void rewriteArtifactsAndPoms( List artifacts, ArtifactRepository sourceRepo, ArtifactRepository targetRepo, - RepositoryCleanerConfiguration configuration, File reportsBase, - File sourceRepositoryBase, File targetRepositoryBase, - FileReporter repoReporter ) - throws Exception - { - Logger logger = getLogger(); - - ArtifactPomRewriter artifactPomRewriter = null; - - try - { - logger.debug( "Rewriting up to " + artifacts.size() + " artifacts (Should be " + ( artifacts.size() * 2 ) + - " rewrites including POMs)." ); - - int actualRewriteCount = 0; - for ( Iterator it = artifacts.iterator(); it.hasNext(); ) - { - Artifact artifact = (Artifact) it.next(); - - RewriteTransaction transaction = new RewriteTransaction( artifact ); - - String artifactReportPath = buildArtifactReportPath( artifact ); - - FileReporter artifactReporter = null; - try - { - artifactReporter = new FileReporter( reportsBase, artifactReportPath ); - - boolean errorOccurred = false; - - File artifactSource = new File( sourceRepo.getBasedir(), sourceRepo.pathOf( artifact ) ); - File artifactTarget = new File( targetRepo.getBasedir(), targetRepo.pathOf( artifact ).replace( - '+', '-' ) ); - - transaction.addFile( artifactTarget ); - - artifact.setFile( artifactSource ); - - boolean targetMissingOrOlder = !artifactTarget.exists() || - artifactTarget.lastModified() < artifactSource.lastModified(); - - if ( artifactSource.exists() && ( configuration.force() || targetMissingOrOlder ) ) - { - actualRewriteCount++; - - transaction.addFile( artifactTarget ); - - try - { - if ( !configuration.reportOnly() ) - { - if ( logger.isDebugEnabled() ) - { - logger.debug( "sourceRepo basedir is: \'" + sourceRepo.getBasedir() + "\'" ); - logger.debug( "targetRepo basedir is: \'" + targetRepo.getBasedir() + "\'" ); - } - - File targetParent = artifactTarget.getParentFile(); - if ( !targetParent.exists() ) - { - targetParent.mkdirs(); - } - - if ( logger.isDebugEnabled() ) - { - logger.debug( "Copying artifact[" + artifact.getId() + "] from \'" + - artifactSource + "\' to \'" + artifactTarget + "\'." ); - } - - copyArtifact( artifact, artifactTarget, artifactReporter ); - } - } - catch ( Exception e ) - { - repoReporter.error( "Error transferring artifact[" + artifact.getId() + - "] to the target repository.", e ); - - throw e; - } - - if ( logger.isDebugEnabled() ) - { - logger.debug( "working on digest for artifact[" + artifact.getId() + "] with groupId: \'" + - artifact.getGroupId() + "\'" ); - } - - try - { - digestVerifier.verifyDigest( artifactSource, artifactTarget, transaction, artifactReporter, - configuration.reportOnly() ); - } - catch ( Exception e ) - { - repoReporter.error( "Error verifying digest for artifact[" + artifact.getId() + "]", e ); - - throw e; - } - - ArtifactMetadata pom = new ProjectMetadata( artifact ); - - artifactPomRewriter = (ArtifactPomRewriter) container.lookup( ArtifactPomRewriter.ROLE, - configuration.getSourcePomVersion() ); - - File sourcePom = new File( sourceRepositoryBase, sourceRepo.pathOfMetadata( pom ) ); - - File targetPom = new File( targetRepositoryBase, - targetRepo.pathOfMetadata( pom ).replace( '+', '-' ) ); - - transaction.addFile( targetPom ); - - File bridgedTargetPom = new File( targetRepositoryBase, bridgingLayout.pathOfMetadata( pom ).replace( - '+', '-' ) ); - - transaction.addFile( bridgedTargetPom ); - - try - { - artifactPomRewriter.rewrite( artifact, sourcePom, targetPom, artifactReporter, - configuration.reportOnly() ); - - boolean wroteBridge = bridgePomLocations( targetPom, bridgedTargetPom, artifactReporter ); - - digestVerifier.verifyDigest( sourcePom, targetPom, transaction, artifactReporter, - configuration.reportOnly() ); - - if ( wroteBridge ) - { - digestVerifier.verifyDigest( sourcePom, bridgedTargetPom, transaction, - artifactReporter, configuration.reportOnly() ); - } - - } - catch ( Exception e ) - { - repoReporter.error( "Error rewriting POM for artifact[" + artifact.getId() + - "] into the target repository.\n Error message: " + e.getMessage() ); - - throw e; - } - - } - else if ( !targetMissingOrOlder ) - { - artifactReporter.warn( "Target file for artifact is present and not stale. (Artifact: \'" + - artifact.getId() + "\' in path: \'" + artifactSource + - "\' with target path: " + artifactTarget + ")." ); - } - else - { - artifactReporter.error( "Cannot find source file for artifact: \'" + artifact.getId() + - "\' under path: \'" + artifactSource + "\'" ); - } - - if ( artifactReporter.hasError() ) - { - repoReporter.warn( "Error(s) occurred while rewriting artifact: \'" + artifact.getId() + - "\' or its POM." ); - } - } - catch ( Exception e ) - { - if ( !configuration.force() ) - { - repoReporter.warn( "Rolling back conversion for: " + artifact ); - try - { - transaction.rollback(); - } - catch ( RollbackException re ) - { - repoReporter.error( "Error rolling back conversion transaction.", re ); - } - } - else - { - repoReporter.warn( "NOT Rolling back conversion for: " + artifact + "; we are in --force mode." ); - } - - artifactReporter.error( "Error while rewriting file or POM for artifact: \'" + artifact.getId() + - "\'. See report at: \'" + artifactReportPath + "\'.", e ); - } - finally - { - if ( artifactReporter != null ) - { - artifactReporter.close(); - } - } - } - - logger.info( "Actual number of artifacts rewritten: " + actualRewriteCount + " (" + - ( actualRewriteCount * 2 ) + " including POMs)." ); - } - finally - { - if ( artifactPomRewriter != null ) - { - container.release( artifactPomRewriter ); - } - } - } - - private boolean bridgePomLocations( File targetPom, File bridgedTargetPom, Reporter reporter ) - throws IOException, ReportWriteException - { - if ( targetPom.equals( bridgedTargetPom ) ) - { - reporter.warn( "Cannot create legacy-compatible copy of POM at: " + targetPom + - "; legacy-compatible path is the same as the converted POM itself." ); - - return false; - } - - FileInputStream in = null; - FileOutputStream out = null; - - try - { - in = new FileInputStream( targetPom ); - out = new FileOutputStream( bridgedTargetPom ); - - IOUtil.copy( in, out ); - } - finally - { - IOUtil.close( in ); - IOUtil.close( out ); - } - - return true; - } - - private String buildArtifactReportPath( Artifact artifact ) - { - String classifier = artifact.getClassifier(); - String groupId = artifact.getGroupId().replace( '.', '/' ); - String artifactId = artifact.getArtifactId(); - String type = artifact.getType(); - String version = artifact.getVersion(); - - return groupId + "/" + artifactId + "/" + type + "/" + - ( ( classifier != null ) ? ( classifier + "-" ) : ( "" ) ) + version + ".report.txt"; - } - - private void copyArtifact( Artifact artifact, File artifactTarget, FileReporter reporter ) - throws IOException - { - File artifactSource = artifact.getFile(); - - InputStream inStream = null; - OutputStream outStream = null; - try - { - File targetParent = artifactTarget.getParentFile(); - if ( !targetParent.exists() ) - { - targetParent.mkdirs(); - } - - inStream = new BufferedInputStream( new FileInputStream( artifactSource ) ); - outStream = new BufferedOutputStream( new FileOutputStream( artifactTarget ) ); - - byte[] buffer = new byte[16]; - int read = -1; - - while ( ( read = inStream.read( buffer ) ) > -1 ) - { - outStream.write( buffer, 0, read ); - } - - outStream.flush(); - } - finally - { - IOUtil.close( inStream ); - IOUtil.close( outStream ); - } - } - private File normalizeTargetRepositoryBase( String targetRepositoryPath ) { Logger logger = getLogger(); @@ -546,8 +202,8 @@ public class RepositoryCleaner extends AbstractLogEnabled implements Contextuali } else if ( !targetRepositoryBase.isDirectory() ) { - logger.error( "Cannot write to target repository \'" + targetRepositoryBase + - "\' because it is not a directory." ); + logger.error( "Cannot write to target repository \'" + targetRepositoryBase + + "\' because it is not a directory." ); targetRepositoryBase = null; } diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleanerConfiguration.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleanerConfiguration.java index d8218383e1..8ec293a57c 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleanerConfiguration.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleanerConfiguration.java @@ -27,8 +27,6 @@ public class RepositoryCleanerConfiguration private String sourceRepositoryLayout; - private String sourcePomVersion; - private String targetRepositoryPath; private String targetRepositoryLayout; @@ -75,16 +73,6 @@ public class RepositoryCleanerConfiguration return sourceRepositoryLayout; } - public void setSourcePomVersion( String sourcePomVersion ) - { - this.sourcePomVersion = sourcePomVersion; - } - - public String getSourcePomVersion() - { - return sourcePomVersion; - } - public void setTargetRepositoryPath( String targetRepositoryPath ) { this.targetRepositoryPath = targetRepositoryPath; diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/DtdHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/DtdHandler.java index 378a0133ed..d1e5445a7a 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/DtdHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/DtdHandler.java @@ -22,7 +22,8 @@ import org.apache.maven.artifact.handler.AbstractArtifactHandler; * @author Jason van Zyl * @version $Id$ */ -public class DtdHandler extends AbstractArtifactHandler +public class DtdHandler + extends AbstractArtifactHandler { public String directory() { diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/EarHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/EarHandler.java index 8059d3ba4f..9263daaa8a 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/EarHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/EarHandler.java @@ -22,7 +22,8 @@ import org.apache.maven.artifact.handler.JarHandler; * @author Jason van Zyl * @version $Id$ */ -public class EarHandler extends JarHandler +public class EarHandler + extends JarHandler { public String directory() { diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/JarDistroHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/JarDistroHandler.java index 634154b698..ca853e3f9b 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/JarDistroHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/JarDistroHandler.java @@ -19,7 +19,8 @@ import org.apache.maven.artifact.handler.AbstractArtifactHandler; /** * @author jdcasey */ -public class JarDistroHandler extends AbstractArtifactHandler +public class JarDistroHandler + extends AbstractArtifactHandler { public String directory() diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/LegacyPluginHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/LegacyPluginHandler.java index d96e465eb3..b13c47f967 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/LegacyPluginHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/LegacyPluginHandler.java @@ -22,7 +22,8 @@ import org.apache.maven.artifact.handler.AbstractArtifactHandler; /** * @author jdcasey */ -public class LegacyPluginHandler extends AbstractArtifactHandler +public class LegacyPluginHandler + extends AbstractArtifactHandler { public String directory() diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/RarHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/RarHandler.java index 00e47df188..2990a42154 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/RarHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/RarHandler.java @@ -22,7 +22,8 @@ import org.apache.maven.artifact.handler.JarHandler; * @author Jason van Zyl * @version $Id$ */ -public class RarHandler extends JarHandler +public class RarHandler + extends JarHandler { public String directory() { diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/SarHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/SarHandler.java index 13e3993d9c..5754257f4b 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/SarHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/SarHandler.java @@ -22,7 +22,8 @@ import org.apache.maven.artifact.handler.JarHandler; * @author Jason van Zyl * @version $Id$ */ -public class SarHandler extends JarHandler +public class SarHandler + extends JarHandler { public String directory() { diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/TgzDistroHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/TgzDistroHandler.java index b645797aa7..cfec97d3ed 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/TgzDistroHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/TgzDistroHandler.java @@ -19,7 +19,8 @@ import org.apache.maven.artifact.handler.AbstractArtifactHandler; /** * @author jdcasey */ -public class TgzDistroHandler extends AbstractArtifactHandler +public class TgzDistroHandler + extends AbstractArtifactHandler { public String directory() diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/TldHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/TldHandler.java index 547f34168f..e2d2618499 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/TldHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/TldHandler.java @@ -22,7 +22,8 @@ import org.apache.maven.artifact.handler.AbstractArtifactHandler; * @author Jason van Zyl * @version $Id$ */ -public class TldHandler extends AbstractArtifactHandler +public class TldHandler + extends AbstractArtifactHandler { public String directory() { diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/ZipDistroHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/ZipDistroHandler.java index e8e4c78552..ddedae4e85 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/ZipDistroHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/ZipDistroHandler.java @@ -19,7 +19,8 @@ import org.apache.maven.artifact.handler.AbstractArtifactHandler; /** * @author jdcasey */ -public class ZipDistroHandler extends AbstractArtifactHandler +public class ZipDistroHandler + extends AbstractArtifactHandler { public String directory() diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/layout/AlphaBridgingRepositoryLayout.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/layout/AlphaBridgingRepositoryLayout.java index 40a0f439b4..854ad3926d 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/layout/AlphaBridgingRepositoryLayout.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/layout/AlphaBridgingRepositoryLayout.java @@ -21,7 +21,8 @@ import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; * limitations under the License. */ -public class AlphaBridgingRepositoryLayout extends DefaultRepositoryLayout +public class AlphaBridgingRepositoryLayout + extends DefaultRepositoryLayout { public String pathOfMetadata( ArtifactMetadata metadata ) diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/metadata/ProjectMetadata.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/metadata/ProjectMetadata.java index 5f97a5199f..08e2706a95 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/metadata/ProjectMetadata.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/metadata/ProjectMetadata.java @@ -28,7 +28,8 @@ import org.apache.maven.artifact.repository.ArtifactRepository; * @author Brett Porter * @version $Id$ */ -public class ProjectMetadata implements ArtifactMetadata +public class ProjectMetadata + implements ArtifactMetadata { private final Artifact artifact; diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/DigestException.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/DigestException.java index 8ec7180bec..a5fba97a9e 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/DigestException.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/DigestException.java @@ -20,7 +20,8 @@ package org.apache.maven.tools.repoclean.digest; /** * @author jdcasey */ -public class DigestException extends Exception +public class DigestException + extends Exception { public DigestException( String message ) diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/DigestVerificationException.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/DigestVerificationException.java index 6b81536fce..4a9d6e5bae 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/DigestVerificationException.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/DigestVerificationException.java @@ -20,7 +20,8 @@ package org.apache.maven.tools.repoclean.digest; /** * @author jdcasey */ -public class DigestVerificationException extends Exception +public class DigestVerificationException + extends Exception { public DigestVerificationException() diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/DigestVerifier.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/DigestVerifier.java index e7b555e965..dfed69fa74 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/DigestVerifier.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/DigestVerifier.java @@ -41,7 +41,7 @@ public class DigestVerifier } public void verifyDigest( File source, File target, RewriteTransaction transaction, Reporter reporter, - boolean reportOnly ) + boolean reportOnly ) throws DigestException, ReportWriteException, IOException { verifyDigestFile( source, target, transaction, reporter, reportOnly, ".md5", Digestor.MD5 ); @@ -50,7 +50,7 @@ public class DigestVerifier } private void verifyDigestFile( File artifactSource, File artifactTarget, RewriteTransaction transaction, - Reporter reporter, boolean reportOnly, String digestExt, String digestAlgorithm ) + Reporter reporter, boolean reportOnly, String digestExt, String digestAlgorithm ) throws DigestException, ReportWriteException, IOException { // create the digest source file from which to copy/verify. @@ -78,8 +78,8 @@ public class DigestVerifier } catch ( IOException e ) { - reporter.error( "Cannot copy digest file for path [" + artifactSource + - "] from source to target for digest algorithm: \'" + digestAlgorithm + "\'.", e ); + reporter.error( "Cannot copy digest file for path [" + artifactSource + + "] from source to target for digest algorithm: \'" + digestAlgorithm + "\'.", e ); throw e; } diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/Digestor.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/Digestor.java index 6d2a59ed6f..9271756648 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/Digestor.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/Digestor.java @@ -68,8 +68,8 @@ public class Digestor } catch ( IOException e ) { - throw new DigestException( "Cannot verify digest for artifact file: \'" + artifactFile + - "\' against digest file: \'" + digestFile + "\' using algorithm: \'" + algorithm + "\'", e ); + throw new DigestException( "Cannot verify digest for artifact file: \'" + artifactFile + + "\' against digest file: \'" + digestFile + "\' using algorithm: \'" + algorithm + "\'", e ); } finally { @@ -137,7 +137,7 @@ public class Digestor { t = "0" + t; } - + out.write( t ); } } diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/AbstractArtifactDiscoverer.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/AbstractArtifactDiscoverer.java index 8af064b8bb..974b043109 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/AbstractArtifactDiscoverer.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/AbstractArtifactDiscoverer.java @@ -23,11 +23,12 @@ import java.io.File; * limitations under the License. */ -public abstract class AbstractArtifactDiscoverer extends AbstractLogEnabled implements ArtifactDiscoverer +public abstract class AbstractArtifactDiscoverer + extends AbstractLogEnabled + implements ArtifactDiscoverer { - protected String[] scanForArtifactPaths( File repositoryBase, String blacklistedPatterns, - PathLister excludesLister ) + protected String[] scanForArtifactPaths( File repositoryBase, String blacklistedPatterns, PathLister excludesLister ) throws ReportWriteException { String[] blacklisted = null; diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/ArtifactDiscoverer.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/ArtifactDiscoverer.java index cfaf7e0f9b..d968f9816e 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/ArtifactDiscoverer.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/ArtifactDiscoverer.java @@ -27,15 +27,30 @@ public interface ArtifactDiscoverer { public static final String ROLE = ArtifactDiscoverer.class.getName(); - public static final String[] STANDARD_DISCOVERY_EXCLUDES = {"bin/**", "reports/**", ".maven/**", "**/poms/*.pom", - "**/*.md5", "**/*.MD5", "**/*.sha1", "**/*.SHA1", - "**/*snapshot-version", "*/website/**", - "*/licenses/**", "*/licences/**", "**/.htaccess", - "**/*.html", "**/*.asc", "**/*.txt", "**/*.xml", - "**/README*", "**/CHANGELOG*", "**/KEYS*"}; + public static final String[] STANDARD_DISCOVERY_EXCLUDES = { + "bin/**", + "reports/**", + ".maven/**", + "**/poms/*.pom", + "**/*.md5", + "**/*.MD5", + "**/*.sha1", + "**/*.SHA1", + "**/*snapshot-version", + "*/website/**", + "*/licenses/**", + "*/licences/**", + "**/.htaccess", + "**/*.html", + "**/*.asc", + "**/*.txt", + "**/*.xml", + "**/README*", + "**/CHANGELOG*", + "**/KEYS*" }; List discoverArtifacts( File repositoryBase, Reporter reporter, String blacklistedPatterns, - PathLister excludeLister, PathLister kickoutLister ) + PathLister excludeLister, PathLister kickoutLister ) throws Exception; } \ No newline at end of file diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/DefaultArtifactDiscoverer.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/DefaultArtifactDiscoverer.java index 64b9e26b91..434237e2e0 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/DefaultArtifactDiscoverer.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/DefaultArtifactDiscoverer.java @@ -29,13 +29,14 @@ import java.util.StringTokenizer; /** * @author jdcasey */ -public class DefaultArtifactDiscoverer extends AbstractArtifactDiscoverer +public class DefaultArtifactDiscoverer + extends AbstractArtifactDiscoverer { private ArtifactFactory artifactFactory; public List discoverArtifacts( File repositoryBase, Reporter reporter, String blacklistedPatterns, - PathLister excludeLister, PathLister kickoutLister ) + PathLister excludeLister, PathLister kickoutLister ) throws Exception { List artifacts = new ArrayList(); diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/LegacyArtifactDiscoverer.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/LegacyArtifactDiscoverer.java index 4cb4e423c1..060c582a5e 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/LegacyArtifactDiscoverer.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/LegacyArtifactDiscoverer.java @@ -30,13 +30,14 @@ import java.util.StringTokenizer; /** * @author jdcasey */ -public class LegacyArtifactDiscoverer extends AbstractArtifactDiscoverer +public class LegacyArtifactDiscoverer + extends AbstractArtifactDiscoverer { private ArtifactFactory artifactFactory; public List discoverArtifacts( File repositoryBase, Reporter reporter, String blacklistedPatterns, - PathLister excludeLister, PathLister kickoutLister ) + PathLister excludeLister, PathLister kickoutLister ) throws Exception { List artifacts = new ArrayList(); @@ -133,13 +134,13 @@ public class LegacyArtifactDiscoverer extends AbstractArtifactDiscoverer } } - String validVersionParts = "([Dd][Ee][Vv][_.0-9]*)|" + "([Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt])|" + - "([0-9][_.0-9a-zA-Z]*)|" + "([Gg]?[_.0-9ab]*([Pp][Rr][Ee]|[Rr][Cc]|[Gg]|[Mm])[_.0-9]*)|" + - "([Aa][Ll][Pp][Hh][Aa][_.0-9]*)|" + "([Bb][Ee][Tt][Aa][_.0-9]*)|" + "([Rr][Cc][_.0-9]*)|" + - "([Tt][Ee][Ss][Tt][_.0-9]*)|" + "([Dd][Ee][Bb][Uu][Gg][_.0-9]*)|" + - "([Uu][Nn][Oo][Ff][Ff][Ii][Cc][Ii][Aa][Ll][_.0-9]*)|" + "([Cc][Uu][Rr][Rr][Ee][Nn][Tt])|" + - "([Ll][Aa][Tt][Ee][Ss][Tt])|" + "([Ff][Cc][Ss])|" + "([Rr][Ee][Ll][Ee][Aa][Ss][Ee][_.0-9]*)|" + - "([Nn][Ii][Gg][Hh][Tt][Ll][Yy])"; + String validVersionParts = "([Dd][Ee][Vv][_.0-9]*)|" + "([Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt])|" + + "([0-9][_.0-9a-zA-Z]*)|" + "([Gg]?[_.0-9ab]*([Pp][Rr][Ee]|[Rr][Cc]|[Gg]|[Mm])[_.0-9]*)|" + + "([Aa][Ll][Pp][Hh][Aa][_.0-9]*)|" + "([Bb][Ee][Tt][Aa][_.0-9]*)|" + "([Rr][Cc][_.0-9]*)|" + + "([Tt][Ee][Ss][Tt][_.0-9]*)|" + "([Dd][Ee][Bb][Uu][Gg][_.0-9]*)|" + + "([Uu][Nn][Oo][Ff][Ff][Ii][Cc][Ii][Aa][Ll][_.0-9]*)|" + "([Cc][Uu][Rr][Rr][Ee][Nn][Tt])|" + + "([Ll][Aa][Tt][Ee][Ss][Tt])|" + "([Ff][Cc][Ss])|" + "([Rr][Ee][Ll][Ee][Aa][Ss][Ee][_.0-9]*)|" + + "([Nn][Ii][Gg][Hh][Tt][Ll][Yy])"; // let's discover the version, and whatever's leftover will be either // a classifier, or part of the artifactId, depending on position. @@ -196,15 +197,17 @@ public class LegacyArtifactDiscoverer extends AbstractArtifactDiscoverer tokensIterated++; } - getLogger().debug( "After parsing loop, state of buffers:\no Version Buffer: \'" + versionBuffer + - "\'\no Classifier Buffer: \'" + classifierBuffer + - "\'\no Number of Tokens Iterated: " + tokensIterated ); + getLogger().debug( + "After parsing loop, state of buffers:\no Version Buffer: \'" + versionBuffer + + "\'\no Classifier Buffer: \'" + classifierBuffer + + "\'\no Number of Tokens Iterated: " + tokensIterated ); // Now, restore the proper ordering so we can build the artifactId. Collections.reverse( avceTokenList ); - getLogger().debug( "Before repairing bad version and/or cleaning up used tokens, avce token list is:\n" + - avceTokenList ); + getLogger().debug( + "Before repairing bad version and/or cleaning up used tokens, avce token list is:\n" + + avceTokenList ); // if we didn't find a version, then punt. Use the last token // as the version, and set the classifier empty. @@ -220,8 +223,9 @@ public class LegacyArtifactDiscoverer extends AbstractArtifactDiscoverer else { getLogger().debug( "Cannot parse version from artifact path: \'" + path + "\'." ); - getLogger().debug( "artifact-version-classifier-extension remaining tokens is: \'" + avceTokenList + - "\'" ); + getLogger().debug( + "artifact-version-classifier-extension remaining tokens is: \'" + avceTokenList + + "\'" ); } classifierBuffer.setLength( 0 ); @@ -232,8 +236,7 @@ public class LegacyArtifactDiscoverer extends AbstractArtifactDiscoverer // if everything is kosher, then pop off all the classifier and // version tokens, leaving the naked artifact id in the list. - avceTokenList = - new LinkedList( avceTokenList.subList( 0, avceTokenList.size() - ( tokensIterated ) ) ); + avceTokenList = new LinkedList( avceTokenList.subList( 0, avceTokenList.size() - ( tokensIterated ) ) ); } getLogger().debug( "Now, remainder of avce token list is:\n" + avceTokenList ); @@ -272,10 +275,11 @@ public class LegacyArtifactDiscoverer extends AbstractArtifactDiscoverer version = null; } - getLogger().debug( "Extracted artifact information from path:\n" + "groupId: \'" + groupId + "\'\n" + - "artifactId: \'" + artifactId + "\'\n" + "type: \'" + type + "\'\n" + - "version: \'" + version + "\'\n" + "classifier: \'" + classifierBuffer.toString() + - "\'" ); + getLogger().debug( + "Extracted artifact information from path:\n" + "groupId: \'" + groupId + "\'\n" + + "artifactId: \'" + artifactId + "\'\n" + "type: \'" + type + "\'\n" + + "version: \'" + version + "\'\n" + "classifier: \'" + classifierBuffer.toString() + + "\'" ); Artifact result = null; @@ -284,16 +288,17 @@ public class LegacyArtifactDiscoverer extends AbstractArtifactDiscoverer getLogger().debug( "Creating artifact with classifier." ); result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, - Artifact.SCOPE_RUNTIME, type, - classifierBuffer.toString() ); + Artifact.SCOPE_RUNTIME, type, classifierBuffer + .toString() ); } else { result = artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, type ); } - getLogger().debug( "Resulting artifact is: " + result.getId() + " and has classifier of: " + - result.getClassifier() + "\n\n" ); + getLogger().debug( + "Resulting artifact is: " + result.getId() + " and has classifier of: " + + result.getClassifier() + "\n\n" ); return result; } diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/index/ArtifactIndexer.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/index/ArtifactIndexer.java index 83eab898dc..51ba7f10dd 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/index/ArtifactIndexer.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/index/ArtifactIndexer.java @@ -32,7 +32,8 @@ import java.util.List; /** * @author jdcasey */ -public class ArtifactIndexer extends AbstractLogEnabled +public class ArtifactIndexer + extends AbstractLogEnabled { public static final String ROLE = ArtifactIndexer.class.getName(); @@ -64,7 +65,8 @@ public class ArtifactIndexer extends AbstractLogEnabled } } - private static final class ArtifactIdComparator implements Comparator + private static final class ArtifactIdComparator + implements Comparator { public int compare( Object first, Object second ) diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/report/FileReporter.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/report/FileReporter.java index 1443f018b6..e632fe921a 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/report/FileReporter.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/report/FileReporter.java @@ -32,7 +32,8 @@ import java.util.List; /** * @author jdcasey */ -public class FileReporter implements Reporter +public class FileReporter + implements Reporter { private static final String WARN_LEVEL = "[WARNING] "; @@ -61,9 +62,9 @@ public class FileReporter implements Reporter if ( !parentDir.isDirectory() ) { - throw new IllegalArgumentException( "path: \'" + parentDir.getAbsolutePath() + - "\' refers to a file, not a directory.\n" + "Cannot write report file: \'" + - reportsFile.getAbsolutePath() + "\'." ); + throw new IllegalArgumentException( "path: \'" + parentDir.getAbsolutePath() + + "\' refers to a file, not a directory.\n" + "Cannot write report file: \'" + + reportsFile.getAbsolutePath() + "\'." ); } } @@ -170,7 +171,8 @@ public class FileReporter implements Reporter return sWriter.toString(); } - private static class AppendingList extends ArrayList + private static class AppendingList + extends ArrayList { public AppendingList() { diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/report/ReportWriteException.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/report/ReportWriteException.java index 3560873b45..d51122c0e2 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/report/ReportWriteException.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/report/ReportWriteException.java @@ -16,7 +16,8 @@ package org.apache.maven.tools.repoclean.report; * limitations under the License. */ -public class ReportWriteException extends Exception +public class ReportWriteException + extends Exception { public ReportWriteException( String message, Throwable cause ) diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/ArtifactPomRewriter.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/ArtifactPomRewriter.java index 842caaa5e9..6d0c2ca977 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/ArtifactPomRewriter.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/ArtifactPomRewriter.java @@ -1,9 +1,10 @@ package org.apache.maven.tools.repoclean.rewrite; import org.apache.maven.artifact.Artifact; -import org.apache.maven.tools.repoclean.report.FileReporter; +import org.apache.maven.tools.repoclean.report.Reporter; -import java.io.File; +import java.io.Reader; +import java.io.Writer; /* ==================================================================== * Copyright 2001-2004 The Apache Software Foundation. @@ -30,7 +31,11 @@ public interface ArtifactPomRewriter public static final String ROLE = ArtifactPomRewriter.class.getName(); - void rewrite( Artifact artifact, File from, File to, FileReporter reporter, boolean reportOnly ) + public static final String V3_POM = "v3"; + + public static final String V4_POM = "v4"; + + void rewrite( Artifact artifact, Reader from, Writer to, Reporter reporter, boolean reportOnly ) throws Exception; } diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/V3PomRewriter.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/V3PomRewriter.java index fc86393fc0..f6874bcafb 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/V3PomRewriter.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/V3PomRewriter.java @@ -4,14 +4,12 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.apache.maven.model.v3_0_0.io.xpp3.MavenXpp3Reader; -import org.apache.maven.tools.repoclean.report.FileReporter; +import org.apache.maven.tools.repoclean.report.Reporter; import org.apache.maven.tools.repoclean.translate.PomV3ToV4Translator; -import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; +import java.io.Reader; +import java.io.Writer; /* ==================================================================== * Copyright 2001-2004 The Apache Software Foundation. @@ -33,51 +31,39 @@ import java.io.FileWriter; /** * @author jdcasey */ -public class V3PomRewriter implements ArtifactPomRewriter +public class V3PomRewriter + implements ArtifactPomRewriter { private PomV3ToV4Translator translator; - public void rewrite( Artifact artifact, File from, File to, FileReporter reporter, boolean reportOnly ) + public void rewrite( Artifact artifact, Reader from, Writer to, Reporter reporter, boolean reportOnly ) throws Exception { Model v4Model = null; - if ( from.exists() ) + if( from != null ) { - FileReader fromReader = null; + org.apache.maven.model.v3_0_0.Model v3Model = null; try { - org.apache.maven.model.v3_0_0.Model v3Model = null; - try - { - fromReader = new FileReader( from ); + MavenXpp3Reader v3Reader = new MavenXpp3Reader(); - MavenXpp3Reader v3Reader = new MavenXpp3Reader(); - - v3Model = v3Reader.read( fromReader ); - } - catch ( Exception e ) - { - reporter.error( "Invalid v3 POM at: \'" + from + "\'. Cannot read.", e ); - - throw e; - } - - if ( v3Model != null ) - { - v4Model = translator.translate( v3Model, reporter ); - } + v3Model = v3Reader.read( from ); } - finally + catch ( Exception e ) { - IOUtil.close( fromReader ); + reporter.error( "Invalid v3 POM at: \'" + from + "\'. Cannot read.", e ); + + throw e; + } + + if ( v3Model != null ) + { + v4Model = translator.translate( v3Model, reporter ); } } else { - reporter.warn( "POM for artifact[" + artifact.getId() + - "] does not exist in source repository. We will create a skeletal one here." ); - v4Model = new Model(); } @@ -87,28 +73,13 @@ public class V3PomRewriter implements ArtifactPomRewriter if ( !reportOnly ) { - File toParent = to.getParentFile(); - if ( !toParent.exists() ) - { - toParent.mkdirs(); - } - - FileWriter toWriter = null; - try - { - toWriter = new FileWriter( to ); - MavenXpp3Writer v4Writer = new MavenXpp3Writer(); - v4Writer.write( toWriter, v4Model ); - } - finally - { - IOUtil.close( toWriter ); - } + MavenXpp3Writer v4Writer = new MavenXpp3Writer(); + v4Writer.write( to, v4Model ); } } } - private void validateV4Basics( Model model, Artifact artifact, FileReporter reporter ) + private void validateV4Basics( Model model, Artifact artifact, Reporter reporter ) throws Exception { if ( StringUtils.isEmpty( model.getModelVersion() ) ) diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/V4PomRewriter.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/V4PomRewriter.java index 3ca1f01e1c..483d6c181c 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/V4PomRewriter.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/V4PomRewriter.java @@ -21,50 +21,39 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; -import org.apache.maven.tools.repoclean.report.FileReporter; -import org.codehaus.plexus.util.IOUtil; +import org.apache.maven.tools.repoclean.report.Reporter; import org.codehaus.plexus.util.StringUtils; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; +import java.io.Reader; +import java.io.Writer; /** * @author jdcasey */ -public class V4PomRewriter implements ArtifactPomRewriter +public class V4PomRewriter + implements ArtifactPomRewriter { - public void rewrite( Artifact artifact, File from, File to, FileReporter reporter, boolean reportOnly ) + public void rewrite( Artifact artifact, Reader from, Writer to, Reporter reporter, boolean reportOnly ) throws Exception { Model model = null; - if ( from.exists() ) + if( from != null ) { - FileReader fromReader = null; + MavenXpp3Reader reader = new MavenXpp3Reader(); + try { - fromReader = new FileReader( from ); - - MavenXpp3Reader reader = new MavenXpp3Reader(); - - try - { - model = reader.read( fromReader ); - } - catch ( Exception e ) - { - reporter.error( "Invalid v4 POM at \'" + from + "\'. Cannot read.", e ); - } + model = reader.read( from ); } - finally + catch ( Exception e ) { - IOUtil.close( fromReader ); + reporter.error( "Invalid v4 POM at \'" + from + "\'. Cannot read.", e ); } } else { - reporter.error( "POM for artifact[" + artifact.getId() + "] does not exist in source repository!" ); + model = new Model(); } if ( model != null ) @@ -73,28 +62,13 @@ public class V4PomRewriter implements ArtifactPomRewriter if ( !reportOnly ) { - File toParent = to.getParentFile(); - if ( !toParent.exists() ) - { - toParent.mkdirs(); - } - - FileWriter toWriter = null; - try - { - toWriter = new FileWriter( to ); - MavenXpp3Writer writer = new MavenXpp3Writer(); - writer.write( toWriter, model ); - } - finally - { - IOUtil.close( toWriter ); - } + MavenXpp3Writer writer = new MavenXpp3Writer(); + writer.write( to, model ); } } } - private void validateBasics( Model model, Artifact artifact, FileReporter reporter ) + private void validateBasics( Model model, Artifact artifact, Reporter reporter ) throws Exception { if ( StringUtils.isEmpty( model.getModelVersion() ) ) diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/transaction/RewriteTransaction.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/transaction/RewriteTransaction.java index cdc51f90c7..0cf006c25f 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/transaction/RewriteTransaction.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/transaction/RewriteTransaction.java @@ -48,8 +48,8 @@ public class RewriteTransaction File file = (File) it.next(); if ( file.exists() && !file.delete() ) { - throw new RollbackException( "[rollback] Cannot delete file: " + file + - "\nPart of transaction for artifact: {" + artifact.getId() + "}." ); + throw new RollbackException( "[rollback] Cannot delete file: " + file + + "\nPart of transaction for artifact: {" + artifact.getId() + "}." ); } } } diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/transaction/RollbackException.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/transaction/RollbackException.java index f966428bed..916ce37511 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/transaction/RollbackException.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/transaction/RollbackException.java @@ -16,7 +16,8 @@ package org.apache.maven.tools.repoclean.transaction; * limitations under the License. */ -public class RollbackException extends Exception +public class RollbackException + extends Exception { public RollbackException( String message, Throwable cause ) diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/translate/PomTranslationException.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/translate/PomTranslationException.java index 9a5cdda4e7..96b77f5e5e 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/translate/PomTranslationException.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/translate/PomTranslationException.java @@ -20,7 +20,8 @@ package org.apache.maven.tools.repoclean.translate; /** * @author jdcasey */ -public class PomTranslationException extends Exception +public class PomTranslationException + extends Exception { private final String groupId; diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/translate/PomV3ToV4Translator.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/translate/PomV3ToV4Translator.java index 570bad58bd..4c98db640a 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/translate/PomV3ToV4Translator.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/translate/PomV3ToV4Translator.java @@ -50,7 +50,8 @@ import java.util.regex.Pattern; /** * @author jdcasey */ -public class PomV3ToV4Translator extends AbstractLogEnabled +public class PomV3ToV4Translator + extends AbstractLogEnabled { public static final String ROLE = PomV3ToV4Translator.class.getName(); @@ -66,15 +67,15 @@ public class PomV3ToV4Translator extends AbstractLogEnabled String artifactId = format( v3Model.getArtifactId() ); String id = v3Model.getId(); - + if ( StringUtils.isNotEmpty( id ) ) { if ( StringUtils.isEmpty( groupId ) ) { - int plusIdx = id.indexOf("+"); - if(plusIdx > -1) + int plusIdx = id.indexOf( "+" ); + if ( plusIdx > -1 ) { - groupId = id.substring(0, plusIdx); + groupId = id.substring( 0, plusIdx ); } else { @@ -89,7 +90,7 @@ public class PomV3ToV4Translator extends AbstractLogEnabled } String version = format( v3Model.getCurrentVersion() ); - + if ( version == null ) { version = format( v3Model.getVersion() ); @@ -186,8 +187,8 @@ public class PomV3ToV4Translator extends AbstractLogEnabled if ( StringUtils.isNotEmpty( v3Model.getGumpRepositoryId() ) ) { - reporter.warn( "Ignoring gump repository id: \'" + v3Model.getGumpRepositoryId() + - "\'. This is not supported in v4 POMs." ); + reporter.warn( "Ignoring gump repository id: \'" + v3Model.getGumpRepositoryId() + + "\'. This is not supported in v4 POMs." ); } if ( notEmpty( v3Model.getVersions() ) ) @@ -261,8 +262,8 @@ public class PomV3ToV4Translator extends AbstractLogEnabled String reportPluginName = null; if ( !matcher.matches() ) { - reporter.warn( "Non-standard report name: \'" + reportName + - "\'. Using entire name for plugin artifactId." ); + reporter.warn( "Non-standard report name: \'" + reportName + + "\'. Using entire name for plugin artifactId." ); reportPluginName = reportName; } @@ -281,11 +282,11 @@ public class PomV3ToV4Translator extends AbstractLogEnabled StringBuffer info = new StringBuffer(); - info.append( "Using some contrived information for report: \'" ).append( reportName ).append( "\'.\n" ).append( - "\to groupId: \'maven\'\n" ).append( "\to artifactId: \'" ).append( reportPluginName ).append( - "\'\n" ).append( "\to version: \'1.0-SNAPSHOT\'\n" ).append( "\to goal: \'report\'\n" ).append( - "\n" ).append( - "These values were extracted using the v3 report naming convention, but may be wrong." ); + info.append( "Using some contrived information for report: \'" ).append( reportName ).append( "\'.\n" ) + .append( "\to groupId: \'maven\'\n" ).append( "\to artifactId: \'" ).append( reportPluginName ) + .append( "\'\n" ).append( "\to version: \'1.0-SNAPSHOT\'\n" ).append( "\to goal: \'report\'\n" ) + .append( "\n" ) + .append( "These values were extracted using the v3 report naming convention, but may be wrong." ); reporter.warn( info.toString() ); @@ -303,7 +304,8 @@ public class PomV3ToV4Translator extends AbstractLogEnabled } private org.apache.maven.model.Organization translateOrganization( - org.apache.maven.model.v3_0_0.Organization v3Organization, Reporter reporter ) + org.apache.maven.model.v3_0_0.Organization v3Organization, + Reporter reporter ) throws ReportWriteException { Organization organization = null; @@ -332,7 +334,8 @@ public class PomV3ToV4Translator extends AbstractLogEnabled { for ( Iterator it = v3MailingLists.iterator(); it.hasNext(); ) { - org.apache.maven.model.v3_0_0.MailingList v3List = (org.apache.maven.model.v3_0_0.MailingList) it.next(); + org.apache.maven.model.v3_0_0.MailingList v3List = (org.apache.maven.model.v3_0_0.MailingList) it + .next(); MailingList list = new MailingList(); list.setArchive( v3List.getArchive() ); list.setName( v3List.getName() ); @@ -382,7 +385,7 @@ public class PomV3ToV4Translator extends AbstractLogEnabled } private DistributionManagement translateDistributionManagement( PomKey pomKey, - org.apache.maven.model.v3_0_0.Model v3Model ) + org.apache.maven.model.v3_0_0.Model v3Model ) throws PomTranslationException { DistributionManagement distributionManagement = new DistributionManagement(); @@ -481,7 +484,8 @@ public class PomV3ToV4Translator extends AbstractLogEnabled { for ( Iterator it = v3Developers.iterator(); it.hasNext(); ) { - org.apache.maven.model.v3_0_0.Developer v3Developer = (org.apache.maven.model.v3_0_0.Developer) it.next(); + org.apache.maven.model.v3_0_0.Developer v3Developer = (org.apache.maven.model.v3_0_0.Developer) it + .next(); Developer developer = new Developer(); @@ -519,11 +523,11 @@ public class PomV3ToV4Translator extends AbstractLogEnabled { if ( StringUtils.isEmpty( groupId ) ) { - int plusIdx = id.indexOf("+"); - - if(plusIdx > -1) + int plusIdx = id.indexOf( "+" ); + + if ( plusIdx > -1 ) { - groupId = id.substring(0, plusIdx); + groupId = id.substring( 0, plusIdx ); } else { @@ -603,7 +607,8 @@ public class PomV3ToV4Translator extends AbstractLogEnabled { for ( Iterator it = v3Contributors.iterator(); it.hasNext(); ) { - org.apache.maven.model.v3_0_0.Contributor v3Contributor = (org.apache.maven.model.v3_0_0.Contributor) it.next(); + org.apache.maven.model.v3_0_0.Contributor v3Contributor = (org.apache.maven.model.v3_0_0.Contributor) it + .next(); Contributor contributor = new Contributor();