3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-26 00:00:33 +01:00

Update build scripts

Dieser Commit ist enthalten in:
KennyTV 2021-05-29 09:32:55 +02:00
Ursprung fb368a9ebe
Commit 27b4933262
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
13 geänderte Dateien mit 209 neuen und 149 gelöschten Zeilen

12
build-logic/build.gradle.kts Normale Datei
Datei anzeigen

@ -0,0 +1,12 @@
plugins {
`kotlin-dsl`
}
repositories {
gradlePluginPortal()
}
dependencies {
// version must be manually kept in sync with the one in root project settings.gradle.kts
implementation("gradle.plugin.com.github.jengelman.gradle.plugins", "shadow", "7.0.0")
}

Datei anzeigen

@ -0,0 +1,44 @@
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.named
import java.io.ByteArrayOutputStream
fun Project.publishShadowJar() {
configurePublication {
artifact(tasks["shadowJar"])
artifact(tasks["sourcesJar"])
}
}
fun Project.publishJavaComponents() {
configurePublication {
from(components["java"])
}
}
private fun Project.configurePublication(configurer: MavenPublication.() -> Unit) {
extensions.configure<PublishingExtension> {
publications.named<MavenPublication>("mavenJava") {
apply(configurer)
}
}
}
fun Project.latestCommitHash(): String {
val byteOut = ByteArrayOutputStream()
exec {
commandLine = listOf("git", "rev-parse", "--short", "HEAD")
standardOutput = byteOut
}
return byteOut.toString(Charsets.UTF_8.name()).trim()
}
fun JavaPluginExtension.javaTarget(version: Int) {
sourceCompatibility = JavaVersion.toVersion(version)
targetCompatibility = JavaVersion.toVersion(version)
}

Datei anzeigen

@ -0,0 +1,42 @@
plugins {
`java-library`
`maven-publish`
}
tasks {
// Variable replacements
processResources {
filesMatching(listOf("plugin.yml", "mcmod.info", "fabric.mod.json", "bungee.yml")) {
expand("version" to project.version, "description" to project.description, "url" to "https://github.com/ViaVersion/ViaBackwards")
}
}
javadoc {
options.encoding = Charsets.UTF_8.name()
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
}
compileJava {
options.encoding = Charsets.UTF_8.name()
options.compilerArgs.addAll(listOf("-nowarn", "-Xlint:-unchecked", "-Xlint:-deprecation"))
}
}
java {
javaTarget(8)
withSourcesJar()
}
publishing {
publications.create<MavenPublication>("mavenJava") {
groupId = rootProject.group as String
artifactId = project.name
version = rootProject.version as String
}
repositories.maven {
name = "Via"
url = uri("https://repo.viaversion.com/")
credentials(PasswordCredentials::class)
authentication {
create<BasicAuthentication>("basic")
}
}
}

Datei anzeigen

@ -0,0 +1,10 @@
plugins {
id("vb.shadow-conventions")
}
tasks {
shadowJar {
archiveFileName.set("ViaBackwards-${project.name.substringAfter("viabackwards-").capitalize()}-${project.version}.jar")
destinationDirectory.set(rootProject.layout.buildDirectory.dir("libs"))
}
}

Datei anzeigen

@ -0,0 +1,29 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.named
plugins {
id("vb.base-conventions")
id("com.github.johnrengelman.shadow")
}
tasks {
named<Jar>("jar") {
archiveClassifier.set("unshaded")
from(project.rootProject.file("LICENSE"))
}
val shadowJar = named<ShadowJar>("shadowJar") {
archiveClassifier.set("")
configureRelocations()
}
named("build") {
dependsOn(shadowJar)
}
}
publishShadowJar()
fun ShadowJar.configureRelocations() {
relocate("com.google.gson", "com.viaversion.viaversion.libs.gson")
relocate("it.unimi.dsi.fastutil", "com.viaversion.viaversion.libs.fastutil")
}

Datei anzeigen

