mirror of https://github.com/apache/maven.git
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
This commit is contained in:
parent
ecc12bd005
commit
099c5383c2
|
@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0;
|
|||
//- Imported classes and packages -/
|
||||
//---------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Class Branch.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0;
|
|||
//- Imported classes and packages -/
|
||||
//---------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Class Build.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0;
|
|||
//- Imported classes and packages -/
|
||||
//---------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Class Contributor.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0;
|
|||
//- Imported classes and packages -/
|
||||
//---------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Class Dependency.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0;
|
|||
//- Imported classes and packages -/
|
||||
//---------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Class Developer.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0;
|
|||
//- Imported classes and packages -/
|
||||
//---------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Class FileSet.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0;
|
|||
//- Imported classes and packages -/
|
||||
//---------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Class License.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0;
|
|||
//- Imported classes and packages -/
|
||||
//---------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Class MailingList.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0;
|
|||
//- Imported classes and packages -/
|
||||
//---------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Class Organization.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0;
|
|||
//- Imported classes and packages -/
|
||||
//---------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Class PackageGroup.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0;
|
|||
//- Imported classes and packages -/
|
||||
//---------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Class Repository.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0;
|
|||
//- Imported classes and packages -/
|
||||
//---------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Class Resource.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0;
|
|||
//- Imported classes and packages -/
|
||||
//---------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Class SourceModification.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0;
|
|||
//- Imported classes and packages -/
|
||||
//---------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Class UnitTest.
|
||||
*
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.apache.maven.model.v3_0_0;
|
|||
//- Imported classes and packages -/
|
||||
//---------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Class Version.
|
||||
*
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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|<configuration-properties-file>\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|<configuration-properties-file>\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=<hostname>\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=<hostname>\n" + "\n" );
|
||||
}
|
||||
|
||||
private static void printUsage()
|
||||
{
|
||||
System.out.println( "Required input is missing.\n\n" + "Usage:\n" +
|
||||
"--------------------------------------------------\n\n" +
|
||||
"repoclean -h|-template|<configuration-properties-file>\n" );
|
||||
System.out.println( "Required input is missing.\n\n" + "Usage:\n"
|
||||
+ "--------------------------------------------------\n\n"
|
||||
+ "repoclean -h|-template|<configuration-properties-file>\n" );
|
||||
}
|
||||
|
||||
}
|
|
@ -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() );
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -22,7 +22,8 @@ import org.apache.maven.artifact.handler.AbstractArtifactHandler;
|
|||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DtdHandler extends AbstractArtifactHandler
|
||||
public class DtdHandler
|
||||
extends AbstractArtifactHandler
|
||||
{
|
||||
public String directory()
|
||||
{
|
||||
|
|
|
@ -22,7 +22,8 @@ import org.apache.maven.artifact.handler.JarHandler;
|
|||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class EarHandler extends JarHandler
|
||||
public class EarHandler
|
||||
extends JarHandler
|
||||
{
|
||||
public String directory()
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -22,7 +22,8 @@ import org.apache.maven.artifact.handler.JarHandler;
|
|||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class RarHandler extends JarHandler
|
||||
public class RarHandler
|
||||
extends JarHandler
|
||||
{
|
||||
public String directory()
|
||||
{
|
||||
|
|
|
@ -22,7 +22,8 @@ import org.apache.maven.artifact.handler.JarHandler;
|
|||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class SarHandler extends JarHandler
|
||||
public class SarHandler
|
||||
extends JarHandler
|
||||
{
|
||||
public String directory()
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -22,7 +22,8 @@ import org.apache.maven.artifact.handler.AbstractArtifactHandler;
|
|||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class TldHandler extends AbstractArtifactHandler
|
||||
public class TldHandler
|
||||
extends AbstractArtifactHandler
|
||||
{
|
||||
public String directory()
|
||||
{
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -28,7 +28,8 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
|||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ProjectMetadata implements ArtifactMetadata
|
||||
public class ProjectMetadata
|
||||
implements ArtifactMetadata
|
||||
{
|
||||
private final Artifact artifact;
|
||||
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -27,12 +27,27 @@ 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 )
|
||||
|
|
|
@ -29,7 +29,8 @@ import java.util.StringTokenizer;
|
|||
/**
|
||||
* @author jdcasey
|
||||
*/
|
||||
public class DefaultArtifactDiscoverer extends AbstractArtifactDiscoverer
|
||||
public class DefaultArtifactDiscoverer
|
||||
extends AbstractArtifactDiscoverer
|
||||
{
|
||||
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
|
|
@ -30,7 +30,8 @@ import java.util.StringTokenizer;
|
|||
/**
|
||||
* @author jdcasey
|
||||
*/
|
||||
public class LegacyArtifactDiscoverer extends AbstractArtifactDiscoverer
|
||||
public class LegacyArtifactDiscoverer
|
||||
extends AbstractArtifactDiscoverer
|
||||
{
|
||||
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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,28 +31,24 @@ 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() )
|
||||
{
|
||||
FileReader fromReader = null;
|
||||
try
|
||||
if( from != null )
|
||||
{
|
||||
org.apache.maven.model.v3_0_0.Model v3Model = null;
|
||||
try
|
||||
{
|
||||
fromReader = new FileReader( from );
|
||||
|
||||
MavenXpp3Reader v3Reader = new MavenXpp3Reader();
|
||||
|
||||
v3Model = v3Reader.read( fromReader );
|
||||
v3Model = v3Reader.read( from );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
|
@ -68,16 +62,8 @@ public class V3PomRewriter implements ArtifactPomRewriter
|
|||
v4Model = translator.translate( v3Model, reporter );
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( fromReader );
|
||||
}
|
||||
}
|
||||
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 );
|
||||
}
|
||||
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() ) )
|
||||
|
|
|
@ -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;
|
||||
try
|
||||
{
|
||||
fromReader = new FileReader( from );
|
||||
|
||||
MavenXpp3Reader reader = new MavenXpp3Reader();
|
||||
|
||||
try
|
||||
{
|
||||
model = reader.read( fromReader );
|
||||
model = reader.read( from );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
reporter.error( "Invalid v4 POM at \'" + from + "\'. Cannot read.", e );
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( fromReader );
|
||||
}
|
||||
}
|
||||
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 );
|
||||
}
|
||||
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() ) )
|
||||
|
|
|
@ -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() + "}." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
@ -71,10 +72,10 @@ 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
|
||||
{
|
||||
|
@ -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() );
|
||||
|
@ -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("+");
|
||||
int plusIdx = id.indexOf( "+" );
|
||||
|
||||
if(plusIdx > -1)
|
||||
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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue