Author: epugh
Date: Fri Jul  8 14:11:08 2005
New Revision: 209890

URL: http://svn.apache.org/viewcvs?rev=209890&view=rev
Log:
MPSIMIAN-14 upgrade simian

Added:
    maven/maven-1/plugins/trunk/simian/src/plugin-resources/
    maven/maven-1/plugins/trunk/simian/src/plugin-resources/simian.jsl   (with 
props)
Removed:
    
maven/maven-1/plugins/trunk/simian/src/main/org/apache/maven/simian/Duplication.java
    
maven/maven-1/plugins/trunk/simian/src/main/org/apache/maven/simian/DuplicationArea.java
    
maven/maven-1/plugins/trunk/simian/src/main/org/apache/maven/simian/SimianLog.java
    
maven/maven-1/plugins/trunk/simian/src/test/org/apache/maven/simian/SimianLogTest.java
Modified:
    maven/maven-1/plugins/trunk/simian/plugin.jelly
    maven/maven-1/plugins/trunk/simian/project.xml
    
maven/maven-1/plugins/trunk/simian/src/main/org/apache/maven/simian/FileSimianTask.java
    maven/maven-1/plugins/trunk/simian/xdocs/changes.xml

Modified: maven/maven-1/plugins/trunk/simian/plugin.jelly
URL: 
http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/simian/plugin.jelly?rev=209890&r1=209889&r2=209890&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/simian/plugin.jelly (original)
+++ maven/maven-1/plugins/trunk/simian/plugin.jelly Fri Jul  8 14:11:08 2005
@@ -30,14 +30,6 @@
   xmlns:ant="jelly:ant"
   xmlns:simian="simian">
 
-  <define:taglib uri="simian">
-    <define:jellybean
-      name="simianLog"
-      className="org.apache.maven.simian.SimianLog"
-      method="process"
-    />
-  </define:taglib>
-
   <goal name="maven-simian-plugin" 
         description="Generate Simian (Code Similarity Analyzer) report." 
         prereqs="maven-simian-plugin:report"/>
@@ -65,10 +57,11 @@
       </ant:classpath>
     </ant:taskdef>
 
-    <ant:simian output="${maven.build.dir}/generated-xdocs/simian.log"
-                lineCount="${maven.simian.linecount}"
-                failOnDuplication="${maven.simian.failonduplication}">
+    <echo>Generating the Simian raw report ...</echo>
 
+    <ant:simian threshold="${maven.simian.linecount}">
+      <formatter type="plain" 
toFile="${maven.build.dir}/simian-raw-report.log"/>
+      <formatter type="xml" toFile="${maven.build.dir}/simian-raw-report.xml"/>
       <ant:fileset dir="${pom.build.sourceDirectory}">
         <ant:include name="${maven.simian.includes}"/>
         <ant:exclude name="${maven.simian.excludes}"/>
@@ -122,86 +115,25 @@
 
     </ant:simian>
 
+    <!-- Run JSL to transform the report into XDOC -->
+          
+    <echo>Converting the Simian report to xdoc ...</echo>
+
+    <doc:jsl
+      input="${maven.build.dir}/simian-raw-report.xml"
+      output="simian-report.xml"
+      stylesheet="${plugin.resources}/simian.jsl"
+      outputMode="xml"
+      prettyPrint="true"
+    />
+
   </goal>
 
   <goal name="maven-simian-plugin:report">
 
     <j:choose>
       <j:when test="${sourcesPresent}">
-
         <attainGoal name="maven-simian-plugin:analyze"/>
