o Added more filters on the excludes.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163671 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-03-23 06:58:47 +00:00
parent 14bb2c805a
commit 1b4723f972
2 changed files with 63 additions and 40 deletions

View File

@ -13,21 +13,19 @@ import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
/* ====================================================================
* Copyright 2001-2004 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.
* ====================================================================
/*
* ==================================================================== Copyright 2001-2004 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. ====================================================================
*/
/**
@ -39,13 +37,24 @@ public class DefaultArtifactDiscoverer
private ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
public List discoverArtifacts( File repositoryBase, Reporter reporter ) throws Exception
public List discoverArtifacts( File repositoryBase, Reporter reporter )
throws Exception
{
List artifacts = new ArrayList();
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( repositoryBase );
scanner.setExcludes( new String[] { "**/*.pom", "**/*.md5" } );
scanner.setExcludes( new String[] {
"bin/**",
"reports/**",
".maven/**",
"**/*.pom",
"**/*.md5",
"**/*snapshot-version",
"*/website/**",
"*/licenses/**",
"**/.htaccess",
"**/REPOSITORY-V*.txt" } );
scanner.scan();
@ -56,8 +65,8 @@ public class DefaultArtifactDiscoverer
String path = artifactPaths[i];
Artifact artifact = buildArtifact( repositoryBase, path, reporter );
if(artifact != null)
if ( artifact != null )
{
artifacts.add( artifact );
}
@ -66,38 +75,40 @@ public class DefaultArtifactDiscoverer
return artifacts;
}
private Artifact buildArtifact( File repositoryBase, String path, Reporter reporter ) throws Exception
private Artifact buildArtifact( File repositoryBase, String path, Reporter reporter )
throws Exception
{
Artifact result = null;
int lastDot = path.lastIndexOf('.');
if(lastDot < 0)
int lastDot = path.lastIndexOf( '.' );
if ( lastDot < 0 )
{
reporter.error( "Found potential artifact file with invalid name. Path: \'" + path + "\' doesn't seem to contain a file extension." );
reporter.error( "Found potential artifact file with invalid name. Path: \'" + path
+ "\' doesn't seem to contain a file extension." );
}
else
{
String pomPath = path.substring(0, lastDot) + ".pom";
File pomFile = new File(repositoryBase, pomPath);
if(pomFile.exists())
String pomPath = path.substring( 0, lastDot ) + ".pom";
File pomFile = new File( repositoryBase, pomPath );
if ( pomFile.exists() )
{
FileReader pomReader = null;
try
{
pomReader = new FileReader(pomFile);
pomReader = new FileReader( pomFile );
MavenXpp3Reader modelReader = new MavenXpp3Reader();
Model model = modelReader.read(pomReader);
Model model = modelReader.read( pomReader );
result = artifactConstructionSupport.createArtifact( model.getGroupId(), model.getArtifactId(),
model.getVersion(), Artifact.SCOPE_RUNTIME,
model.getPackaging() );
}
finally
{
IOUtil.close(pomReader);
IOUtil.close( pomReader );
}
}
else
@ -106,8 +117,8 @@ public class DefaultArtifactDiscoverer
+ "\'. Cannot create Artifact instance." );
}
}
return result;
}
}
}

View File

@ -43,7 +43,17 @@ public class LegacyArtifactDiscoverer
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( repositoryBase );
scanner.setExcludes( new String[] { "**/poms/*.pom", "**/*.md5" } );
scanner.setExcludes( new String[] {
"bin/**",
"reports/**",
".maven/**",
"**/poms/*.pom",
"**/*.md5",
"**/*snapshot-version",
"*/website/**",
"*/licenses/**",
"**/.htaccess",
"**/REPOSITORY-V*.txt" } );
scanner.scan();
@ -85,7 +95,7 @@ public class LegacyArtifactDiscoverer
String artifactId = matcher.group( 3 );
String version = matcher.group( 4 );
// Commenting this, since the old repo style didn't have a concept
// Commenting this, since the old repo style didn't have a concept
// of 'maven-plugin'...I've added an additional artifact handler
// specifically for this, with just enough functionality to get the
// pathing right.
@ -94,8 +104,10 @@ public class LegacyArtifactDiscoverer
// type = "maven-plugin";
//}
getLogger().debug( "Extracted artifact information from path:\n" + "groupId: \'" + groupId + "\'\n"
+ "artifactId: \'" + artifactId + "\'\n" + "type: \'" + type + "\'\n" + "version: \'" + version + "\'" );
getLogger().debug(
"Extracted artifact information from path:\n" + "groupId: \'" + groupId + "\'\n"
+ "artifactId: \'" + artifactId + "\'\n" + "type: \'" + type + "\'\n"
+ "version: \'" + version + "\'" );
result = artifactConstructionSupport.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME,
type );