From 84e67faf308116aaea0d7e84264a415f75a46a00 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Wed, 20 Apr 2005 22:10:24 +0000 Subject: [PATCH] o Added support for weeding out potential artifacts that don't have an extension matching the '...s' pattern in the legacy layout (eg. things in '/jars/' that don't have a .jar extension). o Added artifacts to my local testing repository (which I will be sync'ing with the one on beaver) to satisfy the dotted groupId, the no-extension test, the '.txt' extension test. o not sure what to do with the last test-case in MNG-312, though, given that I thought we decided not to convert distributions, and the classifiers currently only happen in distros. Will take this discussion to jira, though. PR: MNG-312 git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163988 13f79535-47bb-0310-9956-ffa450edef68 --- .../discover/ArtifactDiscoverer.java | 3 +- .../discover/LegacyArtifactDiscoverer.java | 46 ++++++++++++------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/ArtifactDiscoverer.java b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/ArtifactDiscoverer.java index b8b9377dab..ea481df232 100644 --- a/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/ArtifactDiscoverer.java +++ b/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/ArtifactDiscoverer.java @@ -39,8 +39,7 @@ public interface ArtifactDiscoverer "**/.htaccess", "**/*.html", "**/*.asc", - "**/*.txt", - "**/REPOSITORY-V*.txt" + "**/*.txt" }; List discoverArtifacts( File repositoryBase, FileReporter reporter ) throws Exception; 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 1616aa53ce..37d6dfe01d 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 @@ -124,18 +124,32 @@ public class LegacyArtifactDiscoverer if ( extPos > 0 ) { - lastAvceToken = lastAvceToken.substring( 0, extPos ); - } + String ext = lastAvceToken.substring( extPos + 1 ); + if ( type.equals( ext ) ) + { + lastAvceToken = lastAvceToken.substring( 0, extPos ); - avceTokenList.addLast( lastAvceToken ); + avceTokenList.addLast( lastAvceToken ); + } + else + { + reporter + .warn( "Artifact path: \'" + + path + + "\' does not match naming convention. Cannot reliably extract artifact information from path." ); + + return null; + } + } } - 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. @@ -211,16 +225,16 @@ public class LegacyArtifactDiscoverer } String artifactId = artifactIdBuffer.toString(); - - int lastVersionCharIdx = versionBuffer.length() -1; - if(lastVersionCharIdx > -1 && versionBuffer.charAt(lastVersionCharIdx) == '-') + + int lastVersionCharIdx = versionBuffer.length() - 1; + if ( lastVersionCharIdx > -1 && versionBuffer.charAt( lastVersionCharIdx ) == '-' ) { - versionBuffer.setLength(lastVersionCharIdx); + versionBuffer.setLength( lastVersionCharIdx ); } - + String version = versionBuffer.toString(); - - if(version.length() < 1) + + if ( version.length() < 1 ) { version = null; }