Build: Reproducible build conde cleanup, and more documentation for it.
diff --git a/README.md b/README.md
index 5c23bd7..e282628 100644
--- a/README.md
+++ b/README.md
@@ -137,6 +137,9 @@
See `gradle.properties` for some Gradle properties that you may what to set,
especially if you are building a release.
+Reproducible builds: If the resulting `freemarker.jar` is not identical with the official jar, see the build environment
+in the `.buildinfo` file packed into the official source distribution, and also into the Maven "sources" artifact!
+
IDE setup
---------
diff --git a/build.gradle.kts b/build.gradle.kts
index fc37519..be443d8 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -17,11 +17,11 @@
* under the License.
*/
+import java.io.FileOutputStream
import java.nio.charset.StandardCharsets
import java.nio.file.Files
+import java.util.*
import java.util.stream.Collectors
-import java.util.Properties
-import java.io.FileOutputStream
plugins {
`freemarker-root`
@@ -99,6 +99,9 @@
}
sourceSets.main.get().java.srcDir(compileJavacc)
+fun buildInfoFile(): File
+ = project.layout.buildDirectory.get().asFile.resolve("buildinfo").resolve(".buildinfo")
+
tasks.sourcesJar.configure {
from(compileJavacc.flatMap { it.sourceDirectory })
@@ -108,9 +111,7 @@
// Depend on the createBuildInfo task and include the generated file
dependsOn(createBuildInfo)
- from(File(project.buildDir, "tmp/buildinfo")) {
- include(".buildinfo")
- }
+ from(buildInfoFile())
}
tasks.javadocJar.configure {
@@ -422,7 +423,7 @@
val jarFile = tasks.named<Jar>("jar").flatMap { jar -> jar.archiveFile }
from(jarFile) {
- rename { name -> "freemarker.jar" }
+ rename { _ -> "freemarker.jar" }
}
from(tasks.named("manualOffline")) {
@@ -435,10 +436,9 @@
}
registerDistSupportTasks(distBin)
-// Task to generate buildinfo.properties
val createBuildInfo = tasks.register("createBuildInfo") {
doLast {
- val buildInfoFile = File(project.buildDir, "tmp/buildinfo/.buildinfo")
+ val buildInfoFile = buildInfoFile()
buildInfoFile.parentFile.mkdirs()
val props = Properties().apply {
@@ -458,7 +458,7 @@
}
FileOutputStream(buildInfoFile).use { outputStream ->
- props.store(outputStream, "Effective recorded build environment information")
+ props.store(outputStream, " Build environment information recorded for reproducible builds")
}
}
}
@@ -495,12 +495,9 @@
)
}
-
// Depend on the createBuildInfo task and include the generated file
dependsOn(createBuildInfo)
- from(File(project.buildDir, "tmp/buildinfo")) {
- include(".buildinfo")
- }
+ from(buildInfoFile())
}
registerDistSupportTasks(distSrc)
diff --git a/freemarker-core/src/main/java/freemarker/template/Configuration.java b/freemarker-core/src/main/java/freemarker/template/Configuration.java
index a2d9dcc..331f5ae 100644
--- a/freemarker-core/src/main/java/freemarker/template/Configuration.java
+++ b/freemarker-core/src/main/java/freemarker/template/Configuration.java
@@ -26,10 +26,8 @@
import java.net.URLConnection;
import java.text.Collator;
import java.text.DecimalFormat;
-import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -3704,8 +3702,8 @@
* do NOT use this as the value of the {@code incompatible_improvements} setting (as the parameter to
* {@link Configuration#Configuration(Version)}), as then your application can break when you upgrade FreeMarker!
* Use a constant value, like {@link #VERSION_2_3_28}, to protect your application from fixes/changes that aren't
- * entirely backward compatible. Fixes and features that are backward compatible are always enabled.
- *
+ * entirely backward compatible. Fixes and features that are backward compatible are always enabled.
+ *
* On FreeMarker version numbering rules:
* <ul>
* <li>For final/stable releases the version number is like major.minor.micro, like 2.3.19. (Historically,
@@ -3728,7 +3726,10 @@
* Also, "pre" and "rc" was lowercase, and was followd by a number without 0-padding.</li>
* </ul>
* </ul>
- *
+ *
+ * <p>Starting from 2.3.33, {@link Version#getBuildDate()} will return {@code null}, as we don't store the build
+ * date anymore, to make the build reproducible.
+ *
* @since 2.3.20
*/
public static Version getVersion() {
diff --git a/freemarker-core/src/main/java/freemarker/template/Version.java b/freemarker-core/src/main/java/freemarker/template/Version.java
index ac25be1..24b7501 100644
--- a/freemarker-core/src/main/java/freemarker/template/Version.java
+++ b/freemarker-core/src/main/java/freemarker/template/Version.java
@@ -229,7 +229,9 @@
}
/**
- * @deprecated do not used anymore
+ * @deprecated Will always return {@code null} for the FreeMarker version, as we can't store the build date anymore
+ * in the jar, in order to have a reproducible build.
+ *
* @return The build date if known, or {@code null}.
*/
public Date getBuildDate() {
diff --git a/freemarker-manual/src/main/docgen/en_US/book.xml b/freemarker-manual/src/main/docgen/en_US/book.xml
index e194205..dfeadb1 100644
--- a/freemarker-manual/src/main/docgen/en_US/book.xml
+++ b/freemarker-manual/src/main/docgen/en_US/book.xml
@@ -30279,6 +30279,15 @@
</listitem>
<listitem>
+ <para><literal>Configuration.getVersion().getBuildDate()</literal>
+ will now always return <literal>null</literal>, as we don't
+ store the build date anymore, to make the build reproducible.
+ For same reason, <literal>META-INF/MANIFEST.FM</literal> now
+ will not store any timestamps, nor information about the build
+ environment.</para>
+ </listitem>
+
+ <listitem>
<para>Build changes (in case you build FreeMarker itself, not
just depend on it):</para>
@@ -30302,6 +30311,13 @@
<para>JavaDoc is now generated with JDK 16 (so now we have
search on it)</para>
</listitem>
+
+ <listitem>
+ <para>The build is now reproducible (see <link
+ xlink:href="https://reproducible-builds.org">reproducible-builds.org</link>).
+ However, therefore it doesn't contain any build timestamps
+ anymore.</para>
+ </listitem>
</itemizedlist>
</listitem>