Author: bentmann
Date: Sun Mar  8 10:15:42 2009
New Revision: 751395

URL: http://svn.apache.org/viewvc?rev=751395&view=rev
Log:
o Updated ITs to not fork Maven in the post-build hook script

Added:
    
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/invoker.properties
   (with props)
    
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/invoker.properties
   (with props)
Modified:
    maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/pom.xml
    maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/verify.bsh
    maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/pom.xml
    maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/verify.bsh

Added: 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/invoker.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/invoker.properties?rev=751395&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/invoker.properties
 (added)
+++ 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/invoker.properties
 Sun Mar  8 10:15:42 2009
@@ -0,0 +1,3 @@
+# NOTE: The first time, we run up to "integration-test" phase which includes 
the AntRun execution which saves the
+# timestamp of the first JAR for comparision with the timestamp of the JAR 
from the final "package" invocation.
+invoker.goals = clean integration-test package

Propchange: 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/pom.xml?rev=751395&r1=751394&r2=751395&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/pom.xml 
(original)
+++ maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/pom.xml 
Sun Mar  8 10:15:42 2009
@@ -34,6 +34,28 @@
         <configuration>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <version>1.2</version>
+        <executions>
+          <execution>
+            <id>touch</id>
+            <phase>integration-test</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <tasks>
+                <!-- Save the JAR and especially its timestamp for evaluation 
by the post-build hook script -->
+                <copy file="target/MJAR-70-no-recreation-1.0-SNAPSHOT.jar"
+                      tofile="target/reference.jar"
+                      preservelastmodified="true" overwrite="true"/>
+              </tasks>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 </project>

Modified: 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/verify.bsh?rev=751395&r1=751394&r2=751395&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/verify.bsh 
(original)
+++ 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-no-recreation/verify.bsh 
Sun Mar  8 10:15:42 2009
@@ -20,60 +20,34 @@
 
 import java.io.*;
 import java.util.*;
-import java.util.jar.*;
-import org.codehaus.plexus.util.*;
-import org.codehaus.plexus.util.cli.*;
 
-boolean result = true;
+File target = new File( basedir, "target" );
+if ( !target.isDirectory() )
+{
+    throw new IOException( "target file is missing or not a directory: " + 
target );
+}
 
