You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/10/09 13:08:58 UTC

[tomcat] 01/02: Fix BZ 64784. Don't include timestamp in .java file when pre-compiling

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 374690d5793248f26d5894a33bb5ed562e22da91
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Oct 9 14:02:50 2020 +0100

    Fix BZ 64784. Don't include timestamp in .java file when pre-compiling
---
 java/org/apache/jasper/JspC.java               | 13 +++++++++++++
 java/org/apache/jasper/Options.java            | 12 ++++++++++++
 java/org/apache/jasper/compiler/Generator.java |  6 ++++--
 webapps/docs/changelog.xml                     |  6 ++++++
 4 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/jasper/JspC.java b/java/org/apache/jasper/JspC.java
index ff28ed1..3804d2a 100644
--- a/java/org/apache/jasper/JspC.java
+++ b/java/org/apache/jasper/JspC.java
@@ -1124,6 +1124,19 @@ public class JspC extends Task implements Options {
         return tagPluginManager;
     }
 
+
+    /**
+     * {@inheritDoc}
+     * <p>
+     * Hard-coded to {@code false} for pre-compiled code to enable repeatable
+     * builds.
+     */
+    @Override
+    public boolean getGeneratedJavaAddTimestamp() {
+        return false;
+    }
+
+
     /**
      * Adds servlet declaration and mapping for the JSP page servlet to the
      * generated web.xml fragment.
diff --git a/java/org/apache/jasper/Options.java b/java/org/apache/jasper/Options.java
index 4b100aa..19f3947 100644
--- a/java/org/apache/jasper/Options.java
+++ b/java/org/apache/jasper/Options.java
@@ -360,4 +360,16 @@ public interface Options {
     public default boolean getUseInstanceManagerForTags() {
         return false;
     }
+
+
+    /**
+     * Should the container include the time the file was generated in the
+     * comments at the start of a Java file generated from a JSP or tag.
+     * Defaults to {@code true}.
+     *
+     * @return {@code true} to include the timestamp, otherwise don't include it
+     */
+    public default boolean getGeneratedJavaAddTimestamp() {
+        return true;
+    }
 }
diff --git a/java/org/apache/jasper/compiler/Generator.java b/java/org/apache/jasper/compiler/Generator.java
index bcd0412..21593d8 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -3669,8 +3669,10 @@ class Generator {
         out.println("/*");
         out.println(" * Generated by the Jasper component of Apache Tomcat");
         out.println(" * Version: " + ctxt.getServletContext().getServerInfo());
-        out.println(" * Generated at: " + timestampFormat.format(new Date()) +
-                " UTC");
+        if (ctxt.getOptions().getGeneratedJavaAddTimestamp()) {
+            out.println(" * Generated at: " + timestampFormat.format(new Date()) +
+                    " UTC");
+        }
         out.println(" * Note: The last modified time of this file was set to");
         out.println(" *       the last modified time of the source file after");
         out.println(" *       generation to assist with modification tracking.");
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 68859ce..691ec31 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -74,6 +74,12 @@
   <subsection name="Jasper">
     <changelog>
       <fix>
+        <bug>64784</bug>: Don't include the time the Java file was generated as
+        a comment when generating Java files for JSPs and/or tags if the Java
+        file was created during pre-compilation. This is to aid repeatable
+        builds. (markt)
+      </fix>
+      <fix>
         <bug>64794</bug>: Security exception reading system property on
         JspRuntimeLibrary use. (remm)
       </fix>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org