From 46a01cb0f033bf789d72af8f23c41cc9925552f8 Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 24 Feb 2021 03:04:31 -0800 Subject: [PATCH] Fix publishing (#2364) --- build.gradle.kts | 57 +++++++++++++++++++++++--------------- buildSrc/build.gradle.kts | 2 -- universal/build.gradle.kts | 8 ------ 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 20cb45780..eef69438b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,11 +1,8 @@ -import net.kyori.indra.IndraPlugin -import net.kyori.indra.IndraPublishingPlugin -import net.kyori.indra.sonatypeSnapshots +import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin plugins { `java-library` `maven-publish` - id("net.kyori.indra") } group = "us.myles" @@ -15,8 +12,6 @@ description = "Allow newer clients to join older server versions." subprojects { apply() apply() - apply() - apply() tasks { // Variable replacements @@ -25,7 +20,11 @@ subprojects { expand("version" to project.version, "description" to project.description) } } + withType { + options.encoding = Charsets.UTF_8.name() + } withType { + options.encoding = Charsets.UTF_8.name() options.compilerArgs.addAll(listOf("-nowarn", "-Xlint:-unchecked", "-Xlint:-deprecation")) } } @@ -40,9 +39,12 @@ subprojects { if (platforms.contains(project.name)) { configureShadowJar() } + if (project.name == "viaversion") { + apply() + } repositories { - sonatypeSnapshots() + maven("https://oss.sonatype.org/content/repositories/snapshots/") maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots") maven("https://nexus.velocitypowered.com/repository/velocity-artifacts-snapshots/") maven("https://repo.spongepowered.org/maven") @@ -58,23 +60,34 @@ subprojects { testImplementation("org.junit.jupiter", "junit-jupiter-engine", Versions.jUnit) } - indra { - javaVersions { - target.set(8) - testWith(8, 11, 15) - } - github("ViaVersion", "ViaVersion") { - issues = true - } - mitLicense() + java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + withSourcesJar() + withJavadocJar() } - publishing.repositories.maven { - name = "Via" - url = uri("https://repo.viaversion.com/") - credentials(PasswordCredentials::class) - authentication { - create("basic") + publishing { + publications { + create("mavenJava") { + groupId = rootProject.group as String + 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("basic") + } } } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 3b0f9bc24..7f236a57b 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -7,7 +7,5 @@ repositories { } dependencies { - implementation("net.kyori", "indra-common", "1.3.1") - implementation("net.kyori", "indra-publishing-gradle-plugin", "1.3.1") implementation("com.github.jengelman.gradle.plugins", "shadow", "6.1.0") } \ No newline at end of file diff --git a/universal/build.gradle.kts b/universal/build.gradle.kts index c55fa450f..58e15484e 100644 --- a/universal/build.gradle.kts +++ b/universal/build.gradle.kts @@ -1,8 +1,5 @@ -import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -apply() - tasks { withType { archiveClassifier.set("") @@ -25,9 +22,4 @@ tasks { build { dependsOn(withType()) } - withType { - if (name == "jar") { - archiveClassifier.set("unshaded") - } - } }