jdcasey     2005/03/22 22:58:47

  Modified:    
sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover
                        DefaultArtifactDiscoverer.java
                        LegacyArtifactDiscoverer.java
  Log:
  o Added more filters on the excludes.
  
  Revision  Changes    Path
  1.2       +47 -36    
maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/DefaultArtifactDiscoverer.java
  
  Index: DefaultArtifactDiscoverer.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/DefaultArtifactDiscoverer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultArtifactDiscoverer.java    23 Mar 2005 04:53:30 -0000      1.1
  +++ DefaultArtifactDiscoverer.java    23 Mar 2005 06:58:47 -0000      1.2
  @@ -13,21 +13,19 @@
   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 @@
   
       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 @@
               String path = artifactPaths[i];
   
               Artifact artifact = buildArtifact( repositoryBase, path, 
reporter );
  -            
  -            if(artifact != null)
  +
  +            if ( artifact != null )
               {
                   artifacts.add( artifact );
               }
  @@ -66,38 +75,40 @@
           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 @@
                       + "\'. Cannot create Artifact instance." );
               }
           }
  -        
  +
           return result;
       }
   
  -}
  +}
  \ No newline at end of file
  
  
  
  1.2       +16 -4     
maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/LegacyArtifactDiscoverer.java
  
  Index: LegacyArtifactDiscoverer.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/LegacyArtifactDiscoverer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LegacyArtifactDiscoverer.java     23 Mar 2005 04:53:30 -0000      1.1
  +++ LegacyArtifactDiscoverer.java     23 Mar 2005 06:58:47 -0000      1.2
  @@ -43,7 +43,17 @@
   
           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 @@
               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 @@
               //    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 );
  
  
  

Reply via email to