diff --git a/sandbox/repoclean/src/main/bash/repoclean.sh b/sandbox/repoclean/src/main/bash/repoclean.sh index 40da34437b..4530919013 100644 --- a/sandbox/repoclean/src/main/bash/repoclean.sh +++ b/sandbox/repoclean/src/main/bash/repoclean.sh @@ -15,7 +15,7 @@ case "`uname`" in CYGWIN*) cygwin=true ;; esac -if [ $cygwin ]; then +if [ $cygwin == true ]; then CP=`cygpath -pw $CP` fi @@ -28,4 +28,4 @@ if [ "$1" == "profile" ]; then shift fi -java $JAVA_OPTS -classpath ${CP} org.apache.maven.tools.repoclean.Main $* | tee repoclean-log.txt +nice -n 19 java -Xmx128M -Xms64M -Xincgc $JAVA_OPTS -classpath ${CP} org.apache.maven.tools.repoclean.Main $* | tee repoclean-log.txt diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleaner.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleaner.java index 09b7bd3896..81f8784ae6 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleaner.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleaner.java @@ -17,8 +17,10 @@ package org.apache.maven.tools.repoclean; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.construction.ArtifactConstructionSupport; +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.ArtifactDigestVerifier; import org.apache.maven.tools.repoclean.discover.ArtifactDiscoverer; import org.apache.maven.tools.repoclean.report.Reporter; @@ -182,6 +184,7 @@ public class RepositoryCleaner try { + logger.info("Rewriting " + artifacts.size() + " artifacts (Should be " + (artifacts.size() * 2) + " rewrites including POMs)."); for ( Iterator it = artifacts.iterator(); it.hasNext(); ) { Artifact artifact = (Artifact) it.next(); @@ -194,101 +197,108 @@ public class RepositoryCleaner boolean errorOccurred = false; File artifactSource = new File( sourceRepo.getBasedir(), sourceRepo.pathOf( artifact ) ); - File artifactTarget = new File( targetRepo.getBasedir(), targetRepo.pathOf( artifact ) ); - - artifact.setFile( artifactSource ); - try + if(artifactSource.exists()) { - if ( !configuration.reportOnly() ) + File artifactTarget = new File( targetRepo.getBasedir(), targetRepo.pathOf( artifact ) ); + + artifact.setFile( artifactSource ); + + try { - if(logger.isDebugEnabled()) + if ( !configuration.reportOnly() ) { - logger.debug( "sourceRepo basedir is: \'" + sourceRepo.getBasedir() + "\'" ); - logger.debug( "targetRepo basedir is: \'" + targetRepo.getBasedir() + "\'" ); - } + if(logger.isDebugEnabled()) + { + logger.debug( "sourceRepo basedir is: \'" + sourceRepo.getBasedir() + "\'" ); + logger.debug( "targetRepo basedir is: \'" + targetRepo.getBasedir() + "\'" ); + } - File targetParent = artifactTarget.getParentFile(); - if ( !targetParent.exists() ) + 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 ); + } + else { - targetParent.mkdirs(); + artifactReporter.info( "Skipping artifact copy (we're in report-only mode)." ); } + } + catch ( Exception e ) + { + repoReporter.error( "Error transferring artifact[" + artifact.getId() + + "] to the target repository.", e ); + // if we can't copy the jar over, then skip the rest. + errorOccurred = true; + } + + if ( !errorOccurred ) + { if ( logger.isDebugEnabled() ) { - logger.debug( "Copying artifact[" + artifact.getId() + "] from \'" + artifactSource - + "\' to \'" + artifactTarget + "\'." ); + logger.debug( "working on digest for artifact[" + artifact.getId() + "] with groupId: \'" + + artifact.getGroupId() + "\'" ); } - copyArtifact( artifactSource, artifactTarget, artifactReporter ); + try + { + artifactDigestVerifier.verifyDigest( artifact, artifactTarget, artifactReporter, + configuration.reportOnly() ); + } + catch ( Exception e ) + { + repoReporter.error( "Error verifying digest for artifact[" + artifact.getId() + "]", e ); + } } - else + + if ( !errorOccurred ) { - artifactReporter.info( "Skipping artifact copy (we're in report-only mode)." ); + 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 ) ); + + try + { + artifactPomRewriter.rewrite( artifact, sourcePom, targetPom, artifactReporter, + configuration.reportOnly() ); + } + catch ( Exception e ) + { + repoReporter.error( "Error rewriting POM for artifact[" + artifact.getId() + + "] into the target repository.", e ); + } } + } - catch ( Exception e ) + else { - repoReporter.error( "Error transferring artifact[" + artifact.getId() - + "] to the target repository.", e ); - - // if we can't copy the jar over, then skip the rest. - errorOccurred = true; + artifactReporter.error("Cannot find source file for artifact: \'" + artifact.getId() + "\' under path: \'" + artifactSource + "\'"); } - - if ( !errorOccurred ) - { - if ( logger.isDebugEnabled() ) - { - logger.debug( "working on digest for artifact[" + artifact.getId() + "] with groupId: \'" - + artifact.getGroupId() + "\'" ); - } - - try - { - artifactDigestVerifier.verifyDigest( artifact, artifactTarget, artifactReporter, - configuration.reportOnly() ); - } - catch ( Exception e ) - { - repoReporter.error( "Error verifying digest for artifact[" + artifact.getId() + "]", e ); - } - } - - if ( !errorOccurred ) - { - Artifact pomArtifact = buildPomArtifact( artifact ); - - artifactPomRewriter = (ArtifactPomRewriter) container.lookup( ArtifactPomRewriter.ROLE, - configuration.getSourcePomVersion() ); - - File sourcePom = new File( sourceRepositoryBase, sourceRepo.pathOf( pomArtifact ) ); - - File targetPom = new File( targetRepositoryBase, targetRepo.pathOf( pomArtifact ) ); - - try - { - artifactPomRewriter.rewrite( artifact, sourcePom, targetPom, artifactReporter, - configuration.reportOnly() ); - } - catch ( Exception e ) - { - repoReporter.error( "Error rewriting POM for artifact[" + artifact.getId() - + "] into the target repository.", e ); - } - } - + if ( artifactReporter.hasError() ) { repoReporter.warn( "Error(s) occurred while rewriting artifact: \'" + artifact.getId() + "\' or its POM." ); } - - if ( artifactReporter.hasWarning() ) - { - repoReporter.info( "Warning(s) occurred while rewriting artifact: \'" + artifact.getId() - + "\' or its POM." ); - } + } + catch(Exception e) + { + artifactReporter.error("Error while rewriting file or POM for artifact: \'" + artifact.getId() + "\'", e); } finally { @@ -308,9 +318,11 @@ public class RepositoryCleaner } } - private void copyArtifact( File artifactSource, File artifactTarget, Reporter reporter ) + private void copyArtifact( Artifact artifact, File artifactTarget, Reporter reporter ) throws IOException { + File artifactSource = artifact.getFile(); + InputStream inStream = null; OutputStream outStream = null; try @@ -342,12 +354,6 @@ public class RepositoryCleaner } } - private Artifact buildPomArtifact( Artifact artifact ) - { - return artifactConstructionSupport.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), - artifact.getVersion(), artifact.getScope(), "pom" ); - } - private File normalizeTargetRepositoryBase( String targetRepositoryPath ) { Logger logger = getLogger(); diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/DtdHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/DtdHandler.java similarity index 94% rename from sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/DtdHandler.java rename to sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/DtdHandler.java index caff183c68..fc27e5835c 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/DtdHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/DtdHandler.java @@ -1,4 +1,4 @@ -package org.apache.maven.tools.repoclean.artifact; +package org.apache.maven.tools.repoclean.artifact.handler; import org.apache.maven.artifact.handler.AbstractArtifactHandler; diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/EarHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/EarHandler.java similarity index 94% rename from sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/EarHandler.java rename to sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/EarHandler.java index dd708d6743..dcbf119c45 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/EarHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/EarHandler.java @@ -1,4 +1,4 @@ -package org.apache.maven.tools.repoclean.artifact; +package org.apache.maven.tools.repoclean.artifact.handler; import org.apache.maven.artifact.handler.JarHandler; diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/JarDistroHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/JarDistroHandler.java similarity index 93% rename from sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/JarDistroHandler.java rename to sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/JarDistroHandler.java index 43c8081b71..ba0f2ed16f 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/JarDistroHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/JarDistroHandler.java @@ -1,4 +1,4 @@ -package org.apache.maven.tools.repoclean.artifact; +package org.apache.maven.tools.repoclean.artifact.handler; /* * Copyright 2001-2005 The Apache Software Foundation. diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/LegacyPluginHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/LegacyPluginHandler.java similarity index 94% rename from sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/LegacyPluginHandler.java rename to sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/LegacyPluginHandler.java index de4b9b5cf1..9987c6fcbd 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/LegacyPluginHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/LegacyPluginHandler.java @@ -1,4 +1,4 @@ -package org.apache.maven.tools.repoclean.artifact; +package org.apache.maven.tools.repoclean.artifact.handler; import org.apache.maven.artifact.handler.AbstractArtifactHandler; diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/RarHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/RarHandler.java similarity index 94% rename from sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/RarHandler.java rename to sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/RarHandler.java index f809586ae4..c78ba4f6b3 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/RarHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/RarHandler.java @@ -1,4 +1,4 @@ -package org.apache.maven.tools.repoclean.artifact; +package org.apache.maven.tools.repoclean.artifact.handler; import org.apache.maven.artifact.handler.JarHandler; diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/SarHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/SarHandler.java similarity index 93% rename from sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/SarHandler.java rename to sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/SarHandler.java index 8f27ad8231..2e36c5853f 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/SarHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/SarHandler.java @@ -1,4 +1,4 @@ -package org.apache.maven.tools.repoclean.artifact; +package org.apache.maven.tools.repoclean.artifact.handler; import org.apache.maven.artifact.handler.JarHandler; diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/TgzDistroHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/TgzDistroHandler.java similarity index 93% rename from sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/TgzDistroHandler.java rename to sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/TgzDistroHandler.java index 1152be3c5a..c7e3a304fd 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/TgzDistroHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/TgzDistroHandler.java @@ -1,4 +1,4 @@ -package org.apache.maven.tools.repoclean.artifact; +package org.apache.maven.tools.repoclean.artifact.handler; /* * Copyright 2001-2005 The Apache Software Foundation. diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/TldHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/TldHandler.java similarity index 94% rename from sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/TldHandler.java rename to sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/TldHandler.java index c67bc5cc77..ff487e07eb 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/TldHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/TldHandler.java @@ -1,4 +1,4 @@ -package org.apache.maven.tools.repoclean.artifact; +package org.apache.maven.tools.repoclean.artifact.handler; import org.apache.maven.artifact.handler.AbstractArtifactHandler; diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/ZipDistroHandler.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/ZipDistroHandler.java similarity index 93% rename from sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/ZipDistroHandler.java rename to sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/ZipDistroHandler.java index e794d6cc35..0906ef34aa 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/ZipDistroHandler.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/handler/ZipDistroHandler.java @@ -1,4 +1,4 @@ -package org.apache.maven.tools.repoclean.artifact; +package org.apache.maven.tools.repoclean.artifact.handler; /* * Copyright 2001-2005 The Apache Software Foundation. diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/metadata/ProjectMetadata.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/metadata/ProjectMetadata.java new file mode 100644 index 0000000000..3bb9cc8958 --- /dev/null +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/metadata/ProjectMetadata.java @@ -0,0 +1,66 @@ +package org.apache.maven.tools.repoclean.artifact.metadata; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.manager.WagonManager; +import org.apache.maven.artifact.metadata.ArtifactMetadata; +import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException; +import org.apache.maven.artifact.repository.ArtifactRepository; + +/** + * Attach a POM to an artifact. + * + * @author Brett Porter + * @version $Id$ + */ +public class ProjectMetadata + implements ArtifactMetadata +{ + private final Artifact artifact; + + public ProjectMetadata( Artifact artifact) + { + this.artifact = artifact; + } + + public Artifact getArtifact() + { + return artifact; + } + + public String getFilename() + { + return getArtifact().getArtifactId() + "-" + getArtifact().getVersion() + ".pom"; + } + + public void storeInLocalRepository( ArtifactRepository localRepository ) + throws ArtifactMetadataRetrievalException + { + // not used in repoclean. + } + + public void retrieveFromRemoteRepository( ArtifactRepository remoteRepository, WagonManager wagonManager ) + { + // not used - TODO: again indicates bad design? + } + + public void setArtifact( Artifact artifact ) + { + // this should be immutable... + } +} diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/ArtifactDigestVerifier.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/ArtifactDigestVerifier.java index 805651606d..502e54c27a 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/ArtifactDigestVerifier.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/ArtifactDigestVerifier.java @@ -42,17 +42,6 @@ public class ArtifactDigestVerifier // create the digest target file from which to copy/create. File digestTargetFile = new File( artifactTarget + ".md5" ); - if(!reportOnly) - { - File targetParent = digestTargetFile.getParentFile(); - - if ( !targetParent.exists() ) - { - reporter.info( "MD5 parent directory \'" + targetParent + "\' does not exist. Creating..." ); - targetParent.mkdirs(); - } - } - boolean verified = false; // if the digest source file exists, then verify it. diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/ArtifactDigestor.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/ArtifactDigestor.java index 08fb610046..b92c4e61e5 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/ArtifactDigestor.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/ArtifactDigestor.java @@ -4,14 +4,14 @@ package org.apache.maven.tools.repoclean.digest; import org.codehaus.plexus.util.IOUtil; import java.io.BufferedInputStream; -import java.io.ByteArrayOutputStream; 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.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.Arrays; /** * @author jdcasey @@ -43,40 +43,49 @@ public class ArtifactDigestor public boolean verifyArtifactDigest( File artifactFile, File digestFile, String algorithm ) throws ArtifactDigestException { - boolean result = false; - if(artifactFile.exists() && digestFile.exists()) { byte[] generatedDigest = generateArtifactDigest( artifactFile, algorithm ); - byte[] digestFromFile = null; - + + InputStream in = null; try { - digestFromFile = readFile( digestFile ); + in = new FileInputStream( artifactFile ); + + int digestLen = generatedDigest.length; + int currentIdx = 0; + + boolean matched = true; + + int read = -1; + while ( ( read = in.read() ) > -1 ) + { + if(currentIdx >= digestLen || read != generatedDigest[currentIdx]) + { + return false; + } + } } - catch ( Exception e ) + catch ( IOException e ) { - throw new ArtifactDigestException( "Cannot read digest from file: \'" + digestFile + "\'", e ); + throw new ArtifactDigestException("Cannot verify digest for artifact file: \'" + artifactFile + "\' against digest file: \'" + digestFile + "\' using algorithm: \'" + algorithm + "\'", e); } - - result = Arrays.equals( generatedDigest, digestFromFile ); + finally + { + IOUtil.close( in ); + } + + } + else + { + return false; } - return result; + return true; } private byte[] generateArtifactDigest( File artifactFile, String algorithm ) throws ArtifactDigestException { - byte[] data = null; - try - { - data = readFile( artifactFile ); - } - catch ( IOException e ) - { - throw new ArtifactDigestException( "Error reading artifact data from: \'" + artifactFile + "\'", e ); - } - MessageDigest digest = null; try { @@ -87,14 +96,33 @@ public class ArtifactDigestor throw new ArtifactDigestException( "Cannot load digest algoritm provider.", e ); } - digest.update( data ); - + InputStream in = null; + try + { + in = new BufferedInputStream( new FileInputStream( artifactFile ) ); + + byte[] buffer = new byte[16]; + int read = -1; + while ( ( read = in.read( buffer ) ) > -1 ) + { + digest.update(buffer, 0, read); + } + } + catch ( IOException e ) + { + throw new ArtifactDigestException( "Error reading artifact data from: \'" + artifactFile + "\'", e ); + } + finally + { + IOUtil.close( in ); + } + return digest.digest(); } private void writeDigestFile( File digestFile, byte[] digestData ) throws IOException { - FileOutputStream out = null; + OutputStream out = null; try { out = new FileOutputStream( digestFile ); @@ -107,27 +135,4 @@ public class ArtifactDigestor } } - private byte[] readFile( File artifactFile ) throws IOException - { - BufferedInputStream in = null; - try - { - in = new BufferedInputStream( new FileInputStream( artifactFile ) ); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - byte[] buffer = new byte[16]; - int read = -1; - while ( ( read = in.read( buffer ) ) > -1 ) - { - baos.write( buffer, 0, read ); - } - - return baos.toByteArray(); - } - finally - { - IOUtil.close( in ); - } - } - } \ No newline at end of file diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/LegacyArtifactDiscoverer.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/LegacyArtifactDiscoverer.java index b3f3a480d7..d417981a23 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/LegacyArtifactDiscoverer.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/LegacyArtifactDiscoverer.java @@ -130,10 +130,11 @@ public class LegacyArtifactDiscoverer avceTokenList.addLast( lastAvceToken ); } - String validVersionParts = "([Dd][Ee][Vv][_.0-9]*)|" + "([Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt])|" + "([_.0-9ab]+)|" + 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 diff --git a/sandbox/repoclean/src/main/resources/META-INF/plexus/components.xml b/sandbox/repoclean/src/main/resources/META-INF/plexus/components.xml index 47df84d35b..ee91e91d98 100644 --- a/sandbox/repoclean/src/main/resources/META-INF/plexus/components.xml +++ b/sandbox/repoclean/src/main/resources/META-INF/plexus/components.xml @@ -8,7 +8,7 @@ org.apache.maven.artifact.handler.ArtifactHandler plugin - org.apache.maven.tools.repoclean.artifact.LegacyPluginHandler + org.apache.maven.tools.repoclean.artifact.handler.LegacyPluginHandler