jdcasey     2005/04/04 19:47:43

  Modified:    
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/digest
                        ArtifactDigestVerifier.java
               sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean
                        RepositoryCleaner.java
               
sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/report
                        Reporter.java
               
sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/translate
                        PomV3ToV4Translator.java
               
sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/discover
                        LegacyArtifactDiscoverer.java
  Log:
  Clean-ups. Reporters only write on error/warn...since info no longer exists, 
and file opening is lazy now.
  
  Also, cleaner now checks to make sure the target file is missing and/or out 
of date before processing the source file. This should allow us to avoid 
reprocessing the whole source repo every time.
  
  Revision  Changes    Path
  1.3       +5 -10     
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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- V3PomRewriter.java        1 Apr 2005 00:24:44 -0000       1.2
  +++ V3PomRewriter.java        5 Apr 2005 02:47:43 -0000       1.3
  @@ -74,7 +74,7 @@
           }
           else
           {
  -            reporter.info( "POM for artifact[" + artifact.getId()
  +            reporter.warn( "POM for artifact[" + artifact.getId()
                   + "] does not exist in source repository. We will create a 
skeletal one here." );
               
               v4Model = new Model();
  @@ -104,10 +104,6 @@
                       IOUtil.close( toWriter );
                   }
               }
  -            else
  -            {
  -                reporter.info( "Skipping model write to target repository 
(we're in report-only mode)." );
  -            }
           }
       }
   
  @@ -116,31 +112,30 @@
       {
           if ( StringUtils.isEmpty( model.getModelVersion() ) )
           {
  -            reporter.info( "Setting modelVersion on v4 model to \'4.0.0\'" );
               model.setModelVersion( "4.0.0" );
           }
   
           if ( StringUtils.isEmpty( model.getGroupId() ) )
           {
  -            reporter.info( "Setting groupId on model using artifact 
information." );
  +            reporter.warn( "Setting groupId on model using artifact 
information." );
               model.setGroupId( artifact.getGroupId() );
           }
   
           if ( StringUtils.isEmpty( model.getArtifactId() ) )
           {
  -            reporter.info( "Setting artifactId on model using artifact 
information." );
  +            reporter.warn( "Setting artifactId on model using artifact 
information." );
               model.setArtifactId( artifact.getArtifactId() );
           }
   
           if ( StringUtils.isEmpty( model.getVersion() ) )
           {
  -            reporter.info( "Setting version on model using artifact 
information." );
  +            reporter.warn( "Setting version on model using artifact 
information." );
               model.setVersion( artifact.getVersion() );
           }
   
           if ( StringUtils.isEmpty( model.getPackaging() ) )
           {
  -            reporter.info( "Setting packaging on model using artifact type 
information." );
  +            reporter.warn( "Setting packaging on model using artifact type 
information." );
               model.setPackaging( artifact.getType() );
           }
       }
  
  
  
  1.3       +4 -9      
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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- V4PomRewriter.java        1 Apr 2005 00:24:44 -0000       1.2
  +++ V4PomRewriter.java        5 Apr 2005 02:47:43 -0000       1.3
  @@ -92,10 +92,6 @@
                       IOUtil.close( toWriter );
                   }
               }
  -            else
  -            {
  -                reporter.info( "Skipping model write to target repository 
(we're in report-only mode)." );
  -            }
           }
       }
   
  @@ -104,31 +100,30 @@
       {
           if ( StringUtils.isEmpty( model.getModelVersion() ) )
           {
  -            reporter.info( "Setting modelVersion on v4 model to \'4.0.0\'" );
               model.setModelVersion( "4.0.0" );
           }
   
           if ( StringUtils.isEmpty( model.getGroupId() ) )
           {
  -            reporter.info( "Setting groupId on model using artifact 
information." );
  +            reporter.warn( "Setting groupId on model using artifact 
information." );
               model.setGroupId( artifact.getGroupId() );
           }
   
           if ( StringUtils.isEmpty( model.getArtifactId() ) )
           {
  -            reporter.info( "Setting artifactId on model using artifact 
information." );
  +            reporter.warn( "Setting artifactId on model using artifact 
information." );
               model.setArtifactId( artifact.getArtifactId() );
           }
   
           if ( StringUtils.isEmpty( model.getVersion() ) )
           {
  -            reporter.info( "Setting version on model using artifact 
information." );
  +            reporter.warn( "Setting version on model using artifact 
information." );
               model.setVersion( artifact.getVersion() );
           }
   
           if ( StringUtils.isEmpty( model.getPackaging() ) )
           {
  -            reporter.info( "Setting packaging on model using artifact type 
information." );
  +            reporter.warn( "Setting packaging on model using artifact type 
information." );
               model.setPackaging( artifact.getType() );
           }
       }
  
  
  
  1.4       +0 -13     
maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/ArtifactDigestVerifier.java
  
  Index: ArtifactDigestVerifier.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/sandbox/repoclean/src/main/java/org/apache/maven/tools/repoclean/digest/ArtifactDigestVerifier.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ArtifactDigestVerifier.java       2 Apr 2005 02:17:19 -0000       1.3
  +++ ArtifactDigestVerifier.java       5 Apr 2005 02:47:43 -0000       1.4
  @@ -52,9 +52,6 @@
   
               if ( verified )
               {
  -                reporter.info( "Source digest file for artifact[" + 
artifact.getId()
  -                    + "] is okay, so we'll just copy it." );
  -
                   if ( !reportOnly )
                   {
                       try
  @@ -69,10 +66,6 @@
                           throw e;
                       }
                   }
  -                else
  -                {
  -                    reporter.info( "Skipping transfer of valid MD5 digest 
file (we're in report-only mode)." );
  -                }
               }
               else
               {
  @@ -88,16 +81,10 @@
           // in the target repo.
           if ( !verified )
           {
  -            reporter.info( "Creating .md5 for artifact[" + artifact.getId() 
+ "] in target repository." );
  -
               if ( !reportOnly )
               {
                   artifactDigestor.createArtifactDigest( artifactTarget, 
digestTargetFile, ArtifactDigestor.MD5 );
               }
  -            else
  -            {
  -                reporter.info( "Skipping creation of MD5 digest for artifact 
(we're in report-only mode)." );
  -            }
           }
       }
   
  
  
  
  1.8       +6 -9      
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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RepositoryCleaner.java    4 Apr 2005 03:43:11 -0000       1.7
  +++ RepositoryCleaner.java    5 Apr 2005 02:47:43 -0000       1.8
  @@ -199,12 +199,14 @@
                       boolean errorOccurred = false;
   
                       File artifactSource = new File( sourceRepo.getBasedir(), 
sourceRepo.pathOf( artifact ) );
  +                    File artifactTarget = new File( targetRepo.getBasedir(), 
targetRepo.pathOf( artifact ) );
  +
  +                    artifact.setFile( artifactSource );
  +                    
  +                    boolean targetMissingOrOlder = !artifactTarget.exists() 
|| artifactTarget.lastModified() < artifactSource.lastModified();
                       
  -                    if(artifactSource.exists())
  +                    if(artifactSource.exists() && targetMissingOrOlder)
                       {
  -                        File artifactTarget = new File( 
targetRepo.getBasedir(), targetRepo.pathOf( artifact ) );
  -
  -                        artifact.setFile( artifactSource );
                           
                           try
                           {
  @@ -230,10 +232,6 @@
   
                                   copyArtifact( artifact, artifactTarget, 
artifactReporter );
                               }
  -                            else
  -                            {
  -                                artifactReporter.info( "Skipping artifact 
copy (we're in report-only mode)." );
  -                            }
                           }
                           catch ( Exception e )
                           {
  @@ -339,7 +337,6 @@
               File targetParent = artifactTarget.getParentFile();
               if ( !targetParent.exists() )
               {
  -                reporter.info( "Creating directory \'" + targetParent + 
"\'." );
                   targetParent.mkdirs();
               }
   
  
  
  
  1.3       +7 -14     
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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Reporter.java     1 Apr 2005 00:24:44 -0000       1.2
  +++ Reporter.java     5 Apr 2005 02:47:43 -0000       1.3
  @@ -37,8 +37,6 @@
   
       private static final String WARN_LEVEL = "[WARNING] ";
   
  -    private static final String INFO_LEVEL = "[INFO] ";
  -
       private static final String ERROR_LEVEL = "[ERROR] ";
   
       private File reportsFile;
  @@ -50,9 +48,8 @@
       private boolean hasWarning = false;
   
       private Writer writer;
  -
  +    
       public Reporter( File reportsBase, String reportPath )
  -        throws IOException
       {
           this.reportsFile = new File( reportsBase, reportPath );
   
  @@ -68,8 +65,11 @@
                   + "\' refers to a file, not a directory.\n" + "Cannot write 
report file: \'"
                   + reportsFile.getAbsolutePath() + "\'." );
           }
  -
  -        open();
  +    }
  +    
  +    public File getReportFile()
  +    {
  +        return reportsFile;
       }
   
       private void open()
  @@ -88,8 +88,7 @@
       {
           if ( writer == null )
           {
  -            throw new IOException( "BufferedWriter instance in reporter: \'" 
+ this
  -                + "\' is null. Cannot write message." );
  +            open();
           }
   
           if ( message instanceof List )
  @@ -123,12 +122,6 @@
           write( new AppendingList( 2 ).append( WARN_LEVEL ).append( message ) 
);
       }
   
  -    public void info( String message )
  -        throws IOException
  -    {
  -        write( new AppendingList( 2 ).append( INFO_LEVEL ).append( message ) 
);
  -    }
  -
       public void error( String message, Throwable error )
           throws IOException
       {
  
  
  
  1.5       +1 -12     
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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PomV3ToV4Translator.java  1 Apr 2005 02:45:05 -0000       1.4
  +++ PomV3ToV4Translator.java  5 Apr 2005 02:47:43 -0000       1.5
  @@ -83,15 +83,6 @@
   
           PomKey pomKey = new PomKey( groupId, artifactId, version );
   
  -        StringBuffer logHeader = new StringBuffer();
  -        logHeader.append( "Translation of POM {" ).append( 
v3Model.getGroupId() ).append( ":" ).append(
  -                                                                             
                           v3Model.getArtifactId() ).append(
  -                                                                             
                                                             ":" ).append(
  -                                                                             
                                                                           
version ).append(
  -                                                                             
                                                                                
             "}" );
  -
  -        reporter.info( "[START] " + logHeader.toString() );
  -
           warnOfUnsupportedMainModelElements( v3Model, reporter );
   
           Model model = null;
  @@ -124,8 +115,6 @@
               model.setUrl( v3Model.getUrl() );
   
               model.setVersion( version );
  -
  -            reporter.info( "[END] " + logHeader.toString() );
           }
           catch ( PomTranslationException e )
           {
  @@ -273,7 +262,7 @@
                                                                                
                                                                                
                                                                                
                                                                                
  "\n" ).append(
                                                                                
                                                                                
                                                                                
                                                                                
                 "These values were extracted using the v3 report naming 
convention, but may be wrong." );
   
  -                reporter.info( info.toString() );
  +                reporter.warn( info.toString() );
   
                   Goal reportGoal = new Goal();
   
  
  
  
  1.7       +1 -1      
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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LegacyArtifactDiscoverer.java     4 Apr 2005 03:43:11 -0000       1.6
  +++ LegacyArtifactDiscoverer.java     5 Apr 2005 02:47:43 -0000       1.7
  @@ -74,7 +74,7 @@
   
           if ( numberOfTokens != 3 )
           {
  -            reporter.info( "Artifact path: \'" + path
  +            reporter.warn( "Artifact path: \'" + path
                   + "\' does not match naming convention. Cannot reliably 
extract artifact information from path." );
   
               return null;
  
  
  

Reply via email to