gradle: Bootstrap plugin
This commit is contained in:
@@ -74,7 +74,6 @@ subprojects {
|
|||||||
apply<MavenPlugin>()
|
apply<MavenPlugin>()
|
||||||
apply<MavenPublishPlugin>()
|
apply<MavenPublishPlugin>()
|
||||||
apply(plugin = Plugins.testLogger.first)
|
apply(plugin = Plugins.testLogger.first)
|
||||||
apply<FernflowerPlugin>()
|
|
||||||
|
|
||||||
if (this.name != "rs-client") apply(plugin = "checkstyle")
|
if (this.name != "rs-client") apply(plugin = "checkstyle")
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation(gradleApi())
|
implementation(gradleApi())
|
||||||
implementation(group = "net.runelite", name = "fernflower", version = "07082019")
|
implementation(group = "net.runelite", name = "fernflower", version = "07082019")
|
||||||
|
implementation(group = "org.json", name = "json", version = "20190722")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinDslPluginOptions {
|
kotlinDslPluginOptions {
|
||||||
|
|||||||
87
buildSrc/src/main/kotlin/BootstrapPlugin.kt
Normal file
87
buildSrc/src/main/kotlin/BootstrapPlugin.kt
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.get
|
||||||
|
import org.gradle.kotlin.dsl.register
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
class BootstrapPlugin : Plugin<Project> {
|
||||||
|
override fun apply(project: Project) {
|
||||||
|
project.tasks.register<BootstrapTask>("bootstrapStaging") {
|
||||||
|
dependsOn("jar")
|
||||||
|
dependsOn("shadowJar")
|
||||||
|
|
||||||
|
type = "staging"
|
||||||
|
clientJar = project.tasks["jar"].outputs.files.singleFile
|
||||||
|
|
||||||
|
dependsOn(project.parent!!.project(":runelite-api").tasks["jar"])
|
||||||
|
dependsOn(project.parent!!.project(":runescape-api").tasks["jar"])
|
||||||
|
dependsOn(project.parent!!.project(":http-api").tasks["jar"])
|
||||||
|
dependsOn(project.parent!!.project(":injected-client").tasks["jar"])
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
|
||||||
|
project.copy {
|
||||||
|
from(project.tasks["jar"])
|
||||||
|
from(project.parent!!.project(":runelite-api").tasks["jar"])
|
||||||
|
from(project.parent!!.project(":runescape-api").tasks["jar"])
|
||||||
|
from(project.parent!!.project(":http-api").tasks["jar"])
|
||||||
|
from(project.parent!!.project(":injected-client").tasks["jar"])
|
||||||
|
|
||||||
|
into("${project.buildDir}/bootstrap/${type}/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.tasks.register<BootstrapTask>("bootstrapStable") {
|
||||||
|
dependsOn("jar")
|
||||||
|
dependsOn("shadowJar")
|
||||||
|
|
||||||
|
type = "stable"
|
||||||
|
clientJar = project.tasks["jar"].outputs.files.singleFile
|
||||||
|
|
||||||
|
dependsOn(project.parent!!.project(":runelite-api").tasks["jar"])
|
||||||
|
dependsOn(project.parent!!.project(":runescape-api").tasks["jar"])
|
||||||
|
dependsOn(project.parent!!.project(":http-api").tasks["jar"])
|
||||||
|
dependsOn(project.parent!!.project(":injected-client").tasks["jar"])
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
|
||||||
|
project.copy {
|
||||||
|
from(project.tasks["jar"])
|
||||||
|
from(project.parent!!.project(":runelite-api").tasks["jar"])
|
||||||
|
from(project.parent!!.project(":runescape-api").tasks["jar"])
|
||||||
|
from(project.parent!!.project(":http-api").tasks["jar"])
|
||||||
|
from(project.parent!!.project(":injected-client").tasks["jar"])
|
||||||
|
|
||||||
|
into("${project.buildDir}/bootstrap/${type}/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.tasks.register<BootstrapTask>("bootstrapNightly") {
|
||||||
|
dependsOn("jar")
|
||||||
|
dependsOn("shadowJar")
|
||||||
|
|
||||||
|
type = "nightly"
|
||||||
|
clientJar = project.tasks["jar"].outputs.files.singleFile
|
||||||
|
|
||||||
|
dependsOn(project.parent!!.project(":runelite-api").tasks["jar"])
|
||||||
|
dependsOn(project.parent!!.project(":runescape-api").tasks["jar"])
|
||||||
|
dependsOn(project.parent!!.project(":http-api").tasks["jar"])
|
||||||
|
dependsOn(project.parent!!.project(":injected-client").tasks["jar"])
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
|
||||||
|
project.copy {
|
||||||
|
from(project.tasks["jar"])
|
||||||
|
from(project.parent!!.project(":runelite-api").tasks["jar"])
|
||||||
|
from(project.parent!!.project(":runescape-api").tasks["jar"])
|
||||||
|
from(project.parent!!.project(":http-api").tasks["jar"])
|
||||||
|
from(project.parent!!.project(":injected-client").tasks["jar"])
|
||||||
|
|
||||||
|
into("${project.buildDir}/bootstrap/${type}/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
101
buildSrc/src/main/kotlin/BootstrapTask.kt
Normal file
101
buildSrc/src/main/kotlin/BootstrapTask.kt
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.tasks.Input
|
||||||
|
import org.gradle.api.tasks.InputFile
|
||||||
|
import org.gradle.api.tasks.Optional
|
||||||
|
import org.gradle.api.tasks.PathSensitive
|
||||||
|
import org.gradle.api.tasks.PathSensitivity
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
import org.gradle.kotlin.dsl.extra
|
||||||
|
import org.gradle.kotlin.dsl.get
|
||||||
|
import java.io.File
|
||||||
|
import java.security.MessageDigest
|
||||||
|
|
||||||
|
open class BootstrapTask : DefaultTask() {
|
||||||
|
|
||||||
|
@Input
|
||||||
|
@Optional
|
||||||
|
var type: String? = "stable"
|
||||||
|
|
||||||
|
@InputFile
|
||||||
|
@PathSensitive(PathSensitivity.ABSOLUTE)
|
||||||
|
var clientJar: File? = null
|
||||||
|
|
||||||
|
@Input
|
||||||
|
val launcherJvm11Arguments = arrayOf("-XX:+DisableAttachMechanism", "-Drunelite.launcher.nojvm=true", "-Xmx512m", "-Xss2m", "-XX:CompileThreshold=1500", "-Djna.nosys=true")
|
||||||
|
|
||||||
|
@Input
|
||||||
|
val launcherArguments = arrayOf("-XX:+DisableAttachMechanism", "-Drunelite.launcher.nojvm=true", "-Xmx512m", "-Xss2m", "-XX:CompileThreshold=1500", "-Xincgc", "-XX:+UseConcMarkSweepGC", "-XX:+UseParNewGC", "-Djna.nosys=true")
|
||||||
|
|
||||||
|
@Input
|
||||||
|
val clientJvmArguments = arrayOf("-XX:+DisableAttachMechanism", "-Xmx512m", "-Xss2m", "-XX:CompileThreshold=1500", "-Xincgc", "-XX:+UseConcMarkSweepGC", "-XX:+UseParNewGC", "-Djna.nosys=true")
|
||||||
|
|
||||||
|
@Input
|
||||||
|
val clientJvm9Arguments = arrayOf("-XX:+DisableAttachMechanism", "-Xmx512m", "-Xss2m", "-XX:CompileThreshold=1500", "-Djna.nosys=true")
|
||||||
|
|
||||||
|
private fun hash(file: ByteArray): String {
|
||||||
|
return MessageDigest.getInstance("SHA-256").digest(file).fold("", { str, it -> str + "%02x".format(it) })
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getArtifacts(): Array<JsonBuilder> {
|
||||||
|
val artifacts = ArrayList<JsonBuilder>()
|
||||||
|
|
||||||
|
project.configurations["runtimeClasspath"].resolvedConfiguration.resolvedArtifacts.forEach {
|
||||||
|
val module = it.moduleVersion.id.toString()
|
||||||
|
|
||||||
|
val name = module.split(":")[1]
|
||||||
|
val group = module.split(":")[0]
|
||||||
|
val version = module.split(":")[2]
|
||||||
|
var path = ""
|
||||||
|
|
||||||
|
if (it.file.name.contains(ProjectVersions.rlVersion)) {
|
||||||
|
path = "https://github.com/open-osrs/hosting/raw/master/${type}/${it.file.name}"
|
||||||
|
} else if (!group.contains("runelite")) {
|
||||||
|
path = "https://repo.maven.apache.org/maven2/" + group.replace(".", "/") + "/${name}/$version/${name}-$version"
|
||||||
|
if (it.classifier != null && it.classifier != "no_aop") {
|
||||||
|
path += "-${it.classifier}"
|
||||||
|
}
|
||||||
|
path += ".jar"
|
||||||
|
} else if (it.file.name.contains("trident") || it.file.name.contains("discord") || it.file.name.contains("substance")) {
|
||||||
|
path = "https://repo.runelite.net/net/runelite/"
|
||||||
|
if (!it.file.name.contains("discord")) {
|
||||||
|
path += "pushingpixels/"
|
||||||
|
}
|
||||||
|
path += "${name}/$version/${name}-$version.jar"
|
||||||
|
}
|
||||||
|
|
||||||
|
val artifactFile = File(it.file.absolutePath)
|
||||||
|
|
||||||
|
artifacts.add(JsonBuilder(
|
||||||
|
"name" to it.file.name,
|
||||||
|
"path" to path,
|
||||||
|
"size" to artifactFile.length(),
|
||||||
|
"hash" to hash(artifactFile.readBytes())
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts.add(JsonBuilder(
|
||||||
|
"name" to clientJar!!.name,
|
||||||
|
"path" to "https://github.com/open-osrs/hosting/raw/master/${type}/${clientJar!!.name}",
|
||||||
|
"size" to clientJar!!.length(),
|
||||||
|
"hash" to hash(clientJar!!.readBytes())
|
||||||
|
))
|
||||||
|
|
||||||
|
return artifacts.toTypedArray()
|
||||||
|
}
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
fun boostrap() {
|
||||||
|
val json = JsonBuilder(
|
||||||
|
"projectVersion" to ProjectVersions.openosrsVersion,
|
||||||
|
"minimumLauncherVersion" to ProjectVersions.launcherVersion,
|
||||||
|
"launcherJvm11Arguments" to launcherJvm11Arguments,
|
||||||
|
"launcherArguments" to launcherArguments,
|
||||||
|
"clientJvmArguments" to clientJvmArguments,
|
||||||
|
"clientJvm9Arguments" to clientJvm9Arguments,
|
||||||
|
"buildCommit" to project.extra["gitCommit"],
|
||||||
|
"artifacts" to getArtifacts()
|
||||||
|
).toString()
|
||||||
|
|
||||||
|
project.file("${project.buildDir}/bootstrap/bootstrap-${type}.json").writeText(json)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.tasks.StopExecutionException
|
import org.gradle.api.tasks.StopExecutionException
|
||||||
|
import org.gradle.api.tasks.diagnostics.DependencyReportTask
|
||||||
|
import org.gradle.kotlin.dsl.register
|
||||||
|
|
||||||
class FernflowerPlugin : Plugin<Project> {
|
class FernflowerPlugin : Plugin<Project> {
|
||||||
override fun apply(project: Project) {
|
override fun apply(project: Project) {
|
||||||
project.tasks.create("decompile", FernflowerTask::class.java).run {
|
project.tasks.register<FernflowerTask>("decompile") {
|
||||||
dependsOn(project.tasks.getByName("jar"))
|
dependsOn(project.tasks.getByName("jar"))
|
||||||
|
|
||||||
doFirst {
|
doFirst {
|
||||||
|
|||||||
@@ -26,12 +26,10 @@ open class FernflowerTask: DefaultTask() {
|
|||||||
|
|
||||||
@InputFile
|
@InputFile
|
||||||
@PathSensitive(PathSensitivity.ABSOLUTE)
|
@PathSensitive(PathSensitivity.ABSOLUTE)
|
||||||
var getInputJar = project.file(inputJar ?: project.buildDir.toString() + "/libs/" + project.name + '-'
|
var getInputJar = project.file(inputJar ?: "${project.buildDir}/libs/${project.name}-${project.version}.jar")
|
||||||
+ project.version + ".jar")
|
|
||||||
|
|
||||||
@OutputDirectory
|
@OutputDirectory
|
||||||
@PathSensitive(PathSensitivity.ABSOLUTE)
|
var getOutputDir = project.file(outputDir ?: "${project.buildDir}/decompiled-sources")
|
||||||
var getOutputDir = project.file(outputDir ?: project.buildDir.toString() + "/decompiled-sources")
|
|
||||||
|
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
|
|||||||
55
buildSrc/src/main/kotlin/JsonBuilder.kt
Normal file
55
buildSrc/src/main/kotlin/JsonBuilder.kt
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import org.json.JSONArray
|
||||||
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
class JsonBuilder() {
|
||||||
|
private var json = JSONObject()
|
||||||
|
|
||||||
|
constructor(vararg pairs: Pair<String, *>) : this() {
|
||||||
|
add(*pairs)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun add(vararg pairs: Pair<String, *>) {
|
||||||
|
for ((key, value) in pairs) {
|
||||||
|
when (value) {
|
||||||
|
is Boolean -> json.put(key, value)
|
||||||
|
is Number -> add(key, value)
|
||||||
|
is String -> json.put(key, value)
|
||||||
|
is JsonBuilder -> json.put(key, value.json)
|
||||||
|
is Array<*> -> add(key, value)
|
||||||
|
is JSONObject -> json.put(key, value)
|
||||||
|
is JSONArray -> json.put(key, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun add(key: String, value: Number): JsonBuilder {
|
||||||
|
when (value) {
|
||||||
|
is Int -> json.put(key, value)
|
||||||
|
is Long -> json.put(key, value)
|
||||||
|
is Float -> json.put(key, value)
|
||||||
|
is Double -> json.put(key, value)
|
||||||
|
else -> {}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> add(key: String, items: Array<T>): JsonBuilder {
|
||||||
|
val jsonArray = JSONArray()
|
||||||
|
items.forEach {
|
||||||
|
when (it) {
|
||||||
|
is String,is Long,is Int, is Boolean -> jsonArray.put(it)
|
||||||
|
is JsonBuilder -> jsonArray.put(it.json)
|
||||||
|
else -> try {jsonArray.put(it)} catch (ignored:Exception) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
json.put(key, jsonArray)
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toString() = json.toString()
|
||||||
|
}
|
||||||
@@ -24,8 +24,11 @@
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
apply<FernflowerPlugin>()
|
||||||
|
|
||||||
description = "Injected Client"
|
description = "Injected Client"
|
||||||
|
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
compileJava {
|
compileJava {
|
||||||
dependsOn(":injector-plugin:assemble")
|
dependsOn(":injector-plugin:assemble")
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ plugins {
|
|||||||
java
|
java
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
apply<BootstrapPlugin>()
|
||||||
|
|
||||||
description = "RuneLite Client"
|
description = "RuneLite Client"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -110,11 +113,6 @@ fun formatDate(date: Date?) = with(date ?: Date()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
register<DependencyReportTask>("dependencyReportFile") {
|
|
||||||
outputFile = file("dependencies.txt")
|
|
||||||
setConfiguration("runtimeClasspath")
|
|
||||||
}
|
|
||||||
|
|
||||||
build {
|
build {
|
||||||
finalizedBy("shadowJar")
|
finalizedBy("shadowJar")
|
||||||
}
|
}
|
||||||
@@ -144,8 +142,6 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
dependsOn("dependencyReportFile")
|
|
||||||
|
|
||||||
archiveClassifier.set("shaded")
|
archiveClassifier.set("shaded")
|
||||||
|
|
||||||
exclude("net/runelite/injector/**")
|
exclude("net/runelite/injector/**")
|
||||||
|
|||||||
Reference in New Issue
Block a user