diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts new file mode 100644 index 000000000..a46a0281c --- /dev/null +++ b/build-logic/build.gradle.kts @@ -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") +} diff --git a/build-logic/src/main/kotlin/shadow.convention.deploy.gradle.kts b/build-logic/src/main/kotlin/shadow.convention.deploy.gradle.kts new file mode 100644 index 000000000..891cae3c4 --- /dev/null +++ b/build-logic/src/main/kotlin/shadow.convention.deploy.gradle.kts @@ -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( + "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")) +} diff --git a/build-logic/src/main/kotlin/shadow.convention.publish.gradle.kts b/build-logic/src/main/kotlin/shadow.convention.publish.gradle.kts new file mode 100644 index 000000000..5bdf3bcea --- /dev/null +++ b/build-logic/src/main/kotlin/shadow.convention.publish.gradle.kts @@ -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().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") + } +} diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 8cd8b83bb..000000000 --- a/build.gradle +++ /dev/null @@ -1,43 +0,0 @@ -plugins { - id 'groovy' - id 'java-gradle-plugin' - id 'com.gradle.plugin-publish' version '1.3.0' - id 'org.ajoberstar.git-publish' version '4.2.2' - id 'com.github.node-gradle.node' version '7.0.2' - id 'com.vanniktech.maven.publish' version "0.29.0" -} - -apply from: file('gradle/docs.gradle') -apply from: file('gradle/publish.gradle') -apply from: file('gradle/vuepress.gradle') -apply from: file('gradle/ghPages.gradle') -apply from: file('gradle/dependencies.gradle') - -java { - sourceCompatibility = '1.8' - targetCompatibility = '1.8' -} - -tasks.withType(Test).configureEach { - useJUnitPlatform() - - // https://docs.gradle.org/8.8/userguide/performance.html#execute_tests_in_parallel - maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 - - if (System.env.CI == 'true') { - 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", - ) -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..6c61b9e89 --- /dev/null +++ b/build.gradle.kts @@ -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().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, + ) +} diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle deleted file mode 100644 index 19f98713e..000000000 --- a/gradle/dependencies.gradle +++ /dev/null @@ -1,26 +0,0 @@ -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' -} diff --git a/gradle/docs.gradle b/gradle/docs.gradle deleted file mode 100644 index 6b7b6172c..000000000 --- a/gradle/docs.gradle +++ /dev/null @@ -1,16 +0,0 @@ -def javaApiUrl = 'https://docs.oracle.com/javase/17/docs/api' -def groovyApiUrl = "https://docs.groovy-lang.org/2.4.7/html/gapi/" - -tasks.withType(Javadoc).configureEach { - options.links(javaApiUrl, groovyApiUrl) - if (JavaVersion.current().java8Compatible) { - options.addStringOption('Xdoclint:none', '-quiet') - } -} - -java { - withJavadocJar() - withSourcesJar() -} - -tasks.named('build') { dependsOn javadocJar, sourcesJar } diff --git a/gradle/ghPages.gradle b/gradle/ghPages.gradle deleted file mode 100644 index a848658f1..000000000 --- a/gradle/ghPages.gradle +++ /dev/null @@ -1,20 +0,0 @@ -import org.apache.tools.ant.filters.ReplaceTokens - -apply plugin: 'org.ajoberstar.git-publish' - -gitPublish { - repoUri = 'https://github.com/GradleUp/shadow.git' - - branch = 'gh-pages' - - contents { - from 'build/site' - into('api') { - from project.tasks.groovydoc - } - filter(ReplaceTokens, tokens: [version: project.version]) - } -} - -tasks.named('gitPublishCopy') { dependsOn tasks.named('yarn_build') } -tasks.named('gitPublishCopy') { dependsOn tasks.named('groovydoc') } diff --git a/gradle/publish.gradle b/gradle/publish.gradle deleted file mode 100644 index 4a4f6fe6b..000000000 --- a/gradle/publish.gradle +++ /dev/null @@ -1,33 +0,0 @@ -apply plugin: "com.gradle.plugin-publish" -apply plugin: "com.vanniktech.maven.publish" - -group = providers.gradleProperty("GROUP").get() -version = providers.gradleProperty("VERSION_NAME").get() - -gradlePlugin { - website = providers.gradleProperty("POM_URL") - vcsUrl = providers.gradleProperty("POM_URL") - - plugins { - 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 = ['onejar', 'shade', 'fatjar', 'uberjar'] - } - } -} - -tasks.named('publishPlugins') { - doFirst { - if (version.endsWith("SNAPSHOT")) { - throw new GradleException('Cannot publish SNAPSHOT versions to Plugin Portal!') - } - } - notCompatibleWithConfigurationCache("https://github.com/gradle/gradle/issues/21283") -} - -tasks.register('release') { - dependsOn tasks.named('publish'), tasks.named('publishPlugins'), tasks.named('gitPublishPush') -} diff --git a/gradle/vuepress.gradle b/gradle/vuepress.gradle deleted file mode 100644 index 58df23d9f..000000000 --- a/gradle/vuepress.gradle +++ /dev/null @@ -1,11 +0,0 @@ -apply plugin: "com.github.node-gradle.node" - -node { - yarnVersion = '1.5.1' -} - -tasks.named('yarn_build') { - inputs.files project.fileTree('src/docs') - outputs.dir project.file('build/site') - dependsOn("yarn") -} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 4e8f1ff7c..000000000 --- a/settings.gradle +++ /dev/null @@ -1,30 +0,0 @@ -pluginManagement { - repositories { - mavenCentral() - gradlePluginPortal() - } -} - -plugins { - id 'com.gradle.develocity' version '3.18.1' -} - -dependencyResolutionManagement { - repositories { - mavenCentral() - } -} - -def isCI = providers.environmentVariable('CI').present - -develocity { - buildScan { - termsOfUseUrl = 'https://gradle.com/terms-of-service' - termsOfUseAgree = 'yes' - publishing.onlyIf { isCI } - } -} - -enableFeaturePreview("STABLE_CONFIGURATION_CACHE") - -rootProject.name = 'shadow' \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 000000000..ff5bcd337 --- /dev/null +++ b/settings.gradle.kts @@ -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") \ No newline at end of file