Author: jtolentino
Date: Sat Dec 30 15:59:19 2006
New Revision: 491349

URL: http://svn.apache.org/viewvc?view=rev&rev=491349
Log:
Modified for easier configuration. Also provided default values to some 
parameters.

Modified:
    
maven/sandbox/plugins/maven-swizzle-plugin/src/main/java/org/apache/maven/plugin/swizzle/ReportMojo.java
    
maven/sandbox/plugins/maven-swizzle-plugin/src/test/java/org/apache/maven/plugin/swizzle/ReportMojoTest.java
    
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/VotesExpectedResult.txt
    
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/blank-output-file-configuration-test.xml
    
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/blank-template-configuration-test.xml
    
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/custom-template-configuration-test.xml
    
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/resolved-issues-configuration-test.xml
    
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/votes-configuration-test.xml

Modified: 
maven/sandbox/plugins/maven-swizzle-plugin/src/main/java/org/apache/maven/plugin/swizzle/ReportMojo.java
URL: 
http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-swizzle-plugin/src/main/java/org/apache/maven/plugin/swizzle/ReportMojo.java?view=diff&rev=491349&r1=491348&r2=491349
==============================================================================
--- 
maven/sandbox/plugins/maven-swizzle-plugin/src/main/java/org/apache/maven/plugin/swizzle/ReportMojo.java
 (original)
+++ 
maven/sandbox/plugins/maven-swizzle-plugin/src/main/java/org/apache/maven/plugin/swizzle/ReportMojo.java
 Sat Dec 30 15:59:19 2006
@@ -22,10 +22,12 @@
 import org.codehaus.plexus.swizzle.JiraReport;
 import org.codehaus.plexus.swizzle.ReportConfiguration;
 import org.codehaus.plexus.swizzle.ReportGenerationException;
+import org.codehaus.plexus.swizzle.ReportConfigurationException;
 
 import java.io.PrintStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.File;
 
 /**
  * Goal which generates a swizzle report based on velocity template
@@ -42,16 +44,37 @@
     private JiraReport report;
 
     /**
-     * Configuration for the reports. Four values are expected. jiraServerUrl 
is the base url of the JIRA where the
-     * data of the report will be retrieved. projectKey is the code used to 
uniquely identify your project.
-     * projectVersion is a filter for the project's version number (you may 
use wild cards). template is the velocity
-     * macro template to use to generate the report. There are currently two 
templates supplied by plexus-swizzle,
-     * org/codehaus/plexus/swizzle/ResolvedIssues.vm and 
org/codehaus/plexus/swizzle/Votes.vm
+     * Base URL of the issue tracking server
+     *
+     * @parameter default-value="http://jira.codehaus.org";
+     */
+    private String jiraServerUrl;
+
+    /**
+     * Identifying code for the project. E.g. SWIZZLE. Wildcards may be used 
for this parameter.
+     *
+     * @parameter
+     * @required
+     */
+    private String projectKey;
+
+    /**
+     * Version of the project. E.g. 2.0.2. Wildcards may be used for this 
parameter.
      *
      * @parameter
      * @required
      */