@ -0,0 +1,5 @@
plugins {
id("vb.base-conventions")
}
publishJavaComponents()

Datei anzeigen

@ -1,9 +1,6 @@
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
plugins { plugins {
`java-library` base
`maven-publish` id("vb.build-logic")
id("net.kyori.blossom") version "1.2.0" apply false
} }
allprojects { allprojects {
@ -12,87 +9,23 @@ allprojects {
description = "Allow older clients to join newer server versions." description = "Allow older clients to join newer server versions."
} }
subprojects { val platforms = setOf(
apply<JavaLibraryPlugin>()
apply<MavenPublishPlugin>()
tasks {
// Variable replacements
processResources {
filesMatching(listOf("plugin.yml", "mcmod.info", "fabric.mod.json", "bungee.yml")) {
expand("version" to project.version,
"description" to project.description,
"url" to "https://github.com/ViaVersion/ViaBackwards")
}
}
withType<Javadoc> {
options.encoding = Charsets.UTF_8.name()
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
}
withType<JavaCompile> {
options.encoding = Charsets.UTF_8.name()
options.compilerArgs.addAll(listOf("-nowarn", "-Xlint:-unchecked", "-Xlint:-deprecation"))
}
}
repositories {
maven("https://repo.viaversion.com")
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven("https://nexus.velocitypowered.com/repository/velocity-artifacts-snapshots/")
maven("https://repo.spongepowered.org/maven")
mavenCentral()
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
withJavadocJar()
}
}
// Configure shadow tasks before the publishing task
sequenceOf(
projects.viabackwardsBukkit, projects.viabackwardsBukkit,
projects.viabackwardsBungee, projects.viabackwardsBungee,
projects.viabackwardsFabric, projects.viabackwardsFabric,
projects.viabackwardsSponge, projects.viabackwardsSponge,
projects.viabackwardsVelocity projects.viabackwardsVelocity
).map { it.dependencyProject }.forEach { project -> ).map { it.dependencyProject }
project.configureShadowJar()
}
projects.viabackwards.dependencyProject.apply<ShadowPlugin>() // Would otherwise contain api/depdency modules if at some point needed
val special = setOf(
projects.viabackwards
).map { it.dependencyProject }
subprojects { subprojects {
publishing { when (this) {
publications { in platforms -> plugins.apply("vb.platform-conventions")
create<MavenPublication>("mavenJava") { in special -> plugins.apply("vb.base-conventions")
groupId = rootProject.group as String else -> plugins.apply("vb.standard-conventions")
artifactId = project.name
version = rootProject.version as String
if (plugins.hasPlugin(ShadowPlugin::class.java)) {
artifact(tasks["shadowJar"])
} else {
from(components["java"])
}
}
}
repositories.maven {
name = "Via"
url = uri("https://repo.viaversion.com/")
credentials(PasswordCredentials::class)
authentication {
create<BasicAuthentication>("basic")
}
}
}
}
tasks {
withType<Jar> {
onlyIf { false }
} }
} }

Datei anzeigen

@ -1,11 +0,0 @@
plugins {
`kotlin-dsl`
}
repositories {
gradlePluginPortal()
}
dependencies {
implementation("com.github.jengelman.gradle.plugins", "shadow", "6.1.0")
}

Datei anzeigen

@ -1,45 +0,0 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import org.gradle.api.Project
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.invoke
import org.gradle.kotlin.dsl.withType
import java.io.ByteArrayOutputStream
fun Project.configureShadowJar() {
apply<ShadowPlugin>()
tasks {
withType<ShadowJar> {
archiveClassifier.set("")
archiveFileName.set("ViaBackwards-${project.name.substringAfter("viabackwards-").capitalize()}-${project.version}.jar")
destinationDirectory.set(rootProject.projectDir.resolve("build/libs"))
configureRelocations()
}
getByName("build") {
dependsOn(withType<ShadowJar>())
}
withType<Jar> {
if (name == "jar") {
archiveClassifier.set("unshaded")
}
from(project.parent!!.file("LICENSE")) {
into("")
}
}
}
}
private fun ShadowJar.configureRelocations() {
relocate("com.google.gson", "com.viaversion.viaversion.libs.gson")
relocate("it.unimi.dsi.fastutil", "com.viaversion.viaversion.libs.fastutil")
}
fun Project.latestCommitHash(): String {
val byteOut = ByteArrayOutputStream()
exec {
commandLine = listOf("git", "rev-parse", "--short", "HEAD")
standardOutput = byteOut
}
return byteOut.toString(Charsets.UTF_8.name()).trim()
}

Datei anzeigen

@ -13,3 +13,7 @@ dependencies {
compileOnlyApi(libs.guava) compileOnlyApi(libs.guava)
compileOnlyApi(libs.checkerQual) compileOnlyApi(libs.checkerQual)
} }
java {
withJavadocJar()
}

