Skip to content

Commit a72a77b

Browse files
committed
modernize build scripts
1 parent acd1bdc commit a72a77b

9 files changed

Lines changed: 218 additions & 174 deletions

File tree

apirecorder/build.gradle

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

apirecorder/build.gradle.kts

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*
2+
* Copyright (c) 2021 Abex
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright notice, this
9+
* list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation
12+
* and/or other materials provided with the distribution.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
plugins {
26+
java
27+
jacoco
28+
}
29+
30+
repositories {
31+
maven {
32+
url = uri("https://repo.runelite.net")
33+
}
34+
mavenCentral()
35+
}
36+
37+
val testCore by sourceSets.creating
38+
val testPlugin by sourceSets.creating {
39+
compileClasspath += testCore.output
40+
}
41+
42+
dependencies {
43+
implementation(libs.slf4j.simple)
44+
implementation(libs.findbugs.jsr305)
45+
implementation(libs.guava)
46+
implementation(libs.asm)
47+
implementation(libs.gson)
48+
49+
testImplementation(libs.junit)
50+
51+
compileOnly(libs.lombok)
52+
annotationProcessor(libs.lombok)
53+
testCompileOnly(libs.lombok)
54+
testAnnotationProcessor(libs.lombok)
55+
}
56+
57+
tasks.withType<JavaCompile>().configureEach {
58+
// we can't use -release here because we need to --add-exports for the javac
59+
// internal apis
60+
sourceCompatibility = "11"
61+
targetCompatibility = "11"
62+
}
63+
64+
tasks.named<JavaCompile>("compileJava") {
65+
options.compilerArgs.addAll(listOf(
66+
"--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
67+
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
68+
))
69+
}
70+
71+
val testCoreJar = tasks.register<Jar>("testCoreJar") {
72+
archiveBaseName.set("test-core")
73+
from(sourceSets.getByName("testCore").output)
74+
}
75+
76+
val testClassApiFile = project.layout.buildDirectory.file("testCoreApi").get().asFile
77+
78+
val testCoreApi = tasks.register<JavaExec>("testCoreApi") {
79+
inputs.file(testCoreJar.get().archiveFile)
80+
outputs.file(testClassApiFile)
81+
classpath = sourceSets.main.get().runtimeClasspath
82+
mainClass.set("net.runelite.pluginhub.apirecorder.ClassRecorder")
83+
args(testClassApiFile, testCoreJar.get().archiveFile.get().asFile)
84+
}
85+
86+
tasks.named<Test>("test") {
87+
inputs.files(testCoreApi.get().outputs)
88+
inputs.files(testPlugin.allSource)
89+
90+
jvmArgs(
91+
"--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
92+
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
93+
)
94+
95+
systemProperties(mapOf(
96+
"runelite.apirecorder.test.classpath" to testPlugin.compileClasspath.files.joinToString(File.pathSeparator),
97+
"runelite.apirecorder.test.sourcepath" to testPlugin.allJava.files.joinToString(File.pathSeparator),
98+
))
99+
}
100+
101+
tasks.named<JacocoReport>("jacocoTestReport") {
102+
dependsOn(tasks.test)
103+
reports {
104+
xml.required.set(true)
105+
html.required.set(true)
106+
}
107+
}

build.gradle renamed to build.gradle.kts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,26 @@
2323
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
*/
2525
allprojects {
26-
version "2.0-SNAPSHOT"
27-
group "net.runelite.pluginhub"
28-
29-
tasks.withType(AbstractArchiveTask) {
30-
preserveFileTimestamps = false
31-
reproducibleFileOrder = true
32-
}
26+
version = "2.0-SNAPSHOT"
27+
group = "net.runelite.pluginhub"
3328
}
3429

