Skip to content

Commit 5749210

Browse files
aurorasmileswizjany
authored andcommitted
Port build-logic from WorldEdit
1 parent fa357f4 commit 5749210

30 files changed

+719
-500
lines changed

.travis.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

build-logic/build.gradle.kts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
gradlePluginPortal()
7+
maven {
8+
name = "EngineHub Repository"
9+
url = uri("https://maven.enginehub.org/repo/")
10+
}
11+
}
12+
13+
dependencies {
14+
implementation(gradleApi())
15+
implementation(libs.licenser)
16+
implementation(libs.grgit)
17+
implementation(libs.shadow)
18+
implementation(libs.jfrog.buildinfo)
19+
implementation(libs.paperweight)
20+
implementation(libs.gson)
21+
22+
constraints {
23+
val asmVersion = "[${libs.versions.minimumAsm.get()},)"
24+
implementation("org.ow2.asm:asm:$asmVersion") {
25+
because("Need Java 21 support in shadow")
26+
}
27+
implementation("org.ow2.asm:asm-commons:$asmVersion") {
28+
because("Need Java 21 support in shadow")
29+
}
30+
implementation("org.vafer:jdependency:[${libs.versions.minimumJdependency.get()},)") {
31+
because("Need Java 21 support in shadow")
32+
}
33+
}
34+
}