Datei anzeigen

@ -1,8 +1,29 @@
rootProject.name = "viabackwards-parent"
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
enableFeaturePreview("VERSION_CATALOGS") enableFeaturePreview("VERSION_CATALOGS")
rootProject.name = "viabackwards-parent"
dependencyResolutionManagement {
repositories {
maven("https://repo.viaversion.com")
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven("https://nexus.velocitypowered.com/repository/velocity-artifacts-snapshots/")
maven("https://repo.spongepowered.org/maven")
mavenCentral()
}
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
}
pluginManagement {
plugins {
id("net.kyori.blossom") version "1.2.0"
id("com.github.johnrengelman.shadow") version "7.0.0"
}
}
includeBuild("build-logic")
setupViaSubproject("common") setupViaSubproject("common")
setupViaSubproject("bukkit") setupViaSubproject("bukkit")
setupViaSubproject("bungee") setupViaSubproject("bungee")

Datei anzeigen

@ -1,25 +1,41 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
id("com.github.johnrengelman.shadow")
}
val platforms = setOf(
projects.viabackwardsBukkit,
projects.viabackwardsBungee,
projects.viabackwardsFabric,
projects.viabackwardsSponge,
projects.viabackwardsVelocity
).map { it.dependencyProject }
tasks { tasks {
withType<ShadowJar> { shadowJar {
archiveClassifier.set("") archiveClassifier.set("")
archiveFileName.set("ViaBackwards-${project.version}.jar") archiveFileName.set("ViaBackwards-${project.version}.jar")
destinationDirectory.set(rootProject.projectDir.resolve("build/libs")) destinationDirectory.set(rootProject.projectDir.resolve("build/libs"))
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
sequenceOf( platforms.forEach { platform ->
rootProject.projects.viabackwardsBukkit, val shadowJarTask = platform.tasks.getByName("shadowJar", ShadowJar::class)
rootProject.projects.viabackwardsBungee,
rootProject.projects.viabackwardsFabric,
rootProject.projects.viabackwardsSponge,
rootProject.projects.viabackwardsVelocity,
).map { it.dependencyProject }.forEach { subproject ->
val shadowJarTask = subproject.tasks.getByName("shadowJar", ShadowJar::class)
dependsOn(shadowJarTask) dependsOn(shadowJarTask)
dependsOn(subproject.tasks.withType<Jar>()) dependsOn(platform.tasks.withType<Jar>())
from(zipTree(shadowJarTask.archiveFile)) from(zipTree(shadowJarTask.archiveFile))
} }
} }
build { build {
dependsOn(withType<ShadowJar>()) dependsOn(shadowJar)
}
sourcesJar {
rootProject.subprojects.forEach { subproject ->
if (subproject == project) return@forEach
val platformSourcesJarTask = subproject.tasks.findByName("sourcesJar") as? Jar ?: return@forEach
dependsOn(platformSourcesJarTask)
from(zipTree(platformSourcesJarTask.archiveFile))
}
} }
} }
publishShadowJar()