-try
+File jarFile = new File ( target, "MJAR-70-no-recreation-1.0-SNAPSHOT.jar" );
+if ( !jarFile.isFile() )
 {
-    File target = new File( basedir, "target" );
-    if ( !target.exists() || !target.isDirectory() )
-    {
-        System.err.println( "target file is missing or not a directory." );
-        return false;
-    }
-    
-    File artifact = new File ( target, 
"MJAR-70-no-recreation-1.0-SNAPSHOT.jar" );
-    if ( !artifact.exists() || artifact.isDirectory() )
-    {
-        System.err.println( "artifact file is missing or a directory." );
-        return false;
-    }   
-    
-    long lastModified = artifact.lastModified();
-    String localRepoPath = 
basedir.getParentFile().getParentFile().getParentFile().getPath() + 
"/target/local-repo";
-    Commandline commandline = new Commandline();
-    commandline.setExecutable( "mvn" );
-    commandline.setWorkingDirectory( basedir );
-    commandline.createArg().setLine( "-f pom.xml -Dmaven.repo.local=" + 
localRepoPath + "  package" );     
-    CommandLineUtils.StringStreamConsumer consumer = new 
CommandLineUtils.StringStreamConsumer();
-    int res = CommandLineUtils.executeCommandLine( commandline, consumer, 
consumer );
-    System.out.println( consumer.getOutput() );
-    if ( res != 0 )
-    {
-        System.err.println( "mvn cli invocation not return 0 but " + res );
-        return false;
-    }
-    artifact = new File ( target, "MJAR-70-no-recreation-1.0-SNAPSHOT.jar" );  
   
-    if ( !artifact.exists() || artifact.isDirectory() )
-    {
-        System.err.println( "artifact file is missing or a directory." );
-        return false;
-    }
-    if ( lastModified != artifact.lastModified() )
-    {
-        System.err.println( "lastModified != artifact.lastModified() jar has 
been recreated" );
-        return false;    
-    }
+    throw new IOException( "artifact file is missing or a directory: " + 
jarFile );
+}
 
-    
+File refFile = new File ( target, "reference.jar" );
+if ( !refFile.isFile() )
+{
+    throw new IOException( "reference file is missing or a directory: " + 
refFile );
 }
-catch( Throwable e )
+
+long referenceTimestamp = refFile.lastModified();
+System.out.println( "Reference timestamp: " + referenceTimestamp );
+
+long actualTimestamp = jarFile.lastModified();
+System.out.println( "Actual timestamp   : " + actualTimestamp );
+
+if ( referenceTimestamp != actualTimestamp)
 {
-    e.printStackTrace();
-    result = false;
+               throw new Exception( "Timestamps don't match, JAR was recreated 
although contents has not changed" );
 }
 
-return result;
+return true;

Added: 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/invoker.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/invoker.properties?rev=751395&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/invoker.properties
 (added)
+++ 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/invoker.properties
 Sun Mar  8 10:15:42 2009
@@ -0,0 +1,3 @@
+# NOTE: The first time, we run up to "integration-test" phase which includes 
the AntRun execution which saves the
+# timestamp of the first JAR for comparision with the timestamp of the JAR 
from the final "package" invocation.
+invoker.goals = clean integration-test package

Propchange: 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/pom.xml?rev=751395&r1=751394&r2=751395&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/pom.xml 
(original)
+++ maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/pom.xml Sun 
Mar  8 10:15:42 2009
@@ -35,6 +35,28 @@
           <forceCreation>true</forceCreation>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <version>1.2</version>
+        <executions>
+          <execution>
+            <id>touch</id>
+            <phase>integration-test</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <tasks>
+                <!-- Save the JAR and especially its timestamp for evaluation 
by the post-build hook script -->
+                <copy file="target/MJAR-70-recreation-1.0-SNAPSHOT.jar"
+                      tofile="target/reference.jar"
+                      preservelastmodified="true" overwrite="true"/>
+              </tasks>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 </project>

Modified: 
maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/verify.bsh?rev=751395&r1=751394&r2=751395&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/verify.bsh 
(original)
+++ maven/plugins/trunk/maven-jar-plugin/src/it/MJAR-70-recreation/verify.bsh 
Sun Mar  8 10:15:42 2009
@@ -20,58 +20,34 @@
 
 import java.io.*;
 import java.util.*;
-import java.util.jar.*;
-import org.codehaus.plexus.util.*;
-import org.codehaus.plexus.util.cli.*;
 
-boolean result = true;
+File target = new File( basedir, "target" );
+if ( !target.isDirectory() )
+{
+    throw new IOException( "target file is missing or not a directory: " + 
target );
+}
 
-try
+File jarFile = new File ( target, "MJAR-70-recreation-1.0-SNAPSHOT.jar" );
+if ( !jarFile.isFile() )
 {
-    File target = new File( basedir, "target" );
-    if ( !target.exists() || !target.isDirectory() )
-    {
-        System.err.println( "target file is missing or not a directory." );
-        return false;
-    }
-    
-    File artifact = new File ( target, "MJAR-70-recreation-1.0-SNAPSHOT.jar" );
-    if ( !artifact.exists() || artifact.isDirectory() )
-    {
-        System.err.println( "artifact file is missing or a directory." );
-        return false;
-    }   
-    
-    long lastModified = artifact.lastModified();
-    Commandline commandline = new Commandline();
-    commandline.setExecutable( "mvn" );
-    commandline.setWorkingDirectory( basedir );
-    commandline.createArg().setLine( "-f pom.xml -Dmaven.repo.local=" + 
localRepositoryPath + " package" );     
-    CommandLineUtils.StringStreamConsumer consumer = new 
CommandLineUtils.StringStreamConsumer();
-    int res = CommandLineUtils.executeCommandLine( commandline, consumer, 
consumer );
-    if ( res != 0 )
-    {
-        System.err.println( "mvn cli invocation not return 0 but " + res );
-        return false;
-    }
-    artifact = new File ( target, "MJAR-70-recreation-1.0-SNAPSHOT.jar" );     
-    if ( !artifact.exists() || artifact.isDirectory() )
-    {
-        System.err.println( "artifact file is missing or a directory." );
-        return false;
-    }
-    if ( artifact.lastModified() <= lastModified )
-    {
-        System.err.println( "artifact.lastModified() <= lastModified jar has 
not been recreated" );
-        return false;    
-    }
+    throw new IOException( "artifact file is missing or a directory: " + 
jarFile );
+}
 
-    
+File refFile = new File ( target, "reference.jar" );
+if ( !refFile.isFile() )
+{
+    throw new IOException( "reference file is missing or a directory: " + 
refFile );
 }
-catch( Throwable e )
+
+long referenceTimestamp = refFile.lastModified();
+System.out.println( "Reference timestamp: " + referenceTimestamp );
+
+long actualTimestamp = jarFile.lastModified();
+System.out.println( "Actual timestamp   : " + actualTimestamp );
+
+if ( referenceTimestamp >= actualTimestamp)
 {
-    e.printStackTrace();
-    result = false;
+    throw new Exception( "Timestamps match, JAR was not recreated although 
forced by configuration" );
 }
 
-return result;
+return true;


Reply via email to