Skip to content

Commit

Permalink
Migrate Gradle build scripts to kts (#968)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler authored Sep 13, 2024
1 parent b31d9ec commit 7623448
Show file tree
Hide file tree
Showing 12 changed files with 202 additions and 179 deletions.
15 changes: 15 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
implementation("com.gradle.publish:plugin-publish-plugin:1.3.0")
implementation("com.vanniktech:gradle-maven-publish-plugin:0.29.0")
implementation("org.ajoberstar.git-publish:gradle-git-publish:4.2.2")
implementation("com.github.node-gradle:gradle-node-plugin:7.0.2")
}
37 changes: 37 additions & 0 deletions build-logic/src/main/kotlin/shadow.convention.deploy.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import org.apache.tools.ant.filters.ReplaceTokens

plugins {
id("org.ajoberstar.git-publish")
id("com.github.node-gradle.node")
}

gitPublish {
repoUri = "https://github.com/GradleUp/shadow.git"
branch = "gh-pages"
contents {
from("build/site")
into("api") {
from(tasks.named("groovydoc"))
}
filter<ReplaceTokens>(
"tokens" to mapOf(
"version" to version,
"snapshot-version" to "$version-SNAPSHOT",
)
)
}
}

node {
yarnVersion = "1.5.1"
}

val yarnBuild = tasks.named("yarn_build") {
inputs.files(fileTree("src/docs"))
outputs.dir(file("build/site"))
dependsOn(tasks.yarn)
}

tasks.gitPublishCopy {
dependsOn(yarnBuild, tasks.named("groovydoc"))
}
47 changes: 47 additions & 0 deletions build-logic/src/main/kotlin/shadow.convention.publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
plugins {
id("com.gradle.plugin-publish")
id("com.vanniktech.maven.publish")
}

version = providers.gradleProperty("VERSION_NAME").get()
group = providers.gradleProperty("GROUP").get()
description = providers.gradleProperty("POM_DESCRIPTION").get()

java {
withSourcesJar()
withJavadocJar()
}

gradlePlugin {
website = providers.gradleProperty("POM_URL")
vcsUrl = providers.gradleProperty("POM_URL")

plugins {
create("shadowPlugin") {
id = "com.gradleup.shadow"
implementationClass = "com.github.jengelman.gradle.plugins.shadow.ShadowPlugin"
displayName = providers.gradleProperty("POM_NAME").get()
description = providers.gradleProperty("POM_DESCRIPTION").get()
tags = listOf("onejar", "shade", "fatjar", "uberjar")
}
}
}

tasks.publishPlugins {
doFirst {
if (version.toString().endsWith("SNAPSHOT")) {
error("Cannot publish SNAPSHOT versions to Plugin Portal!")
}
}
notCompatibleWithConfigurationCache("https://github.com/gradle/gradle/issues/21283")
}

tasks.withType<Javadoc>().configureEach {
(options as? StandardJavadocDocletOptions)?.let {
it.links(
"https://docs.oracle.com/javase/17/docs/api",
"https://docs.groovy-lang.org/2.4.7/html/gapi/"
)
it.addStringOption("Xdoclint:none", "-quiet")
}
}
43 changes: 0 additions & 43 deletions build.gradle

This file was deleted.

71 changes: 71 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
plugins {
groovy
`java-gradle-plugin`
id("shadow.convention.publish")
id("shadow.convention.deploy")
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
compileOnly(localGroovy())

implementation("org.jdom:jdom2:2.0.6.1")
implementation("org.ow2.asm:asm:9.7")
implementation("org.ow2.asm:asm-commons:9.7")
implementation("commons-io:commons-io:2.16.1")
implementation("org.apache.ant:ant:1.10.15")
implementation("org.codehaus.plexus:plexus-utils:4.0.1")
implementation("org.codehaus.plexus:plexus-xml:4.0.4")
implementation("org.apache.logging.log4j:log4j-core:2.24.0")
implementation("org.vafer:jdependency:2.10") {
exclude(group = "org.ow2.asm")
}

testImplementation("org.spockframework:spock-core:2.3-groovy-3.0") {
exclude(group = "org.codehaus.groovy")
}
testImplementation("org.spockframework:spock-junit4:2.3-groovy-3.0")
testImplementation("xmlunit:xmlunit:1.6")
testImplementation("org.apache.commons:commons-lang3:3.17.0")
testImplementation("com.google.guava:guava:33.3.0-jre")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.0")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.11.0")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

val isCI = providers.environmentVariable("CI").isPresent

tasks.withType<Test>().configureEach {
useJUnitPlatform()

maxParallelForks = Runtime.getRuntime().availableProcessors()

if (isCI) {
testLogging.showStandardStreams = true
minHeapSize = "1g"
maxHeapSize = "1g"
}

systemProperty("shadowVersion", version)

// Required to test configuration cache in tests when using withDebug()
// https://github.com/gradle/gradle/issues/22765#issuecomment-1339427241
jvmArgs(
"--add-opens", "java.base/java.util=ALL-UNNAMED",
"--add-opens", "java.base/java.util.concurrent.atomic=ALL-UNNAMED",
"--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED",
"--add-opens", "java.base/java.net=ALL-UNNAMED",
)
}

tasks.register("release") {
dependsOn(
tasks.publish,
tasks.publishPlugins,
tasks.gitPublishPush,
)
}
26 changes: 0 additions & 26 deletions gradle/dependencies.gradle

This file was deleted.

16 changes: 0 additions & 16 deletions gradle/docs.gradle

This file was deleted.

20 changes: 0 additions & 20 deletions gradle/ghPages.gradle

This file was deleted.

33 changes: 0 additions & 33 deletions gradle/publish.gradle

This file was deleted.

11 changes: 0 additions & 11 deletions gradle/vuepress.gradle

This file was deleted.

30 changes: 0 additions & 30 deletions settings.gradle

This file was deleted.

32 changes: 32 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}

includeBuild("build-logic")
}

plugins {
id("com.gradle.develocity") version "3.18.1"
}

develocity {
buildScan {
termsOfUseUrl = "https://gradle.com/terms-of-service"
termsOfUseAgree = "yes"
// TODO: workaround for https://github.com/gradle/gradle/issues/22879.
val isCI = providers.environmentVariable("CI").isPresent
publishing.onlyIf { isCI }
}
}

dependencyResolutionManagement {
repositories {
mavenCentral()
}
}

rootProject.name = "shadow"

enableFeaturePreview("STABLE_CONFIGURATION_CACHE")

0 comments on commit 7623448

Please sign in to comment.