-        
-        <simian:simianLog
-          logFile="${maven.build.dir}/generated-xdocs/simian.log"
-          jellyContext="${context}"
-          sourceDirectory="${pom.build.sourceDirectory}"
-          unitTestSourceDirectory="${pom.build.unitTestSourceDirectory}"
-        />
-        <j:set var="simLog" value="${context.getVariable('simianLog')}"/>
-    
-        <j:file name="${maven.build.dir}/generated-xdocs/simian-report.xml" 
prettyPrint="true">
-          <j:whitespace xmlns="dummy">
-
-<document>
-  <properties>
-    <title>Simian Report</title>
-  </properties>
-  <body>
-    <section name="Summary">
-      <p>${simLog.copyright1}</p>
-      <p>${simLog.copyright2}</p>
-      <table summary="Simian report summary">
-        <tbody>
-        <tr>
-          <th>Similarity threshold (lines)</th>
-          <td>${maven.simian.linecount}</td>
-        </tr>
-        <tr>
-          <th>Total number of duplicate lines</th>
-          <td>${simLog.totalDuplicateLineCount}</td>
-        </tr>
-        <tr>
-          <th>Total number of duplicate blocks</th>
-          <td>${simLog.blockCount}</td>
-        </tr>
-        <tr>
-          <th>Total number of files with duplicates</th>
-          <td>${simLog.fileWithDuplicateCount}</td>
-        </tr>
-        <tr>
-          <th>Total number of processed lines</th>
-          <td>${simLog.loc}</td>
-        </tr>
-        <tr>
-          <th>Total number of processed files</th>
-          <td>${simLog.fileParseCount}</td>
-        </tr>
-        <tr>
-          <th>Scan time</th>
-          <td>${simLog.time}</td>
-        </tr>
-        </tbody>
-      </table>
-    </section>
-
-    <section name="Duplications">
-      <j:forEach var="duplication" items="${simLog.duplications}">
-        <subsection name="Duplication: ${duplication.lineCount} lines">
-          <ul>
-          <j:forEach var="duplicationArea" 
items="${duplication.duplicationAreas}">
-            <j:set var="className" value="${duplicationArea.className}"/> 
-            <li><a 
href="${duplicationArea.pathToClass}.html#${duplicationArea.startLine}">${duplicationArea.className}(${duplicationArea.startLine}-${duplicationArea.endLine})</a></li>
-          </j:forEach>
-          </ul>          
-        </subsection>
-      </j:forEach>
-    </section>
-  </body>
-</document>
-
-          </j:whitespace>
-        </j:file>
-        
       </j:when>
       <j:otherwise>
         <ant:echo>No sources to run Simian on</ant:echo>

Modified: maven/maven-1/plugins/trunk/simian/project.xml
URL: 
http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/simian/project.xml?rev=209890&r1=209889&r2=209890&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/simian/project.xml (original)
+++ maven/maven-1/plugins/trunk/simian/project.xml Fri Jul  8 14:11:08 2005
@@ -22,7 +22,7 @@
   <extend>../plugin-parent/project.xml</extend>
   <id>maven-simian-plugin</id>
   <name>Maven Simian Plugin</name>
-  <currentVersion>1.4.1-SNAPSHOT</currentVersion>
+  <currentVersion>1.5-SNAPSHOT</currentVersion>
   <description>Simian Plugin for Maven</description>
   <shortDescription>Simian Plugin for Maven</shortDescription>
   <url>http://maven.apache.org/reference/plugins/simian/</url>
@@ -89,12 +89,17 @@
       <name>Maurice Montgénie</name>
       <email>[EMAIL PROTECTED]</email>
     </contributor>
+    <contributor>
+      <name>Benoit Xhenseval</name>
+      <email>[EMAIL PROTECTED]</email>
+      <organization>ObjectLab.co.uk</organization>
+    </contributor>
   </contributors>
   <dependencies>
     <dependency>
       <groupId>redhill</groupId>
       <artifactId>simian</artifactId>
-      <version>1.9.1</version>
+      <version>2.2.4</version>
       <url>http://www.redhillconsulting.com.au/products/simian/</url>
     </dependency>
     <dependency>

Modified: 
maven/maven-1/plugins/trunk/simian/src/main/org/apache/maven/simian/FileSimianTask.java
URL: 
http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/simian/src/main/org/apache/maven/simian/FileSimianTask.java?rev=209890&r1=209889&r2=209890&view=diff
==============================================================================
--- 
maven/maven-1/plugins/trunk/simian/src/main/org/apache/maven/simian/FileSimianTask.java
 (original)
+++ 
maven/maven-1/plugins/trunk/simian/src/main/org/apache/maven/simian/FileSimianTask.java
 Fri Jul  8 14:11:08 2005
@@ -17,24 +17,14 @@
  * ====================================================================
  */
 
-import au.com.redhillconsulting.simian.b;
 import au.com.redhillconsulting.simian.SimianTask;
 
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.IOException;
 import java.io.FileNotFoundException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.LinkedList;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 
-import org.apache.tools.ant.types.FileSet;
 import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.Task;
+
 
 /**
  * Simian Task that writes the output to a file.
@@ -42,13 +32,22 @@
  * @author Aslak Hellesoy
  * @version $Revision$
  */