-    private ReportConfiguration reportConfiguration;
+    private String projectVersion;
+
+    /**
+     * Template to use in generating the reports. Either provide the name of 
default templates (e.g. RESOLVED_ISSUES,
+     * VOTES, or XDOC_SECTION) or the path and filename of the custom template 
to use
+     * (e.g. my-path/my-custom-template.vm).
+     *
+     * @parameter default-value="RESOLVED_ISSUES"
+     */
+    private String template;
+
 
     /**
      * Name of the file to write the result of the report.
@@ -71,10 +94,22 @@
         }
         try
         {
+            ReportConfiguration reportConfiguration = new 
ReportConfiguration();
+
+            reportConfiguration.setJiraServerUrl( jiraServerUrl );
+            reportConfiguration.setProjectKey( projectKey );
+            reportConfiguration.setProjectVersion( projectVersion );
+            reportConfiguration.setTemplate( template );
+
             FileOutputStream out = new FileOutputStream( result );
             PrintStream printStream = new PrintStream( out );
 
             report.generateReport( reportConfiguration, printStream );
+        }
+        catch ( ReportConfigurationException reportConfigurationException )
+        {
+            throw new MojoExecutionException(
+                "Problem encountered while configuring the plugin: " + 
reportConfigurationException.getStackTrace() );
         }
         catch ( IOException fileException )
         {

Modified: 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/java/org/apache/maven/plugin/swizzle/ReportMojoTest.java
URL: 
http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-swizzle-plugin/src/test/java/org/apache/maven/plugin/swizzle/ReportMojoTest.java?view=diff&rev=491349&r1=491348&r2=491349
==============================================================================
--- 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/java/org/apache/maven/plugin/swizzle/ReportMojoTest.java
 (original)
+++ 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/java/org/apache/maven/plugin/swizzle/ReportMojoTest.java
 Sat Dec 30 15:59:19 2006
@@ -46,20 +46,21 @@
         throws Exception
     {
         testConfiguration( "resolved-issues-configuration-test.xml", 
"ResolvedIssuesExpectedResult.txt",
-                           "ResolvedIssuesActualResult.txt" );
+                           getBasedir() + 
"/target/test-classes/unit/ResolvedIssuesActualResult.txt" );
     }
 
     public void testVotesConfiguration()
         throws Exception
     {
-        testConfiguration( "votes-configuration-test.xml", 
"VotesExpectedResult.txt", "VotesActualResult.txt" );
+        testConfiguration( "votes-configuration-test.xml", 
"VotesExpectedResult.txt",
+                           getBasedir() + 
"/target/test-classes/unit/VotesActualResult.txt" );
     }
 
     public void testCustomTemplateConfiguration()
         throws Exception
     {
         testConfiguration( "custom-template-configuration-test.xml", 
"MyResolvedIssuesExpectedResult.txt",
-                           "MyResolvedIssuesActualResult.txt" );
+                           getBasedir() + 
"/target/test-classes/unit/MyResolvedIssuesActualResult.txt" );
     }
 
     public void testReportGenerationExceptionHandling()
@@ -87,7 +88,6 @@
         {
             assertTrue( true );
         }
-
     }
 
     public void testBlankOutputPathHandling()
@@ -139,7 +139,6 @@
         {
             assertTrue( true );
         }
-
     }
 
     private void testConfiguration( String configurationFile, String 
expectedResult, String actualResult )
@@ -148,7 +147,7 @@
         File pom = new File( getBasedir(), "target/test-classes/unit/" + 
configurationFile );
 
         File expectedFile = new File( getBasedir() + 
"/target/test-classes/unit/" + expectedResult );
-        File actualFile = new File( getBasedir() + 
"/target/test-classes/unit/" + actualResult );
+        File actualFile = new File( actualResult );
 
         if ( actualFile.exists() )
         {

Modified: 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/VotesExpectedResult.txt
URL: 
http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/VotesExpectedResult.txt?view=diff&rev=491349&r1=491348&r2=491349
==============================================================================
--- 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/VotesExpectedResult.txt
 (original)
+++ 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/VotesExpectedResult.txt
 Sat Dec 30 15:59:19 2006
@@ -5,10 +5,11 @@
   </properties>
   <body>
     <section name="Issue Tracking Votes">
+      <h3>Swizzle <a 
href="http://jira.codehaus.org/browse/SWIZZLE?report=com.atlassian.jira.plugin.system.project:roadmap-panel";>(Road
 Map)</a></h3>
       <table>
         <tr>
-          <th>2</th>
-          <th>Swizzle</th>
+          <th>TOTAL VOTES: 2</th>
+          <th>DESCRIPTION</th>
         </tr>
         <tr>
           <td>2</td>

Modified: 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/blank-output-file-configuration-test.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/blank-output-file-configuration-test.xml?view=diff&rev=491349&r1=491348&r2=491349
==============================================================================
--- 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/blank-output-file-configuration-test.xml
 (original)
+++ 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/blank-output-file-configuration-test.xml
 Sat Dec 30 15:59:19 2006
@@ -27,12 +27,10 @@
       <plugin>
         <artifactId>maven-swizzle-plugin</artifactId>
         <configuration>
-          <reportConfiguration>
-            <jiraServerUrl>http://jira.codehaus.org</jiraServerUrl>
-            <projectKey>SWIZZLE</projectKey>
-            <projectVersion>*</projectVersion>
-            <template>VOTES</template>
-          </reportConfiguration>
+          <jiraServerUrl>http://jira.codehaus.org</jiraServerUrl>
+          <projectKey>SWIZZLE</projectKey>
+          <projectVersion>*</projectVersion>
+          <template>VOTES</template>
           <result></result>
         </configuration>
       </plugin>

Modified: 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/blank-template-configuration-test.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/blank-template-configuration-test.xml?view=diff&rev=491349&r1=491348&r2=491349
==============================================================================
--- 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/blank-template-configuration-test.xml
 (original)
+++ 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/blank-template-configuration-test.xml
 Sat Dec 30 15:59:19 2006
@@ -27,12 +27,10 @@
       <plugin>
         <artifactId>maven-swizzle-plugin</artifactId>
         <configuration>
-          <reportConfiguration>
-            <jiraServerUrl>http://jira.codehaus.org</jiraServerUrl>
-            <projectKey>SWIZZLE</projectKey>
-            <projectVersion>*</projectVersion>
-            <template></template>
-          </reportConfiguration>
+          <jiraServerUrl>http://jira.codehaus.org</jiraServerUrl>
+          <projectKey>SWIZZLE</projectKey>
+          <projectVersion>*</projectVersion>
+          <template></template>
           <result>target/test-classes/unit/exception.txt</result>
         </configuration>
       </plugin>

Modified: 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/custom-template-configuration-test.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/custom-template-configuration-test.xml?view=diff&rev=491349&r1=491348&r2=491349
==============================================================================
--- 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/custom-template-configuration-test.xml
 (original)
+++ 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/custom-template-configuration-test.xml
 Sat Dec 30 15:59:19 2006
@@ -27,12 +27,10 @@
       <plugin>
         <artifactId>maven-swizzle-plugin</artifactId>
         <configuration>
-          <reportConfiguration>
-            <jiraServerUrl>http://jira.codehaus.org</jiraServerUrl>
-            <projectKey>SWIZZLE</projectKey>
-            <projectVersion>*</projectVersion>
-            <template>unit/MyResolvedIssuesTemplate.vm</template>
-          </reportConfiguration>
+          <jiraServerUrl>http://jira.codehaus.org</jiraServerUrl>
+          <projectKey>SWIZZLE</projectKey>
+          <projectVersion>*</projectVersion>
+          <template>unit/MyResolvedIssuesTemplate.vm</template>
           
<result>target/test-classes/unit/MyResolvedIssuesActualResult.txt</result>
         </configuration>
       </plugin>

Modified: 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/resolved-issues-configuration-test.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/resolved-issues-configuration-test.xml?view=diff&rev=491349&r1=491348&r2=491349
==============================================================================
--- 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/resolved-issues-configuration-test.xml
 (original)
+++ 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/resolved-issues-configuration-test.xml
 Sat Dec 30 15:59:19 2006
@@ -27,12 +27,10 @@
       <plugin>
         <artifactId>maven-swizzle-plugin</artifactId>
         <configuration>
-          <reportConfiguration>
-            <jiraServerUrl>http://jira.codehaus.org</jiraServerUrl>
-            <projectKey>SWIZZLE</projectKey>
-            <projectVersion>*</projectVersion>
-            <template>RESOLVED_ISSUES</template>
-          </reportConfiguration>
+          <jiraServerUrl>http://jira.codehaus.org</jiraServerUrl>
+          <projectKey>SWIZZLE</projectKey>
+          <projectVersion>*</projectVersion>
+          <template>RESOLVED_ISSUES</template>
           
<result>target/test-classes/unit/ResolvedIssuesActualResult.txt</result>
         </configuration>
       </plugin>

Modified: 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/votes-configuration-test.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/votes-configuration-test.xml?view=diff&rev=491349&r1=491348&r2=491349
==============================================================================
--- 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/votes-configuration-test.xml
 (original)
+++ 
maven/sandbox/plugins/maven-swizzle-plugin/src/test/resources/unit/votes-configuration-test.xml
 Sat Dec 30 15:59:19 2006
@@ -27,12 +27,10 @@
       <plugin>
         <artifactId>maven-swizzle-plugin</artifactId>
         <configuration>
-          <reportConfiguration>
-            <jiraServerUrl>http://jira.codehaus.org</jiraServerUrl>
-            <projectKey>SWIZZLE</projectKey>
-            <projectVersion>*</projectVersion>
-            <template>VOTES</template>
-          </reportConfiguration>
+          <jiraServerUrl>http://jira.codehaus.org</jiraServerUrl>
+          <projectKey>SWIZZLE</projectKey>
+          <projectVersion>*</projectVersion>
+          <template>VOTES</template>
           <result>target/test-classes/unit/VotesActualResult.txt</result>
         </configuration>
       </plugin>


Reply via email to