Signature configuration is now more configurable via the `freemarker.signMethod` property. The possible values are: none, gradle_properties, gpg_command.
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d97fbf8..9376121 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -52,7 +52,7 @@
uses: gradle/wrapper-validation-action@v1.1.0
- name: Run Build
id: build_step
- run: './gradlew --continue clean build -PsignPublication=false'
+ run: './gradlew "-Pfreemarker.signMethod=none" --continue clean build'
- name: Upload Failed Report
uses: actions/upload-artifact@v2.3.1
if: failure() && steps.build_step.outcome == 'failure'
diff --git a/build.gradle.kts b/build.gradle.kts
index 51ca745..35e32bf 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -337,7 +337,8 @@
}
}
}
- if (fmExt.doSignPackages.get()) {
+ if (fmExt.signMethod.needSignature()) {
+ fmExt.signMethod.configure(signing)
signing.sign(mainPublication)
}
}
@@ -359,6 +360,7 @@
fun registerDistSupportTasks(archiveTask: TaskProvider<Tar>) {
val signTask = tasks.register<freemarker.build.SignatureTask>("${archiveTask.name}Signature") {
+ signatureConfiguration.set(fmExt.signMethod)
inputFile.set(archiveTask.flatMap { task -> task.archiveFile })
}
@@ -370,7 +372,7 @@
dependsOn(archiveTask)
dependsOn(checksumTask)
- if (fmExt.doSignPackages.get()) {
+ if (fmExt.signMethod.needSignature()) {
dependsOn(signTask)
}
}
diff --git a/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootExtension.kt b/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootExtension.kt
index e7f069b..6683f0a 100644
--- a/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootExtension.kt
+++ b/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootExtension.kt
@@ -201,10 +201,10 @@
.gradleProperty("freemarker.javadoc.javaVersion")
.get()
- val doSignPackages = context.providers
- .gradleProperty("signPublication")
- .map { it.toBoolean() }
- .orElse(true)
+ val signMethod = context.providers
+ .gradleProperty("freemarker.signMethod")
+ .map { SignatureConfiguration.valueOf(it.uppercase()) }
+ .get()
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 c7bb172..bbb2fb0 100644
--- a/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootPlugin.kt
+++ b/buildSrc/src/main/kotlin/freemarker/build/FreemarkerRootPlugin.kt
@@ -91,7 +91,7 @@
if (ext.versionService.developmentBuild) {
throw IllegalStateException("The development build configuration is active!")
}
- if (!ext.doSignPackages.get()) {
+ if (!ext.signMethod.needSignature()) {
throw IllegalStateException("Package signing is disabled!")
}
}
diff --git a/buildSrc/src/main/kotlin/freemarker/build/SignatureConfiguration.kt b/buildSrc/src/main/kotlin/freemarker/build/SignatureConfiguration.kt
new file mode 100644
index 0000000..12ae3ca
--- /dev/null
+++ b/buildSrc/src/main/kotlin/freemarker/build/SignatureConfiguration.kt
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package freemarker.build
+
+import org.gradle.plugins.signing.SigningExtension
+
+enum class SignatureConfiguration {
+ NONE,
+ GPG_COMMAND {
+ override fun configure(ext: SigningExtension) {
+ ext.useGpgCmd()
+ }
+ },
+ GRADLE_PROPERTIES;
+
+ fun needSignature() = this != NONE
+
+ open fun configure(ext: SigningExtension) {
+ }
+}
diff --git a/buildSrc/src/main/kotlin/freemarker/build/SignatureTask.kt b/buildSrc/src/main/kotlin/freemarker/build/SignatureTask.kt
index 6e51994..0b9f094 100644
--- a/buildSrc/src/main/kotlin/freemarker/build/SignatureTask.kt
+++ b/buildSrc/src/main/kotlin/freemarker/build/SignatureTask.kt
@@ -24,18 +24,23 @@
import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.model.ObjectFactory
+import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
+import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
+import org.gradle.kotlin.dsl.property
import org.gradle.kotlin.dsl.the
import org.gradle.plugins.signing.SigningExtension
open class SignatureTask @Inject constructor(
objects: ObjectFactory
) : DefaultTask() {
+ @Input
+ val signatureConfiguration: Property<SignatureConfiguration> = objects.property()
@InputFile
@PathSensitive(PathSensitivity.NONE)
@@ -48,6 +53,10 @@
@TaskAction
fun signFile() {
- signing.sign(inputFile.get().asFile)
+ val config = signatureConfiguration.get()
+ if (config.needSignature()) {
+ config.configure(signing)
+ signing.sign(inputFile.get().asFile)
+ }
}
}
diff --git a/gradle.properties b/gradle.properties
index 29b98ea..9a9e336 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -18,3 +18,6 @@
freemarker.javaVersion=8
freemarker.javadoc.javaVersion=16
freemarker.test.javaVersion=16
+
+# Allowed values: "none", "gradle_properties", "gpg_command"
+freemarker.signMethod=none