3530
subprojects {
36-
apply plugin: "java"
37-
38-
java {
39-
sourceCompatibility = 11
31+
tasks.withType<AbstractArchiveTask> {
32+
isPreserveFileTimestamps = false
33+
isReproducibleFileOrder = true
4034
}
4135

42-
task shadowJar(type: Jar) {
43-
archiveFileName.set archiveBaseName.get() + "." + archiveExtension.get()
44-
from {
45-
configurations.runtimeClasspath.collect {
46-
it.isDirectory() ? it : zipTree(it)
47-
}
36+
plugins.withType<JavaPlugin> {
37+
print(tasks);
38+
tasks.register<Jar>("shadowJar") {
39+
archiveFileName.set(provider { archiveBaseName.get() + "." + archiveExtension.get() })
40+
from(project.provider {
41+
configurations.getByName("runtimeClasspath").map {
42+
if (it.isDirectory) it else zipTree(it)
43+
}
44+
})
45+
with(tasks.getByName<Jar>("jar"))
4846
}
49-
with tasks.jar
5047
}
5148
}

bundle/build.gradle.kts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import de.undercouch.gradle.tasks.download.Download
2626
import de.undercouch.gradle.tasks.download.Verify
2727

2828
plugins {
29-
id("de.undercouch.download") version "5.7.0"
29+
alias(libs.plugins.undercouch.download)
3030
}
3131

3232
val distURL = "https://services.gradle.org/distributions/gradle-8.10-bin.zip"
@@ -45,9 +45,9 @@ val verifyGradle = tasks.create<Verify>("verifyGradle") {
4545
}
4646

4747
val rtCopy = copySpec {
48-
from(arrayOf(":apirecorder", ":package", ":upload").map {
48+
from(provider { arrayOf(":apirecorder", ":package", ":upload").map {
4949
project(it).tasks.getByName<Jar>("shadowJar").archiveFile
50-
})
50+
}})
5151
from(file("src/main/resources"))
5252
from(zipTree(wrapperZip)) {
5353
eachFile {
@@ -59,7 +59,8 @@ val rtCopy = copySpec {
5959
var rtDeps = arrayOf(verifyGradle)
6060

6161
var tar = tasks.create<Tar>("tar") {
62-
archiveFileName = archiveBaseName.get() + "." + archiveExtension.get()
62+
archiveFileName = "bundle.tar"
63+
destinationDirectory = layout.buildDirectory.dir("distributions")
6364

6465
dependsOn(rtDeps)
6566
with(rtCopy)
@@ -127,14 +128,14 @@ var preparer = tasks.create<Exec>("preparer") {
127128
workingDir(rtDir)
128129
}
129130

130-
val testRuntime = configurations.create("testRuntime") {
131+
val testRuntime by configurations.creating {
131132
isCanBeConsumed = true
132133
isCanBeResolved = false
133134
}
134135
var rtArtifact = artifacts.add("testRuntime", rtDir) {
135136
builtBy(testRTSync, preparer, rlVersion, testVerificationMetadata)
136137
}
137138

138-
tasks.build {
139+
tasks.create("build") {
139140
dependsOn(rtArtifact, tar)
140141
}

gradle/libs.versions.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[versions]
2+
asm = "9.9.1"
3+
findbugs = "3.0.2"
4+
gradleToolingApi = "8.10"
5+
gson = "2.8.5"
6+
guava = "23.2-jre"
7+
junit = "4.12"
8+
lombok = "1.18.30"
9+
okhttp = "3.14.9"
10+
slf4jSimple = "1.7.10"
11+
undercouchDownload = "5.7.0"
12+
13+
[libraries]
14+
asm = { module = "org.ow2.asm:asm", version.ref = "asm" }
15+
findbugs-jsr305 = { module = "com.google.code.findbugs:jsr305", version.ref = "findbugs" }
16+
gradle-tooling-api = { module = "org.gradle:gradle-tooling-api", version.ref = "gradleToolingApi" }
17+
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
18+
guava = { module = "com.google.guava:guava", version.ref = "guava" }
19+
junit = { module = "junit:junit", version.ref = "junit" }
20+
lombok = { module = "org.projectlombok:lombok", version.ref = "lombok" }
21+
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
22+
okhttp-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttp" }
23+
slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4jSimple" }
24+
25+
[plugins]
26+
undercouch-download = { id = "de.undercouch.download", version.ref = "undercouchDownload" }

0 commit comments

Comments
 (0)