Author: jvanzyl
Date: Sat Dec  2 19:28:28 2006
New Revision: 481693

URL: http://svn.apache.org/viewvc?view=rev&rev=481693
Log:
o using the plexus-resources component instead of the Locator copied in three 
plugins: clover, pmd, checkstyle. An experiment
  vicent and i tried here to measure the real cost of duplicated code.

Removed:
    
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/Locator.java
    
maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/LocatorTest.java
Modified:
    maven/plugins/trunk/maven-checkstyle-plugin/pom.xml
    
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java
    
maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MinMavenProjectStub.java

Modified: maven/plugins/trunk/maven-checkstyle-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/pom.xml?view=diff&rev=481693&r1=481692&r2=481693
==============================================================================
--- maven/plugins/trunk/maven-checkstyle-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-checkstyle-plugin/pom.xml Sat Dec  2 19:28:28 2006
@@ -138,6 +138,11 @@
       <version>1.0-beta-1</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-resources</artifactId>
+      <version>1.0-alpha-4</version>
+    </dependency>
   </dependencies>
   <build>
     <resources>

Modified: 
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java?view=diff&rev=481693&r1=481692&r2=481693
==============================================================================
--- 
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java
 (original)
+++ 
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleReport.java
 Sat Dec  2 19:28:28 2006
@@ -49,6 +49,8 @@
 import org.codehaus.plexus.util.StringOutputStream;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.velocity.VelocityComponent;
+import org.codehaus.plexus.resource.ResourceManager;
+import org.codehaus.plexus.resource.loader.FileResourceLoader;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -429,7 +431,12 @@
 
     private StringOutputStream stringOutputStream;
 
-    private Locator locator;
+    /**
+     * @component
+     * @required
+     * @readonly
+     */
+    private ResourceManager locator;
 
     /**
      * @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale)
@@ -470,7 +477,7 @@
     {
         return siteRenderer;
     }
-
+    
     /**
      * @see 
org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale)
      */
@@ -479,6 +486,10 @@
     {
         mergeDeprecatedInfo();
 
+        locator.addSearchPath( FileResourceLoader.ID , 
project.getFile().getParentFile().getAbsolutePath() );
+
+        locator.setOutputDirectory( new File( 
project.getBuild().getDirectory() ) );
+
         if ( !canGenerateReport() )
         {
             getLog().info( "Source directory does not exist - skipping 
report." );
@@ -488,7 +499,7 @@
         //        for when we start using maven-shared-io and 
maven-shared-monitor...
         //        locator = new Locator( new MojoLogMonitorAdaptor( getLog() ) 
);
 
-        locator = new Locator( getLog(), new File( 
project.getBuild().getDirectory() ) );
+        //locator = new Locator( getLog(), new File( 
project.getBuild().getDirectory() ) );
 
         String configFile = getConfigFile();
         Properties overridingProperties = getOverridingProperties();
@@ -914,6 +925,7 @@
                 try
                 {
                     File headerFile = locator.resolveLocation( headerLocation, 
"checkstyle-header.txt" );
+
                     if ( headerFile != null )
                     {
                         p.setProperty( "checkstyle.header.file", 
headerFile.getAbsolutePath() );
@@ -951,6 +963,7 @@
         try
         {
             File configFile = locator.resolveLocation( configLocation, 
"checkstyle-checker.xml" );
+            
             if ( configFile == null )
             {
                 throw new MavenReportException( "Unable to process null config 
location." );

Modified: 
maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MinMavenProjectStub.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MinMavenProjectStub.java?view=diff&rev=481693&r1=481692&r2=481693
==============================================================================
--- 
maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MinMavenProjectStub.java
 (original)
+++ 
maven/plugins/trunk/maven-checkstyle-plugin/src/test/java/org/apache/maven/plugin/checkstyle/stubs/MinMavenProjectStub.java
 Sat Dec  2 19:28:28 2006
@@ -107,4 +107,11 @@
 
         return build;
     }
+
+    public File getFile()
+    {
+        File file = new File( getBasedir(), "pom.xml" );
+
+        return file; 
+    }
 }


Reply via email to