Don't publish extra modules (#772)

This commit is contained in:
EnZaXD 2024-06-03 15:24:16 +02:00 committed by Nassim Jahnke
parent 8a675923d1
commit 6058763489
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
5 changed files with 21 additions and 51 deletions

View File

@ -1,34 +1,8 @@
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 {

View File

@ -1,6 +1,5 @@
plugins {
`java-library`
`maven-publish`
}
tasks {
@ -24,19 +23,3 @@ java {
javaTarget(17)
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")
}
}
}

View File

@ -4,6 +4,7 @@ import org.gradle.kotlin.dsl.named
plugins {
id("vb.base-conventions")
id("maven-publish")
id("com.github.johnrengelman.shadow")
}
@ -21,7 +22,24 @@ tasks {
}
}
publishShadowJar()
publishing {
publications.create<MavenPublication>("mavenJava") {
groupId = rootProject.group as String
artifactId = project.name
version = rootProject.version as String
artifact(tasks["shadowJar"])
artifact(tasks["sourcesJar"])
}
repositories.maven {
name = "Via"
url = uri("https://repo.viaversion.com/")
credentials(PasswordCredentials::class)
authentication {
create<BasicAuthentication>("basic")
}
}
}
fun ShadowJar.configureRelocations() {
relocate("com.google.gson", "com.viaversion.viaversion.libs.gson")

View File

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

View File

@ -20,6 +20,6 @@ val main = setOf(
subprojects {
when (this) {
in main -> plugins.apply("vb.shadow-conventions")
else -> plugins.apply("vb.standard-conventions")
else -> plugins.apply("vb.base-conventions")
}
}