mirror of https://github.com/apache/maven.git
o Added --force CLI support
o Added blacklistedPatterns to configuration file, to enhance the exclusion filter during artifact discovery with a set of non-copy-able files. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163997 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cf1937a1f1
commit
65b542741b
|
@ -30,9 +30,14 @@ import java.util.Properties;
|
||||||
*/
|
*/
|
||||||
public class Main
|
public class Main
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static final String FORCE_ARG = "--force";
|
||||||
|
|
||||||
public static void main( String[] args )
|
public static void main( String[] args )
|
||||||
{
|
{
|
||||||
|
boolean force = false;
|
||||||
|
String configFile = null;
|
||||||
|
|
||||||
if ( args.length < 1 )
|
if ( args.length < 1 )
|
||||||
{
|
{
|
||||||
printUsage();
|
printUsage();
|
||||||
|
@ -48,10 +53,36 @@ public class Main
|
||||||
printTemplate();
|
printTemplate();
|
||||||
System.exit( 0 );
|
System.exit( 0 );
|
||||||
}
|
}
|
||||||
|
// up the ante, and let's try to see if there's a --force option.
|
||||||
|
else if ( args.length == 2 )
|
||||||
|
{
|
||||||
|
if(FORCE_ARG.equals(args[0]))
|
||||||
|
{
|
||||||
|
force = true;
|
||||||
|
configFile = args[1];
|
||||||
|
}
|
||||||
|
else if(FORCE_ARG.equals(args[1]))
|
||||||
|
{
|
||||||
|
force = true;
|
||||||
|
configFile = args[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.out.println("Invalid argument list: \'" + args[0] + " " + args[1]);
|
||||||
|
printUsage();
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
configFile = args[0];
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RepositoryCleanerConfiguration config = buildConfig( args[0] );
|
RepositoryCleanerConfiguration config = buildConfig( configFile );
|
||||||
|
|
||||||
|
config.setForce(force);
|
||||||
|
|
||||||
launch( config );
|
launch( config );
|
||||||
|
|
||||||
|
@ -108,6 +139,7 @@ public class Main
|
||||||
config.setTargetRepositoryPath( props.getProperty( "targetRepositoryPath" ) );
|
config.setTargetRepositoryPath( props.getProperty( "targetRepositoryPath" ) );
|
||||||
config.setTargetRepositoryLayout( props.getProperty( "targetRepositoryLayout", "default" ) );
|
config.setTargetRepositoryLayout( props.getProperty( "targetRepositoryLayout", "default" ) );
|
||||||
config.setReportsPath( props.getProperty( "reportsPath" ) );
|
config.setReportsPath( props.getProperty( "reportsPath" ) );
|
||||||
|
config.setBlacklistedPatterns( props.getProperty( "blacklistedPatterns" ) );
|
||||||
config.setReportOnly( Boolean.valueOf( props.getProperty( "reportOnly" ) ).booleanValue() );
|
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() );
|
||||||
|
|
|
@ -67,9 +67,9 @@ public class RepositoryCleaner
|
||||||
private ArtifactRepositoryLayout bridgingLayout;
|
private ArtifactRepositoryLayout bridgingLayout;
|
||||||
|
|
||||||
private MailSender mailSender;
|
private MailSender mailSender;
|
||||||
|
|
||||||
private ArtifactIndexer artifactIndexer;
|
private ArtifactIndexer artifactIndexer;
|
||||||
|
|
||||||
private ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
|
private ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
|
||||||
|
|
||||||
private PlexusContainer container;
|
private PlexusContainer container;
|
||||||
|
@ -101,9 +101,8 @@ public class RepositoryCleaner
|
||||||
List artifacts = null;
|
List artifacts = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
artifactDiscoverer = (ArtifactDiscoverer) container.lookup(
|
artifactDiscoverer = (ArtifactDiscoverer) container.lookup( ArtifactDiscoverer.ROLE, configuration
|
||||||
ArtifactDiscoverer.ROLE,
|
.getSourceRepositoryLayout() );
|
||||||
configuration.getSourceRepositoryLayout() );
|
|
||||||
|
|
||||||
if ( logger.isInfoEnabled() )
|
if ( logger.isInfoEnabled() )
|
||||||
{
|
{
|
||||||
|
@ -112,7 +111,8 @@ public class RepositoryCleaner
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
artifacts = artifactDiscoverer.discoverArtifacts( sourceRepositoryBase, repoReporter );
|
artifacts = artifactDiscoverer.discoverArtifacts( sourceRepositoryBase, repoReporter,
|
||||||
|
configuration.getBlacklistedPatterns() );
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
|
@ -134,16 +134,16 @@ public class RepositoryCleaner
|
||||||
ArtifactRepositoryLayout targetLayout = null;
|
ArtifactRepositoryLayout targetLayout = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
sourceLayout = (ArtifactRepositoryLayout) container.lookup(
|
sourceLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE,
|
||||||
ArtifactRepositoryLayout.ROLE,
|
configuration
|
||||||
configuration.getSourceRepositoryLayout() );
|
.getSourceRepositoryLayout() );
|
||||||
|
|
||||||
ArtifactRepository sourceRepo = new ArtifactRepository( "source", "file://"
|
ArtifactRepository sourceRepo = new ArtifactRepository( "source", "file://"
|
||||||
+ sourceRepositoryBase.getAbsolutePath(), sourceLayout );
|
+ sourceRepositoryBase.getAbsolutePath(), sourceLayout );
|
||||||
|
|
||||||
targetLayout = (ArtifactRepositoryLayout) container.lookup(
|
targetLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE,
|
||||||
ArtifactRepositoryLayout.ROLE,
|
configuration
|
||||||
configuration.getTargetRepositoryLayout() );
|
.getTargetRepositoryLayout() );
|
||||||
|
|
||||||
ArtifactRepository targetRepo = new ArtifactRepository( "target", "file://"
|
ArtifactRepository targetRepo = new ArtifactRepository( "target", "file://"
|
||||||
+ targetRepositoryBase.getAbsolutePath(), targetLayout );
|
+ targetRepositoryBase.getAbsolutePath(), targetLayout );
|
||||||
|
@ -154,7 +154,7 @@ public class RepositoryCleaner
|
||||||
}
|
}
|
||||||
|
|
||||||
artifactIndexer.writeAritfactIndex( artifacts, targetRepositoryBase );
|
artifactIndexer.writeAritfactIndex( artifacts, targetRepositoryBase );
|
||||||
|
|
||||||
rewriteArtifactsAndPoms( artifacts, sourceRepo, targetRepo, configuration, reportsBase,
|
rewriteArtifactsAndPoms( artifacts, sourceRepo, targetRepo, configuration, reportsBase,
|
||||||
sourceRepositoryBase, targetRepositoryBase, repoReporter );
|
sourceRepositoryBase, targetRepositoryBase, repoReporter );
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,8 @@ public class RepositoryCleaner
|
||||||
|
|
||||||
if ( repoReporter.hasWarning() && logger.isWarnEnabled() )
|
if ( repoReporter.hasWarning() && logger.isWarnEnabled() )
|
||||||
{
|
{
|
||||||
logger.warn( "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." );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( repoReporter.hasError() )
|
if ( repoReporter.hasError() )
|
||||||
|
@ -245,12 +246,12 @@ public class RepositoryCleaner
|
||||||
Logger logger = getLogger();
|
Logger logger = getLogger();
|
||||||
|
|
||||||
ArtifactPomRewriter artifactPomRewriter = null;
|
ArtifactPomRewriter artifactPomRewriter = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
logger.info( "Rewriting up to " + artifacts.size() + " artifacts (Should be " + ( artifacts.size() * 2 )
|
logger.info( "Rewriting up to " + artifacts.size() + " artifacts (Should be " + ( artifacts.size() * 2 )
|
||||||
+ " rewrites including POMs)." );
|
+ " rewrites including POMs)." );
|
||||||
|
|
||||||
int actualRewriteCount = 0;
|
int actualRewriteCount = 0;
|
||||||
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
|
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
|
@ -273,10 +274,10 @@ public class RepositoryCleaner
|
||||||
boolean targetMissingOrOlder = !artifactTarget.exists()
|
boolean targetMissingOrOlder = !artifactTarget.exists()
|
||||||
|| artifactTarget.lastModified() < artifactSource.lastModified();
|
|| artifactTarget.lastModified() < artifactSource.lastModified();
|
||||||
|
|
||||||
if ( artifactSource.exists() && targetMissingOrOlder )
|
if ( artifactSource.exists() && ( configuration.force() || targetMissingOrOlder ) )
|
||||||
{
|
{
|
||||||
actualRewriteCount++;
|
actualRewriteCount++;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( !configuration.reportOnly() )
|
if ( !configuration.reportOnly() )
|
||||||
|
@ -334,21 +335,21 @@ public class RepositoryCleaner
|
||||||
{
|
{
|
||||||
ArtifactMetadata pom = new ProjectMetadata( artifact );
|
ArtifactMetadata pom = new ProjectMetadata( artifact );
|
||||||
|
|
||||||
artifactPomRewriter = (ArtifactPomRewriter) container.lookup(
|
artifactPomRewriter = (ArtifactPomRewriter) container.lookup( ArtifactPomRewriter.ROLE,
|
||||||
ArtifactPomRewriter.ROLE,
|
configuration
|
||||||
configuration.getSourcePomVersion() );
|
.getSourcePomVersion() );
|
||||||
|
|
||||||
File sourcePom = new File( sourceRepositoryBase, sourceRepo.pathOfMetadata( pom ) );
|
File sourcePom = new File( sourceRepositoryBase, sourceRepo.pathOfMetadata( pom ) );
|
||||||
|
|
||||||
File targetPom = new File( targetRepositoryBase, targetRepo.pathOfMetadata( pom ) );
|
File targetPom = new File( targetRepositoryBase, targetRepo.pathOfMetadata( pom ) );
|
||||||
|
|
||||||
File bridgedTargetPom = new File( targetRepositoryBase, bridgingLayout.pathOfMetadata( pom ) );
|
File bridgedTargetPom = new File( targetRepositoryBase, bridgingLayout.pathOfMetadata( pom ) );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
artifactPomRewriter.rewrite( artifact, sourcePom, targetPom, artifactReporter,
|
artifactPomRewriter.rewrite( artifact, sourcePom, targetPom, artifactReporter,
|
||||||
configuration.reportOnly() );
|
configuration.reportOnly() );
|
||||||
|
|
||||||
bridgePomLocations( targetPom, bridgedTargetPom, artifactReporter );
|
bridgePomLocations( targetPom, bridgedTargetPom, artifactReporter );
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
|
@ -359,10 +360,11 @@ public class RepositoryCleaner
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if( !targetMissingOrOlder )
|
else if ( !targetMissingOrOlder )
|
||||||
{
|
{
|
||||||
artifactReporter.warn( "Target file for artifact is present and not stale. (Artifact: \'" + artifact.getId()
|
artifactReporter.warn( "Target file for artifact is present and not stale. (Artifact: \'"
|
||||||
+ "\' in path: \'" + artifactSource + "\' with target path: " + artifactTarget + ")." );
|
+ artifact.getId() + "\' in path: \'" + artifactSource + "\' with target path: "
|
||||||
|
+ artifactTarget + ")." );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -389,8 +391,9 @@ public class RepositoryCleaner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Actual number of artifacts rewritten: " + actualRewriteCount + " (" + (actualRewriteCount * 2) + " including POMs).");
|
logger.info( "Actual number of artifacts rewritten: " + actualRewriteCount + " ("
|
||||||
|
+ ( actualRewriteCount * 2 ) + " including POMs)." );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -401,27 +404,29 @@ public class RepositoryCleaner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bridgePomLocations( File targetPom, File bridgedTargetPom, Reporter reporter ) throws IOException, ReportWriteException
|
private void bridgePomLocations( File targetPom, File bridgedTargetPom, Reporter reporter )
|
||||||
|
throws IOException, ReportWriteException
|
||||||
{
|
{
|
||||||
if(targetPom.equals(bridgedTargetPom))
|
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.");
|
reporter.warn( "Cannot create legacy-compatible copy of POM at: " + targetPom
|
||||||
|
+ "; legacy-compatible path is the same as the converted POM itself." );
|
||||||
}
|
}
|
||||||
|
|
||||||
FileInputStream in = null;
|
FileInputStream in = null;
|
||||||
FileOutputStream out = null;
|
FileOutputStream out = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
in = new FileInputStream(targetPom);
|
in = new FileInputStream( targetPom );
|
||||||
out = new FileOutputStream(bridgedTargetPom);
|
out = new FileOutputStream( bridgedTargetPom );
|
||||||
|
|
||||||
IOUtil.copy(in, out);
|
IOUtil.copy( in, out );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
IOUtil.close(in);
|
IOUtil.close( in );
|
||||||
IOUtil.close(out);
|
IOUtil.close( out );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,7 +543,8 @@ public class RepositoryCleaner
|
||||||
return reportsBase;
|
return reportsBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void contextualize( Context context ) throws ContextException
|
public void contextualize( Context context )
|
||||||
|
throws ContextException
|
||||||
{
|
{
|
||||||
this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,8 @@ public class RepositoryCleanerConfiguration
|
||||||
|
|
||||||
private boolean force;
|
private boolean force;
|
||||||
|
|
||||||
|
private String blacklistedPatterns;
|
||||||
|
|
||||||
public void setSourceRepositoryPath( String sourceRepositoryPath )
|
public void setSourceRepositoryPath( String sourceRepositoryPath )
|
||||||
{
|
{
|
||||||
this.sourceRepositoryPath = sourceRepositoryPath;
|
this.sourceRepositoryPath = sourceRepositoryPath;
|
||||||
|
@ -190,4 +192,14 @@ public class RepositoryCleanerConfiguration
|
||||||
{
|
{
|
||||||
this.force = force;
|
this.force = force;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBlacklistedPatterns( String blacklistedPatterns )
|
||||||
|
{
|
||||||
|
this.blacklistedPatterns = blacklistedPatterns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBlacklistedPatterns()
|
||||||
|
{
|
||||||
|
return blacklistedPatterns;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
||||||
public interface ArtifactDiscoverer
|
public interface ArtifactDiscoverer
|
||||||
{
|
{
|
||||||
public static final String ROLE = ArtifactDiscoverer.class.getName();
|
public static final String ROLE = ArtifactDiscoverer.class.getName();
|
||||||
|
|
||||||
public static final String[] STANDARD_DISCOVERY_EXCLUDES = {
|
public static final String[] STANDARD_DISCOVERY_EXCLUDES = {
|
||||||
"bin/**",
|
"bin/**",
|
||||||
"reports/**",
|
"reports/**",
|
||||||
|
@ -39,9 +39,9 @@ public interface ArtifactDiscoverer
|
||||||
"**/.htaccess",
|
"**/.htaccess",
|
||||||
"**/*.html",
|
"**/*.html",
|
||||||
"**/*.asc",
|
"**/*.asc",
|
||||||
"**/*.txt"
|
"**/*.txt" };
|
||||||
};
|
|
||||||
|
List discoverArtifacts( File repositoryBase, FileReporter reporter, String blacklistedPatterns )
|
||||||
|
throws Exception;
|
||||||
|
|
||||||
List discoverArtifacts( File repositoryBase, FileReporter reporter ) throws Exception;
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -36,14 +36,29 @@ public class DefaultArtifactDiscoverer
|
||||||
|
|
||||||
private ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
|
private ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
|
||||||
|
|
||||||
public List discoverArtifacts( File repositoryBase, FileReporter reporter )
|
public List discoverArtifacts( File repositoryBase, FileReporter reporter, String blacklistedPatterns )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
List artifacts = new ArrayList();
|
List artifacts = new ArrayList();
|
||||||
|
|
||||||
|
String[] blacklisted = null;
|
||||||
|
if ( blacklistedPatterns != null && blacklistedPatterns.length() > 0 )
|
||||||
|
{
|
||||||
|
blacklisted = blacklistedPatterns.split( "," );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
blacklisted = new String[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] allExcludes = new String[STANDARD_DISCOVERY_EXCLUDES.length + blacklisted.length];
|
||||||
|
|
||||||
|
System.arraycopy( STANDARD_DISCOVERY_EXCLUDES, 0, allExcludes, 0, STANDARD_DISCOVERY_EXCLUDES.length );
|
||||||
|
System.arraycopy( blacklisted, 0, allExcludes, 0, blacklisted.length );
|
||||||
|
|
||||||
DirectoryScanner scanner = new DirectoryScanner();
|
DirectoryScanner scanner = new DirectoryScanner();
|
||||||
scanner.setBasedir( repositoryBase );
|
scanner.setBasedir( repositoryBase );
|
||||||
scanner.setExcludes( STANDARD_DISCOVERY_EXCLUDES );
|
scanner.setExcludes( allExcludes );
|
||||||
|
|
||||||
scanner.scan();
|
scanner.scan();
|
||||||
|
|
||||||
|
|
|
@ -38,14 +38,38 @@ public class LegacyArtifactDiscoverer
|
||||||
|
|
||||||
private ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
|
private ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
|
||||||
|
|
||||||
public List discoverArtifacts( File repositoryBase, FileReporter reporter )
|
public List discoverArtifacts( File repositoryBase, FileReporter reporter, String blacklistedPatterns )
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
List artifacts = new ArrayList();
|
List artifacts = new ArrayList();
|
||||||
|
|
||||||
|
String[] blacklisted = null;
|
||||||
|
if ( blacklistedPatterns != null && blacklistedPatterns.length() > 0 )
|
||||||
|
{
|
||||||
|
blacklisted = blacklistedPatterns.split( "," );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
blacklisted = new String[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] allExcludes = null;
|
||||||
|
|
||||||
|
if ( blacklisted != null && blacklisted.length > 0 )
|
||||||
|
{
|
||||||
|
allExcludes = new String[STANDARD_DISCOVERY_EXCLUDES.length + blacklisted.length ];
|
||||||
|
|
||||||
|
System.arraycopy( STANDARD_DISCOVERY_EXCLUDES, 0, allExcludes, 0, STANDARD_DISCOVERY_EXCLUDES.length );
|
||||||
|
System.arraycopy( blacklisted, 0, allExcludes, STANDARD_DISCOVERY_EXCLUDES.length, blacklisted.length );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
allExcludes = STANDARD_DISCOVERY_EXCLUDES;
|
||||||
|
}
|
||||||
|
|
||||||
DirectoryScanner scanner = new DirectoryScanner();
|
DirectoryScanner scanner = new DirectoryScanner();
|
||||||
scanner.setBasedir( repositoryBase );
|
scanner.setBasedir( repositoryBase );
|
||||||
scanner.setExcludes( STANDARD_DISCOVERY_EXCLUDES );
|
scanner.setExcludes( allExcludes );
|
||||||
|
|
||||||
scanner.scan();
|
scanner.scan();
|
||||||
|
|
||||||
|
@ -205,20 +229,25 @@ public class LegacyArtifactDiscoverer
|
||||||
|
|
||||||
tokensIterated++;
|
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.
|
// Now, restore the proper ordering so we can build the artifactId.
|
||||||
Collections.reverse( avceTokenList );
|
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
|
// if we didn't find a version, then punt. Use the last token
|
||||||
// as the version, and set the classifier empty.
|
// as the version, and set the classifier empty.
|
||||||
if ( versionBuffer.length() < 1 )
|
if ( versionBuffer.length() < 1 )
|
||||||
{
|
{
|
||||||
int lastIdx = avceTokenList.size() - 1;
|
int lastIdx = avceTokenList.size() - 1;
|
||||||
|
|
||||||
versionBuffer.append( avceTokenList.get( lastIdx ) );
|
versionBuffer.append( avceTokenList.get( lastIdx ) );
|
||||||
avceTokenList.remove( lastIdx );
|
avceTokenList.remove( lastIdx );
|
||||||
|
|
||||||
|
@ -226,14 +255,14 @@ public class LegacyArtifactDiscoverer
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getLogger().debug("Removing " + tokensIterated + " tokens from avce token list.");
|
getLogger().debug( "Removing " + tokensIterated + " tokens from avce token list." );
|
||||||
|
|
||||||
// if everything is kosher, then pop off all the classifier and
|
// if everything is kosher, then pop off all the classifier and
|
||||||
// version tokens, leaving the naked artifact id in the list.
|
// 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);
|
getLogger().debug( "Now, remainder of avce token list is:\n" + avceTokenList );
|
||||||
|
|
||||||
StringBuffer artifactIdBuffer = new StringBuffer();
|
StringBuffer artifactIdBuffer = new StringBuffer();
|
||||||
|
|
||||||
|
@ -270,16 +299,16 @@ public class LegacyArtifactDiscoverer
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger().debug(
|
getLogger().debug(
|
||||||
"Extracted artifact information from path:\n" + "groupId: \'" + groupId + "\'\n"
|
"Extracted artifact information from path:\n" + "groupId: \'" + groupId + "\'\n"
|
||||||
+ "artifactId: \'" + artifactId + "\'\n" + "type: \'" + type + "\'\n" + "version: \'"
|
+ "artifactId: \'" + artifactId + "\'\n" + "type: \'" + type + "\'\n" + "version: \'"
|
||||||
+ version + "\'\n" + "classifier: \'" + classifierBuffer.toString() + "\'" );
|
+ version + "\'\n" + "classifier: \'" + classifierBuffer.toString() + "\'" );
|
||||||
|
|
||||||
Artifact result = null;
|
Artifact result = null;
|
||||||
|
|
||||||
if ( classifierBuffer.length() > 0 )
|
if ( classifierBuffer.length() > 0 )
|
||||||
{
|
{
|
||||||
getLogger().debug("Creating artifact with classifier.");
|
getLogger().debug( "Creating artifact with classifier." );
|
||||||
|
|
||||||
result = artifactConstructionSupport.createArtifactWithClassifier( groupId, artifactId, version,
|
result = artifactConstructionSupport.createArtifactWithClassifier( groupId, artifactId, version,
|
||||||
Artifact.SCOPE_RUNTIME, type,
|
Artifact.SCOPE_RUNTIME, type,
|
||||||
classifierBuffer.toString() );
|
classifierBuffer.toString() );
|
||||||
|
@ -290,7 +319,9 @@ public class LegacyArtifactDiscoverer
|
||||||
type );
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue