Skip to content

Commit 16ea462

Browse files
authored
Merge pull request #2100 from aurorasmiles/feat/buildlogic
Port buildlogic from WorldEdit
2 parents c6fbfb8 + ca49458 commit 16ea462

29 files changed

+650
-485
lines changed

.travis.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
plugins {
22
`kotlin-dsl`
3-
kotlin("jvm") version embeddedKotlinVersion
43
}
54

65
repositories {
7-
mavenCentral()
86
gradlePluginPortal()
97
}
108

119
dependencies {
1210
implementation(gradleApi())
13-
implementation("gradle.plugin.org.cadixdev.gradle:licenser:0.6.1")
14-
implementation("org.ajoberstar.grgit:grgit-gradle:5.2.2")
15-
implementation("com.github.johnrengelman:shadow:8.1.1")
16-
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:5.2.0")
11+
implementation(libs.licenser)
12+
implementation(libs.grgit)
13+
implementation(libs.shadow)
14+
implementation(libs.jfrog.buildinfo)
15+
implementation(libs.gson)
16+
1717
constraints {
18-
val asmVersion = "[9.7,)"
18+
val asmVersion = "[${libs.versions.minimumAsm.get()},)"
1919
implementation("org.ow2.asm:asm:$asmVersion") {
2020
because("Need Java 21 support in shadow")
2121
}
2222
implementation("org.ow2.asm:asm-commons:$asmVersion") {
2323
because("Need Java 21 support in shadow")
2424
}
25-
implementation("org.vafer:jdependency:[2.10,)") {
25+
implementation("org.vafer:jdependency:[${libs.versions.minimumJdependency.get()},)") {
2626
because("Need Java 21 support in shadow")
2727
}
2828
}
29-
}
29+
}

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: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
tasks
12+
.withType<JavaCompile>()
13+
.matching { it.name == "compileJava" || it.name == "compileTestJava" }
14+
.configureEach {
15+
val disabledLint = listOf(
16+
"processing", "path", "fallthrough", "serial", "overloads",
17+
)
18+
options.release.set(21)
19+
options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" })
20+
options.isDeprecation = true
21+
options.encoding = "UTF-8"
22+
options.compilerArgs.add("-parameters")
23+
//options.compilerArgs.add("-Werror")
24+
}
25+
26+
configure<CheckstyleExtension> {
27+
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
28+
toolVersion = "10.16.0"
29+
}
30+
31+
tasks.withType<Test>().configureEach {
32+
useJUnitPlatform()
33+
}
34+
35+
dependencies {
36+
"compileOnly"(stringyLibs.getLibrary("jsr305"))
37+
"testImplementation"(platform(stringyLibs.getLibrary("junit-bom")))
38+
"testImplementation"(stringyLibs.getLibrary("junit-jupiter-api"))
39+
"testImplementation"(stringyLibs.getLibrary("junit-jupiter-params"))
40+
"testRuntimeOnly"(stringyLibs.getLibrary("junit-jupiter-engine"))
41+
}
42+
43+
// Java 8 turns on doclint which we fail
44+
tasks.withType<Javadoc>().configureEach {
45+
options.encoding = "UTF-8"
46+
(options as StandardJavadocDocletOptions).apply {
47+
//addBooleanOption("Werror", true)
48+
addBooleanOption("Xdoclint:all", true)
49+
addBooleanOption("Xdoclint:-missing", true)
50+
tags(
51+
"apiNote:a:API Note:",
52+
"implSpec:a:Implementation Requirements:",
53+
"implNote:a:Implementation Note:"
54+
)
55+
}
56+
}
57+
58+
configure<JavaPluginExtension> {
59+
withJavadocJar()
60+
withSourcesJar()
61+
}
62+
63+
tasks.named("check").configure {
64+
dependsOn("checkstyleMain", "checkstyleTest")
65+
}
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)