You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2023/12/26 10:13:46 UTC

(freemarker) branch 2.3-gae updated: Build: Added freemarker.allowUnsignedReleaseBuild Gradle property, and set it to true in the GitHub "CI" action

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

ddekany pushed a commit to branch 2.3-gae
in repository https://gitbox.apache.org/repos/asf/freemarker.git


The following commit(s) were added to refs/heads/2.3-gae by this push:
     new 06914fa5 Build: Added freemarker.allowUnsignedReleaseBuild Gradle property, and set it to true in the GitHub "CI" action
06914fa5 is described below

commit 06914fa59ec5803cd881c819ac3c1bbc296fe8f6
Author: ddekany <dd...@apache.org>
AuthorDate: Tue Dec 26 10:59:47 2023 +0100

    Build: Added freemarker.allowUnsignedReleaseBuild Gradle property, and set it to true in the GitHub "CI" action
---
 .github/workflows/ci.yml                                    |  2 +-
 README.md                                                   |  6 ++++--
 .../main/kotlin/freemarker/build/FreemarkerRootExtension.kt |  5 +++++
 .../main/kotlin/freemarker/build/FreemarkerRootPlugin.kt    | 13 +++++--------
 gradle.properties                                           |  3 +++
 5 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 93761211..ef7730d7 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -52,7 +52,7 @@ jobs:
         uses: gradle/wrapper-validation-action@v1.1.0
       - name: Run Build
         id: build_step
-        run: './gradlew "-Pfreemarker.signMethod=none" --continue clean build'
+        run: './gradlew "-Pfreemarker.signMethod=none" "-Pfreemarker.allowUnsignedReleaseBuild=true" --continue clean build'
       - name: Upload Failed Report
         uses: actions/upload-artifact@v2.3.1
         if: failure() && steps.build_step.outcome == 'failure'
diff --git a/README.md b/README.md
index d3424c20..5c23bd74 100644
--- a/README.md
+++ b/README.md
@@ -129,8 +129,10 @@ To see how the project would be deployed to Maven Central, issue
 `./gradlew publishAllPublicationsToLocalRepository`,
 and check the `build/local-deployment` directory.
 
-To also build the distribution artifacts (the `tgz`-s that people can download), run `./gradlew build`. However,
-for a stable version you will also need to set up signing; see `gradle.properties` in this project for pointers.  
+To build the distribution artifacts (the `tgz`-s that people can download), run `./gradlew build`.However,
+
+For a stable (non-SNAPSHOT) version number, you will need to set up signing, or disable that verification;
+see `gradle.properties` in this project for those!  
 
 See `gradle.properties` for some Gradle properties that you may what to set,
 especially if you are building a release.
diff --git a/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootExtension.kt b/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootExtension.kt
index dfdd9b3d..c54c491f 100644
--- a/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootExtension.kt
+++ b/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootExtension.kt
@@ -206,6 +206,11 @@ class FreemarkerRootExtension constructor(
         .map { SignatureConfiguration.valueOf(it.uppercase()) }
         .get()
 
+    val allowUnsignedReleaseBuild = context.providers
+        .gradleProperty("allowUnsignedReleaseBuild")
+        .map { it.toBoolean() }
+        .getOrElse(false)
+
     private val allConfiguredSourceSetNamesRef = project.objects.setProperty<String>()
     val allConfiguredSourceSetNames: Provider<Set<String>> = allConfiguredSourceSetNamesRef
 
diff --git a/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootPlugin.kt b/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootPlugin.kt
index bbb2fb07..f30c5bf1 100644
--- a/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootPlugin.kt
+++ b/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootPlugin.kt
@@ -28,11 +28,7 @@ import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
 import org.gradle.api.tasks.SourceSet
 import org.gradle.api.tasks.bundling.Jar
 import org.gradle.jvm.toolchain.JavaLanguageVersion
-import org.gradle.kotlin.dsl.configure
-import org.gradle.kotlin.dsl.filter
-import org.gradle.kotlin.dsl.named
-import org.gradle.kotlin.dsl.the
-import org.gradle.kotlin.dsl.withType
+import org.gradle.kotlin.dsl.*
 import org.gradle.language.base.plugins.LifecycleBasePlugin
 import org.gradle.language.jvm.tasks.ProcessResources
 
@@ -89,10 +85,11 @@ open class FreemarkerRootPlugin : Plugin<Project> {
 
                 doLast {
                     if (ext.versionService.developmentBuild) {
-                        throw IllegalStateException("The development build configuration is active!")
+                        throw IllegalStateException("The development build configuration is active, which is not allowed for release versions!")
                     }
-                    if (!ext.signMethod.needSignature()) {
-                        throw IllegalStateException("Package signing is disabled!")
+                    if (!ext.signMethod.needSignature() && !ext.allowUnsignedReleaseBuild) {
+                        throw IllegalStateException("Package signing is disabled, which is not allowed for release versions! "
+                                + "(For testing purposes only, you may set the   Gradle property to false)")
                     }
                 }
             }
diff --git a/gradle.properties b/gradle.properties
index 874f1fd6..6e773bf5 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -30,6 +30,9 @@ freemarker.signMethod=none
 #   signing.secretKeyRingFile=...
 # - For gpg_command, you need GNU Privacy Guard installed, and you don't have to set anything if it's on the path.
 
+# To allow building for a releasable version number when freemarker.signMethod=none. Only use for CI, and local testing!
+#freemarker.allowUnsignedReleaseBuild=false
+
 # To publish to the Apache Maven repo (for staging), somewhere you have to set these:
 #freemarker.deploy.apache.user=<your user name at the ASF>
 #freemarker.deploy.apache.password=<your regular ASF password>