build-logic/settings.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dependencyResolutionManagement {
2+
versionCatalogs {
3+
create("libs") {
4+
from(files("../gradle/libs.versions.toml"))
5+
}
6+
}
7+
}
8+
9+
rootProject.name = "build-logic"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention
2+
import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask
3+
4+
plugins {
5+
id("com.jfrog.artifactory")
6+
}
7+
8+
val ARTIFACTORY_CONTEXT_URL = "artifactory_contextUrl"
9+
val ARTIFACTORY_USER = "artifactory_user"
10+
val ARTIFACTORY_PASSWORD = "artifactory_password"
11+
12+
if (!project.hasProperty(ARTIFACTORY_CONTEXT_URL)) ext[ARTIFACTORY_CONTEXT_URL] = "http://localhost"
13+
if (!project.hasProperty(ARTIFACTORY_USER)) ext[ARTIFACTORY_USER] = "guest"
14+
if (!project.hasProperty(ARTIFACTORY_PASSWORD)) ext[ARTIFACTORY_PASSWORD] = ""
15+
16+
configure<ArtifactoryPluginConvention> {
17+
setContextUrl("${project.property(ARTIFACTORY_CONTEXT_URL)}")
18+
clientConfig.publisher.run {
19+
repoKey = when {
20+
"${project.version}".contains("SNAPSHOT") -> "libs-snapshot-local"
21+
else -> "libs-release-local"
22+
}
23+
username = "${project.property(ARTIFACTORY_USER)}"
24+
password = "${project.property(ARTIFACTORY_PASSWORD)}"
25+
isMaven = true
26+
isIvy = false
27+
}
28+
}
29+
30+
tasks.named<ArtifactoryTask>("artifactoryPublish") {
31+
isSkip = true
32+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
plugins {
2+
id("com.jfrog.artifactory")
3+
}
4+
5+
// Artifactory eagerly evaluates publications, so this must run after all changes to artifacts are done
6+
afterEvaluate {
7+
tasks.named<org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask>("artifactoryPublish") {
8+
publications("maven")
9+
}
10+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import buildlogic.getLibrary
2+
import buildlogic.stringyLibs
3+
4+
plugins {
5+
id("eclipse")
6+
id("idea")
7+
id("checkstyle")
8+
id("buildlogic.common")
9+
}
10+
11+
val commonJava = extensions.create<buildlogic.CommonJavaExtension>("commonJava")
12+
commonJava.banSlf4j.convention(true)
13+
14+
tasks
15+
.withType<JavaCompile>()
16+
.matching { it.name == "compileJava" || it.name == "compileTestJava" }
17+
.configureEach {
18+
val disabledLint = listOf(
19+
"processing", "path", "fallthrough", "serial", "overloads",
20+
)
21+
options.release.set(21)
22+
options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" })
23+
options.isDeprecation = true
24+
options.encoding = "UTF-8"
25+
options.compilerArgs.add("-parameters")
26+
//options.compilerArgs.add("-Werror")
27+
}
28+
29+
configure<CheckstyleExtension> {
30+
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
31+
toolVersion = "10.16.0"
32+
}
33+
34+
tasks.withType<Test>().configureEach {
35+
useJUnitPlatform()
36+
}
37+
38+
dependencies {
39+
"compileOnly"(stringyLibs.getLibrary("jsr305"))
40+
"testImplementation"(platform(stringyLibs.getLibrary("junit-bom")))
41+
"testImplementation"(stringyLibs.getLibrary("junit-jupiter-api"))
42+
"testImplementation"(stringyLibs.getLibrary("junit-jupiter-params"))
43+
"testImplementation"(platform(stringyLibs.getLibrary("mockito-bom")))
44+
"testImplementation"(stringyLibs.getLibrary("mockito-core"))
45+
"testImplementation"(stringyLibs.getLibrary("mockito-junit-jupiter"))
46+
"testRuntimeOnly"(stringyLibs.getLibrary("junit-jupiter-engine"))
47+
}
48+
49+
// Java 8 turns on doclint which we fail
50+
tasks.withType<Javadoc>().configureEach {
51+
options.encoding = "UTF-8"
52+
(options as StandardJavadocDocletOptions).apply {
53+
//addBooleanOption("Werror", true)
54+
addBooleanOption("Xdoclint:all", true)
55+
addBooleanOption("Xdoclint:-missing", true)
56+
tags(
57+
"apiNote:a:API Note:",
58+
"implSpec:a:Implementation Requirements:",
59+
"implNote:a:Implementation Note:"
60+
)
61+
}
62+
}
63+
64+
configure<JavaPluginExtension> {
65+
withJavadocJar()
66+
withSourcesJar()
67+
}
68+
69+
configurations["compileClasspath"].apply {
70+
resolutionStrategy.componentSelection {
71+
withModule("org.slf4j:slf4j-api") {
72+
if (commonJava.banSlf4j.get()) {
73+
reject("No SLF4J allowed on compile classpath")
74+
}
75+
}
76+
}
77+
}
78+
79+
tasks.named("check").configure {
80+
dependsOn("checkstyleMain", "checkstyleTest")
81+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import buildlogic.getLibrary
2+
import buildlogic.stringyLibs
3+
import org.gradle.plugins.ide.idea.model.IdeaModel
4+
5+
plugins {
6+
id("org.cadixdev.licenser")
7+
}
8+
9+
group = rootProject.group
10+
version = rootProject.version
11+
12+
repositories {
13+
mavenCentral()
14+
maven {
15+
name = "EngineHub"
16+
url = uri("https://maven.enginehub.org/repo/")
17+
}
18+
}
19+
20+
configurations.all {
21+
resolutionStrategy {
22+
cacheChangingModulesFor(1, TimeUnit.DAYS)
23+
}
24+
}
25+
26+
plugins.withId("java") {
27+
the<JavaPluginExtension>().toolchain {
28+
languageVersion.set(JavaLanguageVersion.of(21))
29+
}
30+
}
31+
32+
dependencies {
33+
for (conf in listOf("implementation", "api")) {
34+
if (!configurations.names.contains(conf)) {
35+
continue
36+
}
37+
add(conf, platform(stringyLibs.getLibrary("log4j-bom")).map {
38+
val dep = create(it)
39+
dep.because("Mojang provides Log4j")
40+
dep
41+
})
42+
constraints {
43+
add(conf, stringyLibs.getLibrary("guava")) {
44+
because("Mojang provides Guava")
45+
}
46+
add(conf, stringyLibs.getLibrary("gson")) {
47+
because("Mojang provides Gson")
48+
}
49+
add(conf, stringyLibs.getLibrary("fastutil")) {
50+
because("Mojang provides FastUtil")
51+
}
52+
}
53+
}
54+
}
55+
56+
license {
57+
header(rootProject.file("HEADER.txt"))
58+
include("**/*.java")
59+
include("**/*.kt")
60+
}
61+
62+
plugins.withId("idea") {
63+
configure<IdeaModel> {
64+
module {
65+
isDownloadSources = true
66+
isDownloadJavadoc = true
67+
}
68+
}
69+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
plugins {
2+
id("java")
3+
id("maven-publish")
4+
id("buildlogic.common-java")
5+
id("buildlogic.artifactory-sub")
6+
}
7+
8+
ext["internalVersion"] = "$version+${rootProject.ext["gitCommitHash"]}"
9+
10+
publishing {
11+
publications {
12+
register<MavenPublication>("maven") {
13+
versionMapping {
14+
usage("java-api") {
15+
fromResolutionOf("runtimeClasspath")
16+
}
17+
usage("java-runtime") {
18+
fromResolutionResult()
19+
}
20+
}
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)