Skip to content

Commit

Permalink
Clean up Gradle configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
octylFractal committed Apr 30, 2024
1 parent c1f0927 commit 79cba4e
Show file tree
Hide file tree
Showing 85 changed files with 631 additions and 9,056 deletions.
24 changes: 1 addition & 23 deletions buildSrc/build.gradle.kts → build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,7 @@ plugins {
}

repositories {
maven {
name = "PaperMC"
url = uri("https://repo.papermc.io/repository/maven-public/")
content {
includeGroupAndSubgroups("io.papermc")
}
}
maven {
name = "NeoForged Maven"
url = uri("https://maven.neoforged.net/releases")
content {
includeGroupAndSubgroups("net.neoforged")
}
}
mavenCentral()
gradlePluginPortal()
maven {
name = "Fabric"
url = uri("https://maven.fabricmc.net/")
}
maven {
name = "EngineHub Repository"
url = uri("https://maven.enginehub.org/repo/")
Expand All @@ -36,11 +17,8 @@ dependencies {
implementation(libs.japicmp)
implementation(libs.shadow)
implementation(libs.jfrog.buildinfo)
implementation(libs.neoGradle.userdev)
implementation(libs.fabric.loom)
implementation(libs.fabric.mixin)
implementation(libs.codecov)
implementation(libs.paperweight)
implementation(libs.gson)
constraints {
val asmVersion = "[${libs.versions.minimumAsm.get()},)"
implementation("org.ow2.asm:asm:$asmVersion") {
Expand Down
File renamed without changes.
26 changes: 26 additions & 0 deletions build-logic/src/main/kotlin/buildlogic.adapter.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import buildlogic.stringyLibs
import buildlogic.getVersion

plugins {
`java-library`
id("buildlogic.common")
id("buildlogic.common-java")
id("io.papermc.paperweight.userdev")
}

configure<buildlogic.CommonJavaExtension> {
banSlf4j = false
}

dependencies {
"implementation"(project(":worldedit-bukkit"))
constraints {
"remapper"("net.fabricmc:tiny-remapper:[${stringyLibs.getVersion("minimumTinyRemapper")},)") {
because("Need remapper to support Java 21")
}
}
}

tasks.named("assemble") {
dependsOn("reobfJar")
}
35 changes: 35 additions & 0 deletions build-logic/src/main/kotlin/buildlogic.artifactory-root.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.named
import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention
import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask

plugins {
id("com.jfrog.artifactory")
}

val ARTIFACTORY_CONTEXT_URL = "artifactory_contextUrl"
val ARTIFACTORY_USER = "artifactory_user"
val ARTIFACTORY_PASSWORD = "artifactory_password"

if (!project.hasProperty(ARTIFACTORY_CONTEXT_URL)) ext[ARTIFACTORY_CONTEXT_URL] = "http://localhost"
if (!project.hasProperty(ARTIFACTORY_USER)) ext[ARTIFACTORY_USER] = "guest"
if (!project.hasProperty(ARTIFACTORY_PASSWORD)) ext[ARTIFACTORY_PASSWORD] = ""

configure<ArtifactoryPluginConvention> {
setContextUrl("${project.property(ARTIFACTORY_CONTEXT_URL)}")
clientConfig.publisher.run {
repoKey = when {
"${project.version}".contains("SNAPSHOT") -> "libs-snapshot-local"
else -> "libs-release-local"
}
username = "${project.property(ARTIFACTORY_USER)}"
password = "${project.property(ARTIFACTORY_PASSWORD)}"
isMaven = true
isIvy = false
}
}

tasks.named<ArtifactoryTask>("artifactoryPublish") {
isSkip = true
}
10 changes: 10 additions & 0 deletions build-logic/src/main/kotlin/buildlogic.artifactory-sub.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
id("com.jfrog.artifactory")
}

// Artifactory eagerly evaluates publications, so this must run after all changes to artifacts are done
afterEvaluate {
tasks.named<org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask>("artifactoryPublish") {
publications("maven")
}
}
82 changes: 82 additions & 0 deletions build-logic/src/main/kotlin/buildlogic.common-java.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import buildlogic.stringyLibs
import buildlogic.getLibrary

plugins {
id("eclipse")
id("idea")
id("checkstyle")
id("buildlogic.common")
}

val commonJava = extensions.create<buildlogic.CommonJavaExtension>("commonJava")
commonJava.banSlf4j.convention(true)

tasks
.withType<JavaCompile>()
.matching { it.name == "compileJava" || it.name == "compileTestJava" }
.configureEach {
// TODO: re-enable this-escape when ANTLR suppresses it properly
val disabledLint = listOf(
"processing", "path", "fallthrough", "serial", "overloads", "this-escape",
)
options.release.set(21)
options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" })
options.isDeprecation = true
options.encoding = "UTF-8"
options.compilerArgs.add("-parameters")
options.compilerArgs.add("-Werror")
}

configure<CheckstyleExtension> {
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
toolVersion = "9.1"
}

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

dependencies {
"compileOnly"(stringyLibs.getLibrary("jsr305"))
"testImplementation"(platform(stringyLibs.getLibrary("junit-bom")))
"testImplementation"(stringyLibs.getLibrary("junit-jupiter-api"))
"testImplementation"(stringyLibs.getLibrary("junit-jupiter-params"))
"testImplementation"(platform(stringyLibs.getLibrary("mockito-bom")))
"testImplementation"(stringyLibs.getLibrary("mockito-core"))
"testImplementation"(stringyLibs.getLibrary("mockito-junit-jupiter"))
"testRuntimeOnly"(stringyLibs.getLibrary("junit-jupiter-engine"))
}

// Java 8 turns on doclint which we fail
tasks.withType<Javadoc>().configureEach {
options.encoding = "UTF-8"
(options as StandardJavadocDocletOptions).apply {
addBooleanOption("Werror", true)
addBooleanOption("Xdoclint:all", true)
addBooleanOption("Xdoclint:-missing", true)
tags(
"apiNote:a:API Note:",
"implSpec:a:Implementation Requirements:",
"implNote:a:Implementation Note:"
)
}
}

configure<JavaPluginExtension> {
withJavadocJar()
withSourcesJar()
}

configurations["compileClasspath"].apply {
resolutionStrategy.componentSelection {
withModule("org.slf4j:slf4j-api") {
if (commonJava.banSlf4j.get()) {
reject("No SLF4J allowed on compile classpath")
}
}
}
}

tasks.named("check").configure {
dependsOn("checkstyleMain", "checkstyleTest")
}
68 changes: 68 additions & 0 deletions build-logic/src/main/kotlin/buildlogic.common.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import buildlogic.getLibrary
import buildlogic.stringyLibs
import org.gradle.plugins.ide.idea.model.IdeaModel

plugins {
id("org.cadixdev.licenser")
}

group = rootProject.group
version = rootProject.version

repositories {
maven {
name = "EngineHub"
url = uri("https://maven.enginehub.org/repo/")
}
}

configurations.all {
resolutionStrategy {
cacheChangingModulesFor(1, TimeUnit.DAYS)
}
}

plugins.withId("java") {
the<JavaPluginExtension>().toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}

dependencies {
for (conf in listOf("implementation", "api")) {
if (!configurations.names.contains(conf)) {
continue
}
add(conf, platform(stringyLibs.getLibrary("log4j-bom")).map {
val dep = create(it)
dep.because("Mojang provides Log4j")
dep
})
constraints {
add(conf, stringyLibs.getLibrary("guava")) {
because("Mojang provides Guava")
}
add(conf, stringyLibs.getLibrary("gson")) {
because("Mojang provides Gson")
}
add(conf, stringyLibs.getLibrary("fastutil")) {
because("Mojang provides FastUtil")
}
}
}
}

license {
header(rootProject.file("HEADER.txt"))
include("**/*.java")
include("**/*.kt")
}

plugins.withId("idea") {
configure<IdeaModel> {
module {
isDownloadSources = true
isDownloadJavadoc = true
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
id("java")
id("maven-publish")
id("buildlogic.common-java")
id("buildlogic.artifactory-sub")
}

ext["internalVersion"] = "$version+${rootProject.ext["gitCommitHash"]}"

publishing {
publications {
register<MavenPublication>("maven") {
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
}
}
}
Loading

0 comments on commit 79cba4e

Please sign in to comment.