geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pra...@apache.org
Subject svn commit: r477727 - /geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/SurefireXMLGeneratorMojo.java
Date Tue, 21 Nov 2006 16:17:35 GMT
Author: prasad
Date: Tue Nov 21 08:17:35 2006
New Revision: 477727

URL: http://svn.apache.org/viewvc?view=rev&rev=477727
Log:
* check for existence of surefire-reports dir before proceeding

Modified:
    geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/SurefireXMLGeneratorMojo.java

Modified: geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/SurefireXMLGeneratorMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/SurefireXMLGeneratorMojo.java?view=diff&rev=477727&r1=477726&r2=477727
==============================================================================
--- geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/SurefireXMLGeneratorMojo.java
(original)
+++ geronimo/server/trunk/maven-plugins/testsuite-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/testsuite/SurefireXMLGeneratorMojo.java
Tue Nov 21 08:17:35 2006
@@ -45,7 +45,7 @@
  * @version $Rev$ $Date$
  */
 public class SurefireXMLGeneratorMojo
-    extends MojoSupport
+extends MojoSupport
 {
     /**
      * @component
@@ -53,22 +53,26 @@
     protected AntHelper ant;
 
     /**
-     * @parameter default-value="${project.build.directory}/surefire-reports"
+     * @parameter default-value="${project.build.directory}"
      * @read-only
      */
-     private File currentReportsDirectory;
+    private File currentBuildDirectory;
 
-     /**
-     * @parameter default-value="${project.basedir}"
-     * @read-only
-     */
-     private File currentBaseDirectory;
+    private File currentReportsDirectory;
 
-     /**
-     * @parameter default-value="${project.parent.basedir}/target/surefire-reports"
-     * @read-only
-     */
-     private File parentReportsDirectory;
+    /**
+    * @parameter default-value="${project.basedir}"
+    * @read-only
+    */
+    private File currentBaseDirectory;
+
+    /**
+    * @parameter default-value="${project.parent.basedir}/target"
+    * @read-only
+    */
+    private File parentBuildDirectory;
+
+    private File parentReportsDirectory;
 
     //
     // MojoSupport Hooks
@@ -83,7 +87,8 @@
      */
     protected MavenProject project = null;
 
-    protected MavenProject getProject() {
+    protected MavenProject getProject()
+    {
         return project;
     }
 
@@ -91,11 +96,15 @@
         super.init();
 
         ant.setProject(getProject());
+
+        currentReportsDirectory = new File(currentBuildDirectory, "surefire-reports");
+        parentReportsDirectory = new File(parentBuildDirectory, "surefire-reports");
     }
 
     protected void doExecute() throws Exception {
 
-        if (currentReportsDirectory == null) {
+        if ( !currentReportsDirectory.exists() )
+        {
             log.info("No surefire-reports directory here");
             return;
         }
@@ -107,11 +116,15 @@
         String parent_time = "0";
 
         String artifactName = FileUtils.filename(currentBaseDirectory.getAbsolutePath());
-        parentReportsDirectory.mkdirs();
+        if ( !parentReportsDirectory.exists() )
+        {
+            parentReportsDirectory.mkdirs();
+        }
         File parentSurefireXMLFile = new File(parentReportsDirectory, "TEST-" + artifactName
+ ".xml");
 
         ArrayList xmlFiles = (ArrayList) FileUtils.getFiles(currentReportsDirectory, "TEST*.xml",
null);
-        for (int i=0; i < xmlFiles.size(); i++) {
+        for ( int i=0; i < xmlFiles.size(); i++ )
+        {
             File xmlFile = (File) xmlFiles.get(i);
             log.info("Loading surefire xml for xmlproperty: " + xmlFile.getAbsolutePath());
 
@@ -125,7 +138,8 @@
             String time = ant.getAnt().getProperty(prefix + ".testsuite.time");
             log.debug("tests=" + tests + "; skipped=" + skipped + ", errors=" + errors +
", failures=" + failures + ", time=" + time);
 
-            if (parentSurefireXMLFile.exists()) {
+            if ( parentSurefireXMLFile.exists() )
+            {
                 log.info("Loading parent surefire xml for xmlproperty");
                 String parentPrefix = "parent" + prefix;
                 loadXMLProperty(parentSurefireXMLFile, parentPrefix);
@@ -153,10 +167,12 @@
     /**
      * http://ant.apache.org/manual/CoreTasks/xmlproperty.html
      */
-    private void loadXMLProperty(File src, String prefix) {
+    private void loadXMLProperty(File src, String prefix)
+    {
         XmlProperty xmlProperty = (XmlProperty)ant.createTask("xmlproperty");
         xmlProperty.setFile(src);
-        if (prefix != null) {
+        if ( prefix != null )
+        {
             xmlProperty.setPrefix(prefix);
         }
         xmlProperty.setCollapseAttributes(true);



Mime
View raw message