maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject cvs commit: maven-components/sandbox/repoclean pom.xml install.sh
Date Fri, 01 Apr 2005 00:24:45 GMT
jdcasey     2005/03/31 16:24:45

  Modified:    sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover
                        DefaultArtifactDiscoverer.java
                        LegacyArtifactDiscoverer.java
                        ArtifactDiscoverer.java
               sandbox/repoclean/src/main/resources/META-INF/plexus
                        components.xml
               maven-artifact/src/main/java/org/apache/maven/artifact/construction
                        ArtifactConstructionSupport.java
               sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/report
                        Reporter.java
               sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite
                        V3PomRewriter.java V4PomRewriter.java
               sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean
                        RepositoryCleaner.java Main.java
               sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/translate
                        PomV3ToV4Translator.java
               sandbox/repoclean pom.xml install.sh
  Added:       sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact
                        DtdHandler.java TldHandler.java SarHandler.java
                        TgzDistroHandler.java EarHandler.java
                        JarDistroHandler.java ZipDistroHandler.java
                        RarHandler.java
  Log:
  o Reworked the artifact parsing code for the legacy artifact discoverer.
  o Getting OutOfMemoryError when running against ibiblio-v1.
  
  Revision  Changes    Path
  1.1                  maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/DtdHandler.java
  
  Index: DtdHandler.java
  ===================================================================
  package org.apache.maven.tools.repoclean.artifact;
  
  import org.apache.maven.artifact.handler.AbstractArtifactHandler;
  
  /*
   * 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.
   */
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: DtdHandler.java,v 1.1 2005/04/01 00:24:44 jdcasey Exp $
   */
  public class DtdHandler
      extends AbstractArtifactHandler
  {
      public String directory()
      {
          return "dtds";
      }
  
  //    public String packageGoal()
  //    {
  //        return "ejb:ejb";
  //    }
  }
  
  
  
  1.1                  maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/TldHandler.java
  
  Index: TldHandler.java
  ===================================================================
  package org.apache.maven.tools.repoclean.artifact;
  
  import org.apache.maven.artifact.handler.AbstractArtifactHandler;
  
  /*
   * 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.
   */
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: TldHandler.java,v 1.1 2005/04/01 00:24:44 jdcasey Exp $
   */
  public class TldHandler
      extends AbstractArtifactHandler
  {
      public String directory()
      {
          return "tlds";
      }
  
  //    public String packageGoal()
  //    {
  //        return "ejb:ejb";
  //    }
  }
  
  
  
  1.1                  maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/SarHandler.java
  
  Index: SarHandler.java
  ===================================================================
  package org.apache.maven.tools.repoclean.artifact;
  
  import org.apache.maven.artifact.handler.JarHandler;
  
  /*
   * 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.
   */
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: SarHandler.java,v 1.1 2005/04/01 00:24:44 jdcasey Exp $
   */
  public class SarHandler
      extends JarHandler
  {
      public String directory()
      {
          return "sars";
      }
  
  }
  
  
  
  1.1                  maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/TgzDistroHandler.java
  
  Index: TgzDistroHandler.java
  ===================================================================
  package org.apache.maven.tools.repoclean.artifact;
  
  /*
   * 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.handler.AbstractArtifactHandler;
  
  /**
   * @author jdcasey
   */
  public class TgzDistroHandler
      extends AbstractArtifactHandler
  {
  
      public String directory()
      {
          return "distributions";
      }
  
      public String extension()
      {
          return "tar.gz";
      }
  }
  
  
  1.1                  maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/EarHandler.java
  
  Index: EarHandler.java
  ===================================================================
  package org.apache.maven.tools.repoclean.artifact;
  
  import org.apache.maven.artifact.handler.JarHandler;
  
  /*
   * 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.
   */
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: EarHandler.java,v 1.1 2005/04/01 00:24:44 jdcasey Exp $
   */
  public class EarHandler
      extends JarHandler
  {
      public String directory()
      {
          return "ears";
      }
  
      public String packageGoal()
      {
          return "ear:ear";
      }
  }
  
  
  
  1.1                  maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/JarDistroHandler.java
  
  Index: JarDistroHandler.java
  ===================================================================
  package org.apache.maven.tools.repoclean.artifact;
  
  /*
   * 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.handler.AbstractArtifactHandler;
  
  /**
   * @author jdcasey
   */
  public class JarDistroHandler
      extends AbstractArtifactHandler
  {
  
      public String directory()
      {
          return "distributions";
      }
  
  }
  
  
  1.1                  maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/ZipDistroHandler.java
  
  Index: ZipDistroHandler.java
  ===================================================================
  package org.apache.maven.tools.repoclean.artifact;
  
  /*
   * 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.handler.AbstractArtifactHandler;
  
  /**
   * @author jdcasey
   */
  public class ZipDistroHandler
      extends AbstractArtifactHandler
  {
  
      public String directory()
      {
          return "distributions";
      }
  
      public String extension()
      {
          return "zip";
      }
  }
  
  
  1.1                  maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/artifact/RarHandler.java
  
  Index: RarHandler.java
  ===================================================================
  package org.apache.maven.tools.repoclean.artifact;
  
  import org.apache.maven.artifact.handler.JarHandler;
  
  /*
   * 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.
   */
  
  /**
   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
   * @version $Id: RarHandler.java,v 1.1 2005/04/01 00:24:44 jdcasey Exp $
   */
  public class RarHandler
      extends JarHandler
  {
      public String directory()
      {
          return "rars";
      }
  
      public String packageGoal()
      {
          return "rar:rar";
      }
  }
  
  
  
  1.3       +3 -14     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultArtifactDiscoverer.java	23 Mar 2005 06:58:47 -0000	1.2
  +++ DefaultArtifactDiscoverer.java	1 Apr 2005 00:24:44 -0000	1.3
  @@ -14,8 +14,7 @@
   import java.util.List;
   
   /*
  - * ==================================================================== Copyright 2001-2004 The
  - * Apache Software Foundation.
  + * 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
  @@ -25,7 +24,7 @@
    * 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. ====================================================================
  + * the License.
    */
   
   /**
  @@ -44,17 +43,7 @@
   
           DirectoryScanner scanner = new DirectoryScanner();
           scanner.setBasedir( repositoryBase );
  -        scanner.setExcludes( new String[] {
  -            "bin/**",
  -            "reports/**",
  -            ".maven/**",
  -            "**/*.pom",
  -            "**/*.md5",
  -            "**/*snapshot-version",
  -            "*/website/**",
  -            "*/licenses/**",
  -            "**/.htaccess",
  -            "**/REPOSITORY-V*.txt" } );
  +        scanner.setExcludes( STANDARD_DISCOVERY_EXCLUDES );
   
           scanner.scan();
   
  
  
  
  1.3       +157 -44   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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LegacyArtifactDiscoverer.java	23 Mar 2005 06:58:47 -0000	1.2
  +++ LegacyArtifactDiscoverer.java	1 Apr 2005 00:24:44 -0000	1.3
  @@ -1,8 +1,7 @@
   package org.apache.maven.tools.repoclean.discover;
   
   /*
  - * ==================================================================== Copyright 2001-2004 The
  - * Apache Software Foundation.
  + * 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
  @@ -12,7 +11,7 @@
    * 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. ====================================================================
  + * the License.
    */
   
   import org.apache.maven.artifact.Artifact;
  @@ -23,9 +22,11 @@
   
   import java.io.File;
   import java.util.ArrayList;
  +import java.util.Collections;
  +import java.util.Iterator;
  +import java.util.LinkedList;
   import java.util.List;
  -import java.util.regex.Matcher;
  -import java.util.regex.Pattern;
  +import java.util.StringTokenizer;
   
   /**
    * @author jdcasey
  @@ -38,22 +39,13 @@
       private ArtifactConstructionSupport artifactConstructionSupport = new ArtifactConstructionSupport();
   
       public List discoverArtifacts( File repositoryBase, Reporter reporter )
  +        throws Exception
       {
           List artifacts = new ArrayList();
   
           DirectoryScanner scanner = new DirectoryScanner();
           scanner.setBasedir( repositoryBase );
  -        scanner.setExcludes( new String[] {
  -            "bin/**",
  -            "reports/**",
  -            ".maven/**",
  -            "**/poms/*.pom",
  -            "**/*.md5",
  -            "**/*snapshot-version",
  -            "*/website/**",
  -            "*/licenses/**",
  -            "**/.htaccess",
  -            "**/REPOSITORY-V*.txt" } );
  +        scanner.setExcludes( STANDARD_DISCOVERY_EXCLUDES );
   
           scanner.scan();
   
  @@ -74,46 +66,167 @@
       }
   
       private Artifact buildArtifact( String path, Reporter reporter )
  +        throws Exception
       {
  -        Artifact result = null;
  +        StringTokenizer tokens = new StringTokenizer( path, "/" );
   
  -        // TODO: Need to add more test scenarios to the unit test for this
  -        // pattern.
  -        // I'm not convinced that this will catch everything.
  -        Pattern pathInfoPattern = Pattern.compile( "(.+)\\/(.+)s\\/([-a-zA-Z0-9]+)-([0-9]+[-.0-9a-zA-Z]+)\\..+" );
  +        int numberOfTokens = tokens.countTokens();
   
  -        Matcher matcher = pathInfoPattern.matcher( path );
  -        if ( !matcher.matches() )
  +        if ( numberOfTokens != 3 )
           {
               reporter.info( "Artifact path: \'" + path
                   + "\' does not match naming convention. Cannot reliably extract artifact information from path." );
  +
  +            return null;
  +        }
  +
  +        String groupId = tokens.nextToken();
  +
  +        String type = tokens.nextToken();
  +
  +        if ( type.endsWith( "s" ) )
  +        {
  +            type = type.substring( 0, type.length() - 1 );
  +        }
  +
  +        // contains artifactId, version, classifier, and extension.
  +        String avceGlob = tokens.nextToken();
  +
  +        LinkedList avceTokenList = new LinkedList();
  +
  +        StringTokenizer avceTokenizer = new StringTokenizer( avceGlob, "-" );
  +        while ( avceTokenizer.hasMoreTokens() )
  +        {
  +            avceTokenList.addLast( avceTokenizer.nextToken() );
  +        }
  +
  +        String lastAvceToken = (String) avceTokenList.removeLast();
  +
  +        if ( lastAvceToken.endsWith( ".tar.gz" ) )
  +        {
  +            type = "distribution-tgz";
  +
  +            lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".tar.gz".length() );
  +
  +            avceTokenList.addLast( lastAvceToken );
  +        }
  +        else if ( lastAvceToken.endsWith( ".zip" ) )
  +        {
  +            type = "distribution-zip";
  +
  +            lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".zip".length() );
  +
  +            avceTokenList.addLast( lastAvceToken );
           }
           else
           {
  -            String groupId = matcher.group( 1 );
  -            String type = matcher.group( 2 );
  -            String artifactId = matcher.group( 3 );
  -            String version = matcher.group( 4 );
  -
  -            // 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.
  -            //if ( "plugin".equals( type ) )
  -            //{
  -            //    type = "maven-plugin";
  -            //}
  -
  -            getLogger().debug(
  -                               "Extracted artifact information from path:\n" + "groupId: \'" + groupId + "\'\n"
  -                                   + "artifactId: \'" + artifactId + "\'\n" + "type: \'" + type + "\'\n"
  -                                   + "version: \'" + version + "\'" );
  +            int extPos = lastAvceToken.lastIndexOf( '.' );
  +
  +            if ( extPos > 0 )
  +            {
  +                lastAvceToken = lastAvceToken.substring( 0, extPos );
  +            }
  +
  +            avceTokenList.addLast( lastAvceToken );
  +        }
  +
  +        String validVersionParts = "([Dd][Ee][Vv][_.0-9]*)|" + "([Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt])|" + "([_.0-9ab]+)|"
  +            + "([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]*)|"
  +            + "([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.
  +        // Since version is at the end, we have to move in from the back.
  +        Collections.reverse( avceTokenList );
  +
  +        String classifier = null;
  +        StringBuffer versionBuffer = new StringBuffer();
  +
  +        boolean inFirstToken = true;
  +        for ( Iterator it = avceTokenList.iterator(); it.hasNext(); )
  +        {
  +            String token = (String) it.next();
   
  -            result = artifactConstructionSupport.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME,
  -                                                                 type );
  +            boolean tokenIsVersionPart = token.matches( validVersionParts );
  +            if ( inFirstToken && !tokenIsVersionPart )
  +            {
  +                classifier = token;
  +            }
  +            else if ( tokenIsVersionPart )
  +            {
  +                if ( !inFirstToken )
  +                {
  +                    versionBuffer.insert( 0, '-' );
  +                }
  +
  +                versionBuffer.insert( 0, token );
  +            }
  +            else
  +            {
  +                // if we didn't find a version, but we did find a 'classifier', 
  +                // then push that classifier back onto the list...chances are, 
  +                // it doesn't have a version or a classifier if this is the case.
  +                if ( versionBuffer.length() < 1 && classifier != null )
  +                {
  +                    avceTokenList.addFirst( classifier );
  +                }
  +
  +                // we've discovered all the version parts. break the loop.
  +                break;
  +            }
  +
  +            if ( inFirstToken )
  +            {
  +                inFirstToken = false;
  +            }
  +
  +            // pop the token off the list so it doesn't appear in the
  +            // artifactId.
  +            it.remove();
  +        }
  +
  +        // Now, restore the proper ordering so we can build the artifactId.
  +        Collections.reverse( avceTokenList );
  +
  +        StringBuffer artifactIdBuffer = new StringBuffer();
  +
  +        inFirstToken = true;
  +        for ( Iterator it = avceTokenList.iterator(); it.hasNext(); )
  +        {
  +            String token = (String) it.next();
  +
  +            if ( inFirstToken )
  +            {
  +                inFirstToken = false;
  +            }
  +            else
  +            {
  +                artifactIdBuffer.append( '-' );
  +            }
  +
  +            artifactIdBuffer.append( token );
           }
   
  -        return result;
  +        String artifactId = artifactIdBuffer.toString();
  +        String version = versionBuffer.toString();
  +
  +        getLogger().debug(
  +                           "Extracted artifact information from path:\n" + "groupId: \'" + groupId + "\'\n"
  +                               + "artifactId: \'" + artifactId + "\'\n" + "type: \'" + type + "\'\n" + "version: \'"
  +                               + version + "\'\n" + "classifier: \'" + classifier + "\'" );
  +
  +        if ( classifier != null )
  +        {
  +            return artifactConstructionSupport.createArtifactWithClassifier( groupId, artifactId, version,
  +                                                                             Artifact.SCOPE_RUNTIME, type, classifier );
  +        }
  +        else
  +        {
  +            return artifactConstructionSupport.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME,
  +                                                               type );
  +        }
       }
   
   }
  \ No newline at end of file
  
  
  
  1.2       +26 -15    maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/ArtifactDiscoverer.java
  
  Index: ArtifactDiscoverer.java
  ===================================================================
  RCS file: /home/cvs/maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover/ArtifactDiscoverer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ArtifactDiscoverer.java	23 Mar 2005 04:53:30 -0000	1.1
  +++ ArtifactDiscoverer.java	1 Apr 2005 00:24:44 -0000	1.2
  @@ -5,21 +5,18 @@
   import java.io.File;
   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-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.
    */
   
   /**
  @@ -28,6 +25,20 @@
   public interface ArtifactDiscoverer
   {
       public static final String ROLE = ArtifactDiscoverer.class.getName();
  +    
  +    public static final String[] STANDARD_DISCOVERY_EXCLUDES = {
  +        "bin/**",
  +        "reports/**",
  +        ".maven/**",
  +        "**/poms/*.pom",
  +        "**/*.md5",
  +        "**/*snapshot-version",
  +        "*/website/**",
  +        "*/licenses/**",
  +        "*/licences/**",
  +        "**/.htaccess",
  +        "**/REPOSITORY-V*.txt"
  +    };
   
       List discoverArtifacts( File repositoryBase, Reporter reporter ) throws Exception;
       
  
  
  
  1.4       +80 -0     maven-components/sandbox/repoclean/src/main/resources/META-INF/plexus/components.xml
  
  Index: components.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/sandbox/repoclean/src/main/resources/META-INF/plexus/components.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- components.xml	23 Mar 2005 04:53:29 -0000	1.3
  +++ components.xml	1 Apr 2005 00:24:44 -0000	1.4
  @@ -16,6 +16,86 @@
        |
        -->
       <component>
  +      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
  +      <role-hint>distribution</role-hint>
  +      <implementation>org.apache.maven.tools.repoclean.artifact.JarDistroHandler</implementation>
  +    </component>
  +    <!--
  +     |
  +     |
  +     |
  +     -->
  +    <component>
  +      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
  +      <role-hint>distribution-tgz</role-hint>
  +      <implementation>org.apache.maven.tools.repoclean.artifact.TgzDistroHandler</implementation>
  +    </component>
  +    <!--
  +     |
  +     |
  +     |
  +     -->
  +    <component>
  +      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
  +      <role-hint>distribution-zip</role-hint>
  +      <implementation>org.apache.maven.tools.repoclean.artifact.ZipDistroHandler</implementation>
  +    </component>
  +    <!--
  +     |
  +     |
  +     |
  +     -->
  +    <component>
  +      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
  +      <role-hint>tld</role-hint>
  +      <implementation>org.apache.maven.tools.repoclean.artifact.TldHandler</implementation>
  +    </component>
  +    <!--
  +     |
  +     |
  +     |
  +     -->
  +    <component>
  +      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
  +      <role-hint>dtd</role-hint>
  +      <implementation>org.apache.maven.tools.repoclean.artifact.DtdHandler</implementation>
  +    </component>
  +    <!--
  +     |
  +     |
  +     |
  +     -->
  +    <component>
  +      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
  +      <role-hint>ear</role-hint>
  +      <implementation>org.apache.maven.tools.repoclean.artifact.EarHandler</implementation>
  +    </component>
  +    <!--
  +     |
  +     |
  +     |
  +     -->
  +    <component>
  +      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
  +      <role-hint>rar</role-hint>
  +      <implementation>org.apache.maven.tools.repoclean.artifact.RarHandler</implementation>
  +    </component>
  +    <!--
  +     |
  +     |
  +     |
  +     -->
  +    <component>
  +      <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
  +      <role-hint>sar</role-hint>
  +      <implementation>org.apache.maven.tools.repoclean.artifact.SarHandler</implementation>
  +    </component>
  +    <!--
  +     |
  +     |
  +     |
  +     -->
  +    <component>
         <role>org.apache.maven.tools.repoclean.RepositoryCleaner</role>
         <implementation>org.apache.maven.tools.repoclean.RepositoryCleaner</implementation>
         <requirements>
  
  
  
  1.5       +13 -1     maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/construction/ArtifactConstructionSupport.java
  
  Index: ArtifactConstructionSupport.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-artifact/src/main/java/org/apache/maven/artifact/construction/ArtifactConstructionSupport.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ArtifactConstructionSupport.java	24 Mar 2005 08:45:36 -0000	1.4
  +++ ArtifactConstructionSupport.java	1 Apr 2005 00:24:44 -0000	1.5
  @@ -27,12 +27,24 @@
   
       public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type )
       {
  -        return createArtifact( groupId, artifactId, version, scope, type, null );
  +        return createArtifact( groupId, artifactId, version, scope, type, null, null );
  +    }
  +
  +    public Artifact createArtifactWithClassifier( String groupId, String artifactId, String version, String scope, String type, 
  +                                    String classifier )
  +    {
  +        return createArtifact( groupId, artifactId, version, scope, type, classifier, null );
       }
   
       public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
                                       String inheritedScope )
       {
  +        return createArtifact(groupId, artifactId, version, scope, type, null, inheritedScope);
  +    }
  +    
  +    public Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type,
  +                                    String classifier, String inheritedScope )
  +    {
           // TODO: can refactor, use scope handler
   
           // if this artifact is test, and the dependency is test, don't transitively create
  
  
  
  1.2       +50 -37    maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/report/Reporter.java
  
  Index: Reporter.java
  ===================================================================
  RCS file: /home/cvs/maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/report/Reporter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Reporter.java	17 Mar 2005 22:56:40 -0000	1.1
  +++ Reporter.java	1 Apr 2005 00:24:44 -0000	1.2
  @@ -1,17 +1,5 @@
   package org.apache.maven.tools.repoclean.report;
   
  -import org.codehaus.plexus.util.IOUtil;
  -
  -import java.io.BufferedWriter;
  -import java.io.File;
  -import java.io.FileWriter;
  -import java.io.IOException;
  -import java.io.PrintWriter;
  -import java.io.StringWriter;
  -import java.util.ArrayList;
  -import java.util.Iterator;
  -import java.util.List;
  -
   /* ====================================================================
    *   Copyright 2001-2004 The Apache Software Foundation.
    *
  @@ -29,6 +17,18 @@
    * ====================================================================
    */
   
  +import org.codehaus.plexus.util.IOUtil;
  +
  +import java.io.File;
  +import java.io.FileWriter;
  +import java.io.IOException;
  +import java.io.PrintWriter;
  +import java.io.StringWriter;
  +import java.io.Writer;
  +import java.util.ArrayList;
  +import java.util.Iterator;
  +import java.util.List;
  +
   /**
    * @author jdcasey
    */
  @@ -49,7 +49,10 @@
   
       private boolean hasWarning = false;
   
  +    private Writer writer;
  +
       public Reporter( File reportsBase, String reportPath )
  +        throws IOException
       {
           this.reportsFile = new File( reportsBase, reportPath );
   
  @@ -65,36 +68,42 @@
                   + "\' refers to a file, not a directory.\n" + "Cannot write report file: \'"
                   + reportsFile.getAbsolutePath() + "\'." );
           }
  +
  +        open();
       }
   
  -    public void writeReport() throws IOException
  +    private void open()
  +        throws IOException
       {
  -        BufferedWriter writer = null;
  -
  -        try
  -        {
  -            writer = new BufferedWriter( new FileWriter( reportsFile ) );
  +        this.writer = new FileWriter( reportsFile );
  +    }
   
  -            for ( Iterator it = messages.iterator(); it.hasNext(); )
  -            {
  -                Object message = it.next();
  +    public void close()
  +    {
  +        IOUtil.close( writer );
  +    }
   
  -                if ( message instanceof List )
  -                {
  -                    writer.write( format( (List) message ).toString() );
  -                }
  -                else
  -                {
  -                    writer.write( String.valueOf( message ) );
  -                }
  +    private void write( Object message )
  +        throws IOException
  +    {
  +        if ( writer == null )
  +        {
  +            throw new IOException( "BufferedWriter instance in reporter: \'" + this
  +                + "\' is null. Cannot write message." );
  +        }
   
  -                writer.newLine();
  -            }
  +        if ( message instanceof List )
  +        {
  +            writer.write( format( (List) message ).toString() );
           }
  -        finally
  +        else
           {
  -            IOUtil.close( writer );
  +            writer.write( String.valueOf( message ) );
           }
  +
  +        writer.write( '\n' );
  +        
  +        writer.flush();
       }
   
       public boolean hasWarning()
  @@ -108,26 +117,30 @@
       }
   
       public void warn( String message )
  +        throws IOException
       {
           hasWarning = true;
  -        messages.add( new AppendingList( 2 ).append( WARN_LEVEL ).append( message ) );
  +        write( new AppendingList( 2 ).append( WARN_LEVEL ).append( message ) );
       }
   
       public void info( String message )
  +        throws IOException
       {
  -        messages.add( new AppendingList( 2 ).append( INFO_LEVEL ).append( message ) );
  +        write( new AppendingList( 2 ).append( INFO_LEVEL ).append( message ) );
       }
   
       public void error( String message, Throwable error )
  +        throws IOException
       {
           hasError = true;
  -        messages.add( new AppendingList( 3 ).append( ERROR_LEVEL ).append( message ).append( error ) );
  +        write( new AppendingList( 3 ).append( ERROR_LEVEL ).append( message ).append( error ) );
       }
   
       public void error( String message )
  +        throws IOException
       {
           hasError = true;
  -        messages.add( new AppendingList( 2 ).append( ERROR_LEVEL ).append( message ) );
  +        write( new AppendingList( 2 ).append( ERROR_LEVEL ).append( message ) );
       }
   
       private CharSequence format( List messageParts )
  
  
  
  1.2       +1 -0      maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/V3PomRewriter.java
  
  Index: V3PomRewriter.java
  ===================================================================
  RCS file: /home/cvs/maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/V3PomRewriter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- V3PomRewriter.java	23 Mar 2005 04:53:29 -0000	1.1
  +++ V3PomRewriter.java	1 Apr 2005 00:24:44 -0000	1.2
  @@ -112,6 +112,7 @@
       }
   
       private void validateV4Basics( Model model, Artifact artifact, Reporter reporter )
  +        throws Exception
       {
           if ( StringUtils.isEmpty( model.getModelVersion() ) )
           {
  
  
  
  1.2       +33 -30    maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/V4PomRewriter.java
  
  Index: V4PomRewriter.java
  ===================================================================
  RCS file: /home/cvs/maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/rewrite/V4PomRewriter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- V4PomRewriter.java	23 Mar 2005 04:53:29 -0000	1.1
  +++ V4PomRewriter.java	1 Apr 2005 00:24:44 -0000	1.2
  @@ -32,40 +32,42 @@
   /**
    * @author jdcasey
    */
  -public class V4PomRewriter implements ArtifactPomRewriter
  +public class V4PomRewriter
  +    implements ArtifactPomRewriter
   {
  -    public void rewrite( Artifact artifact, File from, File to, Reporter reporter, boolean reportOnly  ) throws Exception
  +    public void rewrite( Artifact artifact, File from, File to, Reporter reporter, boolean reportOnly )
  +        throws Exception
       {
           Model model = null;
  -        
  -        if(from.exists())
  +
  +        if ( from.exists() )
           {
               FileReader fromReader = null;
               try
               {
  -                fromReader = new FileReader(from);
  -                
  +                fromReader = new FileReader( from );
  +
                   MavenXpp3Reader reader = new MavenXpp3Reader();
  -                
  +
                   try
                   {
                       model = reader.read( fromReader );
                   }
                   catch ( Exception e )
                   {
  -                    reporter.error("Invalid v4 POM at \'" + from + "\'. Cannot read.", e);
  +                    reporter.error( "Invalid v4 POM at \'" + from + "\'. Cannot read.", e );
                   }
               }
               finally
               {
  -                IOUtil.close(fromReader);
  +                IOUtil.close( fromReader );
               }
           }
           else
           {
               reporter.error( "POM for artifact[" + artifact.getId() + "] does not exist in source repository!" );
           }
  -        
  +
           if ( model != null )
           {
               validateBasics( model, artifact, reporter );
  @@ -98,36 +100,37 @@
       }
   
       private void validateBasics( Model model, Artifact artifact, Reporter reporter )
  +        throws Exception
       {
  -        if(StringUtils.isEmpty( model.getModelVersion() ) )
  +        if ( StringUtils.isEmpty( model.getModelVersion() ) )
           {
  -            reporter.info("Setting modelVersion on v4 model to \'4.0.0\'");
  -            model.setModelVersion("4.0.0");
  +            reporter.info( "Setting modelVersion on v4 model to \'4.0.0\'" );
  +            model.setModelVersion( "4.0.0" );
           }
  -        
  -        if(StringUtils.isEmpty(model.getGroupId()))
  +
  +        if ( StringUtils.isEmpty( model.getGroupId() ) )
           {
  -            reporter.info("Setting groupId on model using artifact information.");
  -            model.setGroupId(artifact.getGroupId());
  +            reporter.info( "Setting groupId on model using artifact information." );
  +            model.setGroupId( artifact.getGroupId() );
           }
  -        
  -        if(StringUtils.isEmpty(model.getArtifactId()))
  +
  +        if ( StringUtils.isEmpty( model.getArtifactId() ) )
           {
  -            reporter.info("Setting artifactId on model using artifact information.");
  -            model.setArtifactId(artifact.getArtifactId());
  +            reporter.info( "Setting artifactId on model using artifact information." );
  +            model.setArtifactId( artifact.getArtifactId() );
           }
  -        
  -        if(StringUtils.isEmpty(model.getVersion()))
  +
  +        if ( StringUtils.isEmpty( model.getVersion() ) )
           {
  -            reporter.info("Setting version on model using artifact information.");
  -            model.setVersion(artifact.getVersion());
  +            reporter.info( "Setting version on model using artifact information." );
  +            model.setVersion( artifact.getVersion() );
           }
  -        
  -        if(StringUtils.isEmpty(model.getPackaging()))
  +
  +        if ( StringUtils.isEmpty( model.getPackaging() ) )
           {
  -            reporter.info("Setting packaging on model using artifact type information.");
  -            model.setPackaging(artifact.getType());
  +            reporter.info( "Setting packaging on model using artifact type information." );
  +            model.setPackaging( artifact.getType() );
           }
       }
   
  -}
  +}
  \ No newline at end of file
  
  
  
  1.4       +167 -74   maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleaner.java
  
  Index: RepositoryCleaner.java
  ===================================================================
  RCS file: /home/cvs/maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/RepositoryCleaner.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RepositoryCleaner.java	23 Mar 2005 04:53:30 -0000	1.3
  +++ RepositoryCleaner.java	1 Apr 2005 00:24:44 -0000	1.4
  @@ -73,58 +73,136 @@
           {
               Logger logger = getLogger();
   
  -            Reporter repoReporter = new Reporter( reportsBase, "repository.report.txt" );
  -
  -            ArtifactDiscoverer artifactDiscoverer = (ArtifactDiscoverer) container.lookup(
  -                                                                                           ArtifactDiscoverer.ROLE,
  -                                                                                           configuration.getSourceRepositoryLayout() );
  -
  -            logger.info( "Discovering artifacts." );
  -            List artifacts = null;
  +            Reporter repoReporter = null;
               try
               {
  -                artifacts = artifactDiscoverer.discoverArtifacts( sourceRepositoryBase, repoReporter );
  +                repoReporter = new Reporter( reportsBase, "repository.report.txt" );
  +
  +                ArtifactDiscoverer artifactDiscoverer = null;
  +
  +                List artifacts = null;
  +                try
  +                {
  +                    artifactDiscoverer = (ArtifactDiscoverer) container.lookup( ArtifactDiscoverer.ROLE,
  +                                                                                configuration.getSourceRepositoryLayout() );
  +
  +                    if ( logger.isInfoEnabled() )
  +                    {
  +                        logger.info( "Discovering artifacts." );
  +                    }
  +                    
  +                    try
  +                    {
  +                        artifacts = artifactDiscoverer.discoverArtifacts( sourceRepositoryBase, repoReporter );
  +                    }
  +                    catch ( Exception e )
  +                    {
  +                        repoReporter.error( "Error discovering artifacts in source repository.", e );
  +                    }
  +
  +                }
  +                finally
  +                {
  +                    if ( artifactDiscoverer != null )
  +                    {
  +                        container.release( artifactDiscoverer );
  +                    }
  +                }
  +
  +                if ( artifacts != null )
  +                {
  +                    ArtifactRepositoryLayout sourceLayout = null;
  +                    ArtifactRepositoryLayout targetLayout = null;
  +                    try
  +                    {
  +                        sourceLayout = (ArtifactRepositoryLayout) container.lookup(
  +                                                                                    ArtifactRepositoryLayout.ROLE,
  +                                                                                    configuration.getSourceRepositoryLayout() );
  +
  +                        ArtifactRepository sourceRepo = new ArtifactRepository( "source", "file://"
  +                            + sourceRepositoryBase.getAbsolutePath(), sourceLayout );
  +
  +                        targetLayout = (ArtifactRepositoryLayout) container.lookup(
  +                                                                                    ArtifactRepositoryLayout.ROLE,
  +                                                                                    configuration.getTargetRepositoryLayout() );
  +
  +                        ArtifactRepository targetRepo = new ArtifactRepository( "target", "file://"
  +                            + targetRepositoryBase.getAbsolutePath(), targetLayout );
  +
  +                        if ( logger.isInfoEnabled() )
  +                        {
  +                            logger.info( "Rewriting POMs and artifact files." );
  +                        }
  +                        
  +                        rewriteArtifactsAndPoms( artifacts, sourceRepo, targetRepo, configuration, reportsBase,
  +                                                 sourceRepositoryBase, targetRepositoryBase, repoReporter );
  +                    }
  +                    finally
  +                    {
  +                        if ( sourceLayout != null )
  +                        {
  +                            container.release( sourceLayout );
  +                        }
  +
  +                        if ( targetLayout != null )
  +                        {
  +                            container.release( targetLayout );
  +                        }
  +                    }
  +                }
  +
  +                if ( repoReporter.hasError() && logger.isErrorEnabled() )
  +                {
  +                    logger.error( "Error encountered while converting source repository to target repository." );
  +                }
  +
  +                if ( repoReporter.hasWarning() && logger.isWarnEnabled() )
  +                {
  +                    logger.warn( "Warning encountered while rewriting one or more artifacts from source repository to target repository." );
  +                }
               }
  -            catch ( Exception e )
  +            finally
               {
  -                repoReporter.error( "Error discovering artifacts in source repository.", e );
  +                if(repoReporter != null)
  +                {
  +                    repoReporter.close();
  +                }
               }
  +        }
  +    }
  +
  +    private void rewriteArtifactsAndPoms( List artifacts, ArtifactRepository sourceRepo, ArtifactRepository targetRepo,
  +                                         RepositoryCleanerConfiguration configuration, File reportsBase,
  +                                         File sourceRepositoryBase, File targetRepositoryBase, Reporter repoReporter )
  +        throws Exception
  +    {
  +        Logger logger = getLogger();
  +
  +        ArtifactPomRewriter artifactPomRewriter = null;
   
  -            if ( artifacts != null )
  +        try
  +        {
  +            for ( Iterator it = artifacts.iterator(); it.hasNext(); )
               {
  -                ArtifactRepositoryLayout sourceLayout = (ArtifactRepositoryLayout) container.lookup(
  -                                                                                                     ArtifactRepositoryLayout.ROLE,
  -                                                                                                     configuration.getSourceRepositoryLayout() );
  -
  -                ArtifactRepository sourceRepo = new ArtifactRepository( "source",
  -                                                                        "file://" + sourceRepositoryBase.getAbsolutePath(),
  -                                                                        sourceLayout );
  -
  -                ArtifactRepositoryLayout targetLayout = (ArtifactRepositoryLayout) container.lookup(
  -                                                                                                     ArtifactRepositoryLayout.ROLE,
  -                                                                                                     configuration.getTargetRepositoryLayout() );
  -
  -                ArtifactRepository targetRepo = new ArtifactRepository( "target",
  -                                                                        "file://" + targetRepositoryBase.getAbsolutePath(),
  -                                                                        targetLayout );
  +                Artifact artifact = (Artifact) it.next();
   
  -                logger.info( "Rewriting POMs and artifact files." );
  -                for ( Iterator it = artifacts.iterator(); it.hasNext(); )
  +                Reporter artifactReporter = null;
  +                try
                   {
  -                    Artifact artifact = (Artifact) it.next();
  -                    
  -                    Reporter artifactReporter = new Reporter( reportsBase, artifact.getGroupId() + "_"
  -                                                              + artifact.getArtifactId() + "_" + artifact.getVersion() + ".report.txt" );
  +                    artifactReporter = new Reporter( reportsBase, artifact.getId().replace(':', '_') + ".report.txt" );
   
                       boolean errorOccurred = false;
  -                    
  +
                       try
                       {
                           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 artifactSource = new File( sourceRepo.getBasedir(), sourceRepo.pathOf( artifact ) );
                               File artifactTarget = new File( targetRepo.getBasedir(), targetRepo.pathOf( artifact ) );
   
  @@ -134,9 +212,12 @@
                                   targetParent.mkdirs();
                               }
   
  -                            logger.debug( "Copying artifact[" + artifact.getId() + "] from \'"
  -                                + artifactSource + "\' to \'" + artifactTarget + "\'." );
  -                            
  +                            if ( logger.isDebugEnabled() )
  +                            {
  +                                logger.debug( "Copying artifact[" + artifact.getId() + "] from \'" + artifactSource
  +                                    + "\' to \'" + artifactTarget + "\'." );
  +                            }
  +
                               copyArtifact( artifactSource, artifactTarget, artifactReporter );
                           }
                           else
  @@ -146,16 +227,20 @@
                       }
                       catch ( Exception e )
                       {
  -                        repoReporter.error("Error transferring artifact[" + artifact.getId() + "] to the target repository.", 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 )
                       {
  -                        logger.debug( "working on digest for artifact[" + artifact.getId() + "] with groupId: \'"
  -                            + artifact.getGroupId() + "\'" );
  +                        if ( logger.isDebugEnabled() )
  +                        {
  +                            logger.debug( "working on digest for artifact[" + artifact.getId() + "] with groupId: \'"
  +                                + artifact.getGroupId() + "\'" );
  +                        }
   
                           try
                           {
  @@ -172,9 +257,8 @@
                       {
                           Artifact pomArtifact = buildPomArtifact( artifact );
   
  -                        ArtifactPomRewriter artifactPomRewriter = (ArtifactPomRewriter) container.lookup(
  -                                                                                                          ArtifactPomRewriter.ROLE,
  -                                                                                                          configuration.getSourcePomVersion() );
  +                        artifactPomRewriter = (ArtifactPomRewriter) container.lookup( ArtifactPomRewriter.ROLE,
  +                                                                                      configuration.getSourcePomVersion() );
   
                           File sourcePom = new File( sourceRepositoryBase, sourceRepo.pathOf( pomArtifact ) );
   
  @@ -192,58 +276,67 @@
                           }
                       }
   
  -                    try
  +                    if ( artifactReporter.hasError() )
                       {
  -                        artifactReporter.writeReport();
  +                        repoReporter.warn( "Error(s) occurred while rewriting artifact: \'" + artifact.getId()
  +                            + "\' or its POM." );
                       }
  -                    catch ( IOException e )
  +
  +                    if ( artifactReporter.hasWarning() )
                       {
  -                        logger.error( "Error writing report for artifact \'" + artifact.getId() + "\'", e );
  +                        repoReporter.info( "Warning(s) occurred while rewriting artifact: \'" + artifact.getId()
  +                            + "\' or its POM." );
  +                    }
  +                }
  +                finally
  +                {
  +                    if ( artifactReporter != null )
  +                    {
  +                        artifactReporter.close();
                       }
                   }
               }
  -
  -            try
  -            {
  -                repoReporter.writeReport();
  -            }
  -            catch ( IOException e )
  +        }
  +        finally
  +        {
  +            if ( artifactPomRewriter != null )
               {
  -                logger.error( "Error writing report for repository", e );
  +                container.release( artifactPomRewriter );
               }
           }
       }
   
  -    private void copyArtifact( File artifactSource, File artifactTarget, Reporter reporter ) throws IOException
  +    private void copyArtifact( File artifactSource, File artifactTarget, Reporter reporter )
  +        throws IOException
       {
           InputStream inStream = null;
           OutputStream outStream = null;
           try
           {
               File targetParent = artifactTarget.getParentFile();
  -            if(!targetParent.exists())
  +            if ( !targetParent.exists() )
               {
  -                reporter.info("Creating directory \'" + targetParent + "\'.");
  +                reporter.info( "Creating directory \'" + targetParent + "\'." );
                   targetParent.mkdirs();
               }
  -            
  -            inStream = new BufferedInputStream(new FileInputStream(artifactSource));
  -            outStream = new BufferedOutputStream(new FileOutputStream(artifactTarget));
  -            
  +
  +            inStream = new BufferedInputStream( new FileInputStream( artifactSource ) );
  +            outStream = new BufferedOutputStream( new FileOutputStream( artifactTarget ) );
  +
               byte[] buffer = new byte[16];
               int read = -1;
  -            
  -            while((read = inStream.read(buffer)) > -1)
  +
  +            while ( ( read = inStream.read( buffer ) ) > -1 )
               {
  -                outStream.write(buffer, 0, read);
  +                outStream.write( buffer, 0, read );
               }
  -            
  +
               outStream.flush();
           }
           finally
           {
  -            IOUtil.close(inStream);
  -            IOUtil.close(outStream);
  +            IOUtil.close( inStream );
  +            IOUtil.close( outStream );
           }
       }
   
  @@ -258,8 +351,8 @@
           Logger logger = getLogger();
   
           File targetRepositoryBase = new File( targetRepositoryPath );
  -        
  -        logger.info("Target repository is at: \'" + targetRepositoryBase + "\'");
  +
  +        logger.info( "Target repository is at: \'" + targetRepositoryBase + "\'" );
   
           if ( !targetRepositoryBase.exists() )
           {
  @@ -284,7 +377,7 @@
   
           File sourceRepositoryBase = new File( sourceRepositoryPath );
   
  -        logger.info("Source repository is at: \'" + sourceRepositoryBase + "\'");
  +        logger.info( "Source repository is at: \'" + sourceRepositoryBase + "\'" );
   
           if ( !sourceRepositoryBase.exists() )
           {
  
  
  
  1.3       +1 -1      maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/Main.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Main.java	23 Mar 2005 04:53:30 -0000	1.2
  +++ Main.java	1 Apr 2005 00:24:44 -0000	1.3
  @@ -71,7 +71,7 @@
                   }
               }
           }
  -        catch ( Exception e )
  +        catch ( Throwable e )
           {
               e.printStackTrace();
           }
  
  
  
  1.3       +24 -18    maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/translate/PomV3ToV4Translator.java
  
  Index: PomV3ToV4Translator.java
  ===================================================================
  RCS file: /home/cvs/maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/translate/PomV3ToV4Translator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PomV3ToV4Translator.java	23 Mar 2005 04:53:29 -0000	1.2
  +++ PomV3ToV4Translator.java	1 Apr 2005 00:24:45 -0000	1.3
  @@ -56,6 +56,7 @@
       public static final String ROLE = PomV3ToV4Translator.class.getName();
   
       public Model translate( org.apache.maven.model.v3_0_0.Model v3Model, Reporter reporter )
  +        throws Exception
       {
           String groupId = v3Model.getGroupId();
           String artifactId = v3Model.getArtifactId();
  @@ -158,6 +159,7 @@
       }
   
       private void warnOfUnsupportedMainModelElements( org.apache.maven.model.v3_0_0.Model v3Model, Reporter reporter )
  +        throws Exception
       {
           if ( StringUtils.isNotEmpty( v3Model.getExtend() ) )
           {
  @@ -225,6 +227,7 @@
       }
   
       private Reports translateReports( List v3Reports, Reporter reporter )
  +        throws Exception
       {
           Reports reports = null;
           if ( v3Reports != null && !v3Reports.isEmpty() )
  @@ -288,6 +291,7 @@
       private org.apache.maven.model.Organization translateOrganization(
                                                                         org.apache.maven.model.v3_0_0.Organization v3Organization,
                                                                         Reporter reporter )
  +        throws Exception
       {
           Organization organization = null;
   
  @@ -534,6 +538,7 @@
       }
   
       private Build translateBuild( org.apache.maven.model.v3_0_0.Build v3Build, Reporter reporter )
  +        throws Exception
       {
           Build build = null;
           if ( v3Build != null )
  @@ -610,6 +615,7 @@
       }
   
       private void warnOfUnsupportedBuildElements( org.apache.maven.model.v3_0_0.Build v3Build, Reporter reporter )
  +        throws Exception
       {
           if ( notEmpty( v3Build.getSourceModifications() ) )
           {
  @@ -650,24 +656,24 @@
           return resources;
       }
   
  -//    private String pathPatternsToString( List patterns )
  -//    {
  -//        StringBuffer result = new StringBuffer();
  -//
  -//        if ( notEmpty( patterns ) )
  -//        {
  -//            for ( Iterator it = patterns.iterator(); it.hasNext(); )
  -//            {
  -//                String pattern = (String) it.next();
  -//
  -//                result.append( "," ).append( pattern );
  -//            }
  -//
  -//            result.setLength( result.length() - 1 );
  -//        }
  -//
  -//        return result.toString();
  -//    }
  +    //    private String pathPatternsToString( List patterns )
  +    //    {
  +    //        StringBuffer result = new StringBuffer();
  +    //
  +    //        if ( notEmpty( patterns ) )
  +    //        {
  +    //            for ( Iterator it = patterns.iterator(); it.hasNext(); )
  +    //            {
  +    //                String pattern = (String) it.next();
  +    //
  +    //                result.append( "," ).append( pattern );
  +    //            }
  +    //
  +    //            result.setLength( result.length() - 1 );
  +    //        }
  +    //
  +    //        return result.toString();
  +    //    }
   
       private boolean notEmpty( List test )
       {
  
  
  
  1.4       +2 -2      maven-components/sandbox/repoclean/pom.xml
  
  Index: pom.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/sandbox/repoclean/pom.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- pom.xml	23 Mar 2005 06:52:55 -0000	1.3
  +++ pom.xml	1 Apr 2005 00:24:45 -0000	1.4
  @@ -25,13 +25,13 @@
         <scope>compile</scope>
       </dependency>
       <dependency>
  -      <groupId>maven</groupId>
  +      <groupId>org.apache.maven</groupId>
         <artifactId>maven-artifact</artifactId>
         <version>2.0-SNAPSHOT</version>
         <scope>compile</scope>
       </dependency>
       <dependency>
  -      <groupId>maven</groupId>
  +      <groupId>org.apache.maven</groupId>
         <artifactId>maven-model</artifactId>
         <version>2.0-SNAPSHOT</version>
         <scope>compile</scope>
  
  
  
  1.3       +2 -2      maven-components/sandbox/repoclean/install.sh
  
  Index: install.sh
  ===================================================================
  RCS file: /home/cvs/maven-components/sandbox/repoclean/install.sh,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- install.sh	23 Mar 2005 04:53:30 -0000	1.2
  +++ install.sh	1 Apr 2005 00:24:45 -0000	1.3
  @@ -40,8 +40,8 @@
       cp -f $2/plexus/jars/plexus-container-default-1.0-alpha-2-SNAPSHOT.jar $1/lib
       cp -f $2/plexus/jars/plexus-utils-1.0-alpha-2-SNAPSHOT.jar $1/lib
       cp -f $2/classworlds/jars/classworlds-1.1-alpha-1.jar $1/lib
  -    cp -f $2/maven/jars/maven-artifact-2.0-SNAPSHOT.jar $1/lib
  -    cp -f $2/maven/jars/maven-model-2.0-SNAPSHOT.jar $1/lib
  +    cp -f $2/org.apache.maven/jars/maven-artifact-2.0-SNAPSHOT.jar $1/lib
  +    cp -f $2/org.apache.maven/jars/maven-model-2.0-SNAPSHOT.jar $1/lib
       cp -f $2/maven/jars/wagon-provider-api-1.0-alpha-2-SNAPSHOT.jar $1/lib
       cp -f $2/maven/jars/wagon-file-1.0-alpha-2-SNAPSHOT.jar $1/lib
       cp -f $2/maven/jars/wagon-http-lightweight-1.0-alpha-2-SNAPSHOT.jar $1/lib
  
  
  

Mime
View raw message