diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 2421c024..669b449c 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -13,11 +13,21 @@ concurrency: cancel-in-progress: true jobs: + # Run Gradle Wrapper Validation to verify the wrapper's checksum + gradle-validation: + name: Gradle Wrapper + uses: playframework/.github/.github/workflows/gradle-wrapper-validation.yml@gradle # TODO: change version to v3 + check-code-style: name: Code Style - uses: playframework/.github/.github/workflows/cmd.yml@v3 + needs: + - "gradle-validation" + uses: playframework/.github/.github/workflows/cmd.yml@gradle # TODO: change version to v3 with: - cmd: sbt validateCode + gradle-build-root: gradle-twirl + cmd: | + sbt validateCode + cd gradle-twirl && ./gradlew clean spotlessCheck --no-daemon check-binary-compatibility: name: Binary Compatibility @@ -37,11 +47,12 @@ jobs: - "check-code-style" - "check-binary-compatibility" - "check-docs" - uses: playframework/.github/.github/workflows/cmd.yml@v3 + uses: playframework/.github/.github/workflows/cmd.yml@gradle # TODO: change version to v3 with: java: 17, 11 scala: 2.12.x, 2.13.x, 3.x cmd: scripts/test-code.sh + gradle-build-root: gradle-twirl finish: name: Finish diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 92e6f544..9230748b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,12 +4,31 @@ on: push: branches: # Snapshots - main + - gradle # TODO: remove this line tags: ["**"] # Releases release: types: [published] jobs: - publish-artifacts: + publish-snapshot-artifacts: name: Publish / Artifacts - uses: playframework/.github/.github/workflows/publish.yml@v3 + if: github.ref_type == 'branch' # Snapshots + uses: playframework/.github/.github/workflows/publish.yml@gradle # TODO: change version to v3 + with: + gradle-build-root: gradle-twirl + cmd: | + cd gradle-twirl + ./gradlew --no-daemon publishToSonatype -x test -PsonatypeUsername="$SONATYPE_USERNAME" -PsonatypePassword="$SONATYPE_PASSWORD" + secrets: inherit + + publish-release-artifacts: + name: Publish / Artifacts + if: github.ref_type == 'tag' # Releases + uses: playframework/.github/.github/workflows/publish.yml@gradle # TODO: change version to v3 + with: + gradle-build-root: gradle-twirl + cmd: | + sbt ci-release + cd gradle-twirl + ./gradlew --no-daemon publishPlugins -x test -Pgradle.publish.key="$GRADLE_PUBLISH_KEY" -Pgradle.publish.secret="$GRADLE_PUBLISH_SECRET" secrets: inherit diff --git a/gradle-twirl/build.gradle.kts b/gradle-twirl/build.gradle.kts index dfa84fd3..16de9f6d 100644 --- a/gradle-twirl/build.gradle.kts +++ b/gradle-twirl/build.gradle.kts @@ -2,12 +2,21 @@ * Copyright (C) from 2022 The Play Framework Contributors , 2011-2021 Lightbend Inc. */ +import java.time.Duration +import java.util.Base64 +import kotlin.text.Charsets.UTF_8 + plugins { - // Apply the Java Gradle plugin development plugin to add support for developing Gradle plugins - `java-gradle-plugin` + id("com.gradle.plugin-publish") version "1.2.0" + id("io.github.gradle-nexus.publish-plugin") version "1.3.0" id("com.diffplug.spotless") version "6.19.0" + signing } +// group = "com.playframework" // group and plugin id must use same top level namespace +group = "com.typesafe.play" // TODO: remove this line +version = "0.0.1-SNAPSHOT" + repositories { // Use Maven Central for resolving dependencies. mavenCentral() @@ -38,10 +47,30 @@ testing { } } +signing { + val signingKey = Base64.getDecoder().decode(System.getenv("PGP_SECRET").orEmpty()).toString(UTF_8) + val signingPassword = System.getenv("PGP_PASSPHRASE").orEmpty() + useInMemoryPgpKeys(signingKey, signingPassword) +} + +nexusPublishing { + packageGroup.set(project.group.toString()) + clientTimeout.set(Duration.ofMinutes(60)) + this.repositories { + sonatype() + } +} + gradlePlugin { + website.set("https://www.playframework.com/documentation/latest/ScalaTemplates") + vcsUrl.set("https://github.com/playframework/twirl") // Define the plugin val greeting by plugins.creating { - id = "com.playframework.twirl" +// id = "com.playframework.twirl" + id = "com.typesafe.play.twirl" // TODO: remove this line + displayName = "Twirl Plugin" + description = "A Gradle plugin to compile Twirl templates" + tags.set(listOf("playframework", "web", "template", "java", "scala")) implementationClass = "play.twirl.gradle.TwirlPlugin" } } diff --git a/gradle-twirl/src/functionalTest/java/play/twirl/gradle/TwirlPluginFunctionalTest.java b/gradle-twirl/src/functionalTest/java/play/twirl/gradle/TwirlPluginFunctionalTest.java index f4e55d1c..9f1632da 100644 --- a/gradle-twirl/src/functionalTest/java/play/twirl/gradle/TwirlPluginFunctionalTest.java +++ b/gradle-twirl/src/functionalTest/java/play/twirl/gradle/TwirlPluginFunctionalTest.java @@ -29,7 +29,7 @@ private File getSettingsFile() { @Test void canRunTask() throws IOException { writeString(getSettingsFile(), ""); - writeString(getBuildFile(), "plugins {" + " id('com.playframework.twirl')" + "}"); + writeString(getBuildFile(), "plugins {" + " id('com.typesafe.play.twirl')" + "}"); // Run the build GradleRunner runner = GradleRunner.create(); diff --git a/gradle-twirl/src/test/java/play/twirl/gradle/TwirlPluginTest.java b/gradle-twirl/src/test/java/play/twirl/gradle/TwirlPluginTest.java index aea245ee..96c15513 100644 --- a/gradle-twirl/src/test/java/play/twirl/gradle/TwirlPluginTest.java +++ b/gradle-twirl/src/test/java/play/twirl/gradle/TwirlPluginTest.java @@ -15,7 +15,7 @@ class TwirlPluginTest { void pluginRegistersATask() { // Create a test project and apply the plugin Project project = ProjectBuilder.builder().build(); - project.getPlugins().apply("com.playframework.twirl"); + project.getPlugins().apply("com.typesafe.play.twirl"); // Verify the result assertNotNull(project.getTasks().findByName("greeting")); diff --git a/scripts/test-code.sh b/scripts/test-code.sh index 263e968a..5e2f1d51 100755 --- a/scripts/test-code.sh +++ b/scripts/test-code.sh @@ -4,3 +4,4 @@ sbt "++$MATRIX_SCALA test" || exit 1 sbt +publishLocal plugin/test plugin/scripted || exit 1 +(cd gradle-twirl && ./gradlew clean check -x spotlessCheck --no-daemon) || exit 1