-public class FileSimianTask extends SimianTask {
+public class FileSimianTask extends SimianTask 
+{
 
-    public void setOutput(File output) {
+       /**
+        * Make sure the directory structure exists and
+        * send the output to a specified file.
+        */
+    public void setOutput(File output) 
+    {
         output.getParentFile().mkdirs();
-        try {
+        try 
+        {
             setOutput(new FileOutputStream(output));
-        } catch (FileNotFoundException e) {
+        } 
+        catch (FileNotFoundException e) 
+        {
             throw new BuildException("Couldn't set output to " + 
output.getAbsolutePath(), e);
         }
     }

Added: maven/maven-1/plugins/trunk/simian/src/plugin-resources/simian.jsl
URL: 
http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/simian/src/plugin-resources/simian.jsl?rev=209890&view=auto
==============================================================================
--- maven/maven-1/plugins/trunk/simian/src/plugin-resources/simian.jsl (added)
+++ maven/maven-1/plugins/trunk/simian/src/plugin-resources/simian.jsl Fri Jul  
8 14:11:08 2005
@@ -0,0 +1,144 @@
+<?xml version="1.0"?>

+

+<!--

+ * ========================================================================

+ * 

+ * Copyright 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.

+ * 

+ * ========================================================================

+-->

+

+<jsl:stylesheet

+  select="$doc"

+  xmlns:j="jelly:core"

+  xmlns:jsl="jelly:jsl"

+  xmlns:util="jelly:util"

+  xmlns:x="jelly:xml"

+  xmlns:doc="doc"

+  xmlns="dummy" trim="false">

+

+  <!-- This needs to be instantiated here to be available in the template 
matches -->

+  <j:useBean var="mavenTool" class="org.apache.maven.util.MavenTool"/>

+  <j:useBean var="fileutil" class="org.apache.velocity.texen.util.FileUtil"/>

+

+  <jsl:template match="simian">

+    <document>

+

+      <properties>

+       <author email="[EMAIL PROTECTED]">Benoit Xhenseval</author>

+        <title>Simian Results</title>

+      </properties>

+

+      <body>

+        <section name="Simian Results">

+          <p>

+            The following document contains the results of

+            <a 
href="http://www.redhillconsulting.com.au/products/simian/index.html";>Simian 
<x:expr select="./@version"/></a>.</p>

+        </section>

+

+        <section name="Summary">

+             <table summary="Simian report summary">

+               <tbody>

+               <tr>

+                 <th>Similarity threshold (lines)</th>

+                 <td><x:expr select="./check/@threshold"/></td>

+               </tr>

+               <tr>

+                 <th>Total number of duplicate lines</th>

+                 <td><x:expr 
select="./check/summary/@duplicateLineCount"/></td>

+               </tr>

+               <tr>

+                 <th>Total number of duplicate blocks</th>

+                 <td><x:expr 
select="./check/summary/@duplicateBlockCount"/></td>

+               </tr>

+               <tr>

+                 <th>Total number of files with duplicates</th>

+                 <td><x:expr 
select="./check/summary/@duplicateFileCount"/></td>

+               </tr>

+               <tr>

+                 <th>Total number of processed lines</th>

+                 <td><x:expr 
select="./check/summary/@totalSignificantLineCount"/></td>

+               </tr>

+               <tr>

+                 <th>Total number of processed files</th>

+                 <td><x:expr select="./check/summary/@totalFileCount"/></td>

+               </tr>

+               <tr>

+                 <th>Scan time</th>

+                 <td><x:expr select="./check/summary/@processingTime"/> 
ms.</td>

+               </tr>

+               </tbody>

+             </table>

+

+       </section>

+        <section name="Duplications">

+           <j:set var="fullSrcDir" value="${pom.build.sourceDirectory}"/>

+           <j:set var="fullTestSrcDir" 
value="${pom.build.unitTestSourceDirectory}"/>

+           <j:set var="srcDir" 
value="${fileutil.file(fullSrcDir).getCanonicalPath()}"/>

+           <j:set var="testDir" 
value="${fileutil.file(fullTestSrcDir).getCanonicalPath()}"/>

+            <x:set var="sets" select="./check/set"/>

+             <j:forEach var="duplication" items="${sets}">

+               <subsection name="Duplication: 
${duplication.attribute('lineCount').getValue()} lines">

+                  <x:set var="blocks" select="$duplication/block"/>

+                 <ul>

+                 <j:forEach var="duplicationArea" items="${blocks}">

+                       <j:set var="name" 
value="${duplicationArea.attribute('sourceFile').getValue()}"/>

+                       <j:set var="srcDirLength" value="${srcDir.length() + 
1}"/>

+                       <j:set var="testDirLength" value="${testDir.length() + 
1}"/>

+                        <j:set var="testIndex" 
value="${name.lastIndexOf(testDir)}"/>

+                        <j:choose>

+                          <j:when test="${testIndex > 0}">

+                               <j:set var="name" 
value="${name.substring(mavenTool.toInteger(testDirLength.toString()))}"/>

+                         </j:when>

+                         <j:otherwise>

+                               <j:set var="name" 
value="${name.substring(mavenTool.toInteger(srcDirLength.toString()))}"/>

+                         </j:otherwise>

+                       </j:choose>

+                        <j:set var="lastIndex" 
value="${name.lastIndexOf('.java')}"/>

+

+                        <j:choose>

+                          <j:when test="${lastIndex > 0}">

+                            <j:set var="index" 
value="${mavenTool.toInteger(lastIndex.toString())}"/>

+                            <j:set var="nameWithoutJavaExtension" 
value="${name.substring(0, index)}"/>

+                            <util:replace var="nameWithoutJavaExtension" 
value="${nameWithoutJavaExtension}" oldChar="\\" newChar="/"/>

+                               <j:choose>

+                                 <j:when test="${testIndex > 0}">

+                                   <li><a 
href="xref/${nameWithoutJavaExtension}.html#${duplicationArea.attribute('startLineNumber').getValue()}">${nameWithoutJavaExtension}
 ( ${duplicationArea.attribute('startLineNumber').getValue()} - 
${duplicationArea.attribute('endLineNumber').getValue()} )</a></li>

+                                 </j:when>

+                                 <j:otherwise>

+                                   <li><a 
href="xref-test/${nameWithoutJavaExtension}.html#${duplicationArea.attribute('startLineNumber').getValue()}">${nameWithoutJavaExtension}
 ( ${duplicationArea.attribute('startLineNumber').getValue()} - 
${duplicationArea.attribute('endLineNumber').getValue()} )</a></li>

+                                 </j:otherwise>

+                               </j:choose>

+                          </j:when>

+                          <j:otherwise>

+                               <j:choose>

+                                 <j:when test="${testIndex > 0}">

+                                   <li><a 
href="xref/${name}.html#${duplicationArea.attribute('startLineNumber').getValue()}">${nameWithoutJavaExtension}
 ( ${duplicationArea.attribute('startLineNumber').getValue()} - 
${duplicationArea.attribute('endLineNumber').getValue()} )</a></li>

+                                 </j:when>

+                                 <j:otherwise>

+                                   <li><a 
href="xref-test/${name}.html#${duplicationArea.attribute('startLineNumber').getValue()}">${nameWithoutJavaExtension}
 ( ${duplicationArea.attribute('startLineNumber').getValue()} - 
${duplicationArea.attribute('endLineNumber').getValue()} )</a></li>

+                                 </j:otherwise>

+                               </j:choose>

+                          </j:otherwise>

+                        </j:choose>

+                 </j:forEach>

+                 </ul>          

+               </subsection>

+             </j:forEach>

+       </section>      

+      </body>

+    </document>

+  </jsl:template>

+</jsl:stylesheet>


Propchange: maven/maven-1/plugins/trunk/simian/src/plugin-resources/simian.jsl
------------------------------------------------------------------------------
    svn:executable = *

Modified: maven/maven-1/plugins/trunk/simian/xdocs/changes.xml
URL: 
http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/simian/xdocs/changes.xml?rev=209890&r1=209889&r2=209890&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/simian/xdocs/changes.xml (original)
+++ maven/maven-1/plugins/trunk/simian/xdocs/changes.xml Fri Jul  8 14:11:08 
2005
@@ -25,6 +25,9 @@
     <author email="[EMAIL PROTECTED]">Maurice Montg?nie</author>
   </properties>
   <body>
+    <release version="1.5" date="in CVS">
+      <action dev="benoitx" type="update">Upgrade to Simian 2.2.4 and XML file 
output from Simian.</action>
+    </release>
     <release version="1.4.1-SNAPSHOT" date="in CVS">
       <action dev="dion" type="update">Ant dependency changed to 
1.5.3.1.</action>
     </release>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to