Author: olamy Date: Sat Apr 28 21:11:01 2012 New Revision: 1331833 URL: http://svn.apache.org/viewvc?rev=1331833&view=rev Log: for exec war extraction mode, generate a file containing the archive timestamp creation to force reextract when users regenerate it and miss to reset extract folder.
Modified: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java Modified: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java?rev=1331833&r1=1331832&r2=1331833&view=diff ============================================================================== --- tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java (original) +++ tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java Sat Apr 28 21:11:01 2012 @@ -51,6 +51,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; +import java.util.Date; import java.util.Enumeration; import java.util.Iterator; import java.util.List; @@ -293,6 +294,7 @@ public abstract class AbstractExecWarMoj Properties properties = new Properties(); + properties.put( Tomcat7Runner.ARCHIVE_GENERATION_TIMESTAMP_KEY, Long.toString( new Date().getTime() ) ); properties.put( Tomcat7Runner.ENABLE_NAMING_KEY, Boolean.toString( enableNaming ) ); properties.put( Tomcat7Runner.ACCESS_LOG_VALVE_FORMAT_KEY, accessLogValveFormat ); properties.put( Tomcat7Runner.HTTP_PROTOCOL_KEY, connectorHttpProtocol ); @@ -369,7 +371,6 @@ public abstract class AbstractExecWarMoj IOUtils.copy( getClass().getResourceAsStream( "/conf/web.xml" ), os ); os.closeArchiveEntry(); - properties.store( tmpPropertiesFileOutputStream, "created by Apache Tomcat Maven plugin" ); tmpPropertiesFileOutputStream.flush(); Modified: tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java?rev=1331833&r1=1331832&r2=1331833&view=diff ============================================================================== --- tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java (original) +++ tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java Sat Apr 28 21:11:01 2012 @@ -33,6 +33,8 @@ import java.io.BufferedOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.InvocationTargetException; @@ -58,6 +60,8 @@ public class Tomcat7Runner // contains war name wars=foo.war,bar.war public static final String WARS_KEY = "wars"; + public static final String ARCHIVE_GENERATION_TIMESTAMP_KEY = "generationTimestamp"; + public static final String ENABLE_NAMING_KEY = "enableNaming"; public static final String ACCESS_LOG_VALVE_FORMAT_KEY = "accessLogValveFormat"; @@ -125,15 +129,48 @@ public class Tomcat7Runner debugMessage( "use extractDirectory:" + extractDirectoryFile.getPath() ); - // do we have to extract content - if ( !extractDirectoryFile.exists() || resetExtract ) + boolean archiveTimestampChanged = false; + + // compare timestamp stored during previous run if exists + File timestampFile = new File( extractDirectoryFile, ".tomcat_executable_archive.timestamp" ); + + Properties timestampProps = new Properties(); + + if ( timestampFile.exists() ) { - extract(); + timestampProps.load( new FileReader( timestampFile ) ); + String timestampValue = timestampProps.getProperty( Tomcat7Runner.ARCHIVE_GENERATION_TIMESTAMP_KEY ); + if ( timestampValue != null ) + { + long timestamp = Long.parseLong( timestampValue ); + archiveTimestampChanged = + Long.parseLong( runtimeProperties.getProperty( Tomcat7Runner.ARCHIVE_GENERATION_TIMESTAMP_KEY ) ) + > timestamp; + + debugMessage( "read timestamp from file " + timestampValue + ", archiveTimestampChanged: " + + archiveTimestampChanged ); + } + } - else + + // do we have to extract content { - String wars = runtimeProperties.getProperty( WARS_KEY ); - populateWebAppWarPerContext( wars ); + if ( !extractDirectoryFile.exists() || resetExtract ) + { + extract(); + // first run so create timestamp file + if ( !timestampFile.exists() ) + { + timestampProps.put( Tomcat7Runner.ARCHIVE_GENERATION_TIMESTAMP_KEY, runtimeProperties.getProperty( + Tomcat7Runner.ARCHIVE_GENERATION_TIMESTAMP_KEY ) ); + timestampProps.store( new FileWriter( timestampFile ), "Timestamp file for executable war/jar" ); + } + } + else + { + String wars = runtimeProperties.getProperty( WARS_KEY ); + populateWebAppWarPerContext( wars ); + } } // create tomcat various paths --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org