-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #678 from playframework/gradle
Gradle Support
- Loading branch information
Showing
30 changed files
with
1,702 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,5 @@ project/plugins/project/ | |
.idea | ||
|
||
.bloop/ | ||
|
||
compiler/version.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# | ||
# https://help.github.com/articles/dealing-with-line-endings/ | ||
# | ||
# Linux start script should use lf | ||
/gradlew text eol=lf | ||
|
||
# These are Windows script files and should use crlf | ||
*.bat text eol=crlf | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Ignore Gradle project-specific cache directory | ||
.gradle | ||
|
||
# Ignore Gradle build output directory | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
* Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
import java.time.Duration | ||
import java.util.Base64 | ||
import java.util.Properties | ||
import kotlin.text.Charsets.UTF_8 | ||
|
||
plugins { | ||
alias(libs.plugins.gradle.plugin.publish) | ||
alias(libs.plugins.nexus.publish) | ||
alias(libs.plugins.spotless) | ||
signing | ||
} | ||
|
||
val compilerVersion: String = | ||
Properties().apply { | ||
val file = file("$projectDir/../compiler/version.properties") | ||
if (!file.exists()) throw GradleException("Install Twirl Compiler to local Maven repository by `sbt +compiler/publishM2` command") | ||
file.inputStream().use { load(it) } | ||
if (this.getProperty("twirl.compiler.version") | ||
.isNullOrEmpty() | ||
) { | ||
throw GradleException("`twirl.compiler.version` key didn't find in ${file.absolutePath}") | ||
} | ||
}.getProperty("twirl.compiler.version") | ||
|
||
val isRelease = !compilerVersion.endsWith("SNAPSHOT") | ||
|
||
group = "org.playframework.twirl" | ||
version = compilerVersion | ||
|
||
repositories { | ||
mavenCentral() | ||
mavenLocal() | ||
} | ||
|
||
dependencies { | ||
compileOnly("org.playframework.twirl:twirl-compiler_2.13:$compilerVersion") | ||
testImplementation(libs.assertj) | ||
testImplementation(libs.commons.io) | ||
testImplementation(libs.freemarker) | ||
} | ||
|
||
tasks.jar { | ||
manifest { | ||
attributes("Implementation-Version" to version) | ||
} | ||
} | ||
|
||
@Suppress("UnstableApiUsage") | ||
testing { | ||
suites { | ||
val test by getting(JvmTestSuite::class) { | ||
useJUnitJupiter() | ||
targets { | ||
all { | ||
testTask.configure { | ||
systemProperty("twirl.version", compilerVersion) | ||
project.findProperty("scala.version")?.let { scalaVersion -> | ||
val ver = (scalaVersion as String).trimEnd { !it.isDigit() } | ||
systemProperty("scala.version", ver) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
isRequired = isRelease | ||
if (isRelease) { | ||
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() | ||
} | ||
} | ||
|
||
@Suppress("UnstableApiUsage") | ||
gradlePlugin { | ||
website.set("https://www.playframework.com/documentation/latest/ScalaTemplates") | ||
vcsUrl.set("https://github.com/playframework/twirl") | ||
val twirl by plugins.creating { | ||
id = "org.playframework.twirl" | ||
displayName = "Twirl Plugin" | ||
description = "A Gradle plugin to compile Twirl templates" | ||
tags.set(listOf("playframework", "web", "template", "java", "scala")) | ||
implementationClass = "play.twirl.gradle.TwirlPlugin" | ||
} | ||
} | ||
|
||
val headerLicense = | ||
"Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com>" | ||
val headerLicenseHash = "# $headerLicense" | ||
val headerLicenseJava = "/*\n * $headerLicense\n */" | ||
|
||
spotless { | ||
java { | ||
googleJavaFormat() | ||
licenseHeader(headerLicenseJava) | ||
} | ||
kotlinGradle { | ||
licenseHeader(headerLicenseJava, "[^/*]") | ||
} | ||
format("properties") { | ||
target("**/*.properties") | ||
targetExclude("gradle/**") | ||
licenseHeader(headerLicenseHash, "[^#]") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com> | ||
|
||
org.gradle.parallel=true | ||
org.gradle.caching=true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[versions] | ||
gradle-plugin-publish = "1.2.0" | ||
nexus-publish = "1.3.0" | ||
spotless = "6.19.0" | ||
assertj = "3.24.2" | ||
commons-io = "2.13.0" | ||
freemarker = "2.3.32" | ||
|
||
[libraries] | ||
assertj = { group = "org.assertj", name = "assertj-core", version.ref = "assertj" } | ||
commons-io = { group = "commons-io", name = "commons-io", version.ref = "commons-io" } | ||
freemarker = { group = "org.freemarker", name = "freemarker", version.ref = "freemarker" } | ||
|
||
[plugins] | ||
gradle-plugin-publish = { id = "com.gradle.plugin-publish", version.ref = "gradle-plugin-publish" } | ||
nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexus-publish" } | ||
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionSha256Sum=f2b9ed0faf8472cbe469255ae6c86eddb77076c75191741b4a462f33128dd419 | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.