From 9b7622589be65409dd85d021b09aa65a4c397872 Mon Sep 17 00:00:00 2001 From: topi314 Date: Mon, 29 Apr 2024 00:53:54 +0200 Subject: [PATCH] let's try again --- build.gradle.kts | 48 ++++++++++++++++++++--------------------- common/build.gradle.kts | 24 ++++----------------- plugin/build.gradle.kts | 35 ++++-------------------------- v2/build.gradle.kts | 26 +++++----------------- 4 files changed, 37 insertions(+), 96 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 1387813..9f8fa66 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,9 +6,12 @@ plugins { alias(libs.plugins.maven.publish.base) apply false } +val (gitVersion, release) = versionFromGit() +logger.lifecycle("Version: $gitVersion (release: $release)") + allprojects { group = "dev.lavalink.youtube" - version = versionFromTag() + version = gitVersion repositories { mavenLocal() @@ -16,10 +19,13 @@ allprojects { maven(url = "https://maven.lavalink.dev/releases") maven(url = "https://jitpack.io") } +} - apply(plugin = "java") +subprojects { + apply() + apply() - java { + configure { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } @@ -30,34 +36,28 @@ allprojects { compileOnly("org.slf4j:slf4j-api:1.7.25") compileOnly("org.jetbrains:annotations:24.1.0") } -} -subprojects { - afterEvaluate { - plugins.withId(libs.plugins.maven.publish.base.get().pluginId) { - configure { - if (findProperty("MAVEN_PASSWORD") != null && findProperty("MAVEN_USERNAME") != null) { - repositories { - val snapshots = "https://maven.lavalink.dev/snapshots" - val releases = "https://maven.lavalink.dev/releases" + configure { + if (findProperty("MAVEN_PASSWORD") != null && findProperty("MAVEN_USERNAME") != null) { + repositories { + val snapshots = "https://maven.lavalink.dev/snapshots" + val releases = "https://maven.lavalink.dev/releases" - maven(if ((version as String).endsWith("-SNAPSHOT")) snapshots else releases) { - credentials { - password = findProperty("MAVEN_PASSWORD") as String? - username = findProperty("MAVEN_USERNAME") as String? - } - } + maven(if (release) releases else snapshots) { + credentials { + password = findProperty("MAVEN_PASSWORD") as String? + username = findProperty("MAVEN_USERNAME") as String? } - } else { - logger.lifecycle("Not publishing to maven.lavalink.dev because credentials are not set") } } + } else { + logger.lifecycle("Not publishing to maven.lavalink.dev because credentials are not set") } } } @SuppressWarnings("GrMethodMayBeStatic") -fun versionFromTag(): String { +fun versionFromGit(): Pair { Grgit.open(mapOf("currentDir" to project.rootDir)).use { git -> val headTag = git.tag .list() @@ -65,9 +65,9 @@ fun versionFromTag(): String { val clean = git.status().isClean || System.getenv("CI") != null if (!clean) { - println("Git state is dirty, setting version as snapshot.") + logger.lifecycle("Git state is dirty, version is a snapshot.") } - return if (headTag != null && clean) headTag.name else "${git.head().id}-SNAPSHOT" + return if (headTag != null && clean) headTag.name to true else "${git.head().id}-SNAPSHOT" to false } -} +} \ No newline at end of file diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 9ed2f99..950bb23 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -6,30 +6,14 @@ plugins { alias(libs.plugins.maven.publish.base) } -val moduleName = "common" +base { + archivesName = "youtube-common" +} dependencies { compileOnly(libs.lavaplayer.v1) } -tasks.jar { - archiveBaseName.set("youtube-common") -} - -val sourcesJar by tasks.registering(Jar::class) { - archiveClassifier.set("sources") - from(sourceSets["main"].allSource) -} - mavenPublishing { - configure( - JavaLibrary( - javadocJar = JavadocJar.Javadoc(), - sourcesJar = true - ) - ) - pom { - name = "Lavaplayer v1 YouTube Source" - description = "YouTube source for Lavaplayer v1" - } + configure(JavaLibrary(JavadocJar.Javadoc())) } diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index b173624..67b64a7 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -1,14 +1,9 @@ -import com.vanniktech.maven.publish.JavaLibrary -import com.vanniktech.maven.publish.JavadocJar - plugins { `java-library` alias(libs.plugins.lavalink.gradle.plugin) alias(libs.plugins.maven.publish.base) } -val moduleName = "plugin" - lavalinkPlugin { name = "youtube-plugin" path = "dev.lavalink.youtube.plugin" @@ -17,6 +12,10 @@ lavalinkPlugin { configurePublishing = false } +base { + archivesName = "youtube-plugin" +} + dependencies { implementation(projects.common) implementation(projects.v2) @@ -28,29 +27,3 @@ java { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 } - -val sourcesJar by tasks.registering(Jar::class) { - dependsOn(tasks.generatePluginProperties) - archiveBaseName.set("youtube-plugin") - archiveClassifier.set("sources") - from(sourceSets["main"].allSource) -} - -tasks.jar { - dependsOn(projects.common.dependencyProject.tasks.jar) - dependsOn(projects.v2.dependencyProject.tasks.jar) - archiveBaseName.set(moduleName) -} - -mavenPublishing { - configure( - JavaLibrary( - javadocJar = JavadocJar.Javadoc(), - sourcesJar = true - ) - ) - pom { - name = "Lavalink YouTube Plugin" - description = "YouTube plugin for Lavalink" - } -} diff --git a/v2/build.gradle.kts b/v2/build.gradle.kts index 0a4967c..3bf6328 100644 --- a/v2/build.gradle.kts +++ b/v2/build.gradle.kts @@ -6,31 +6,15 @@ plugins { alias(libs.plugins.maven.publish.base) } -val moduleName = "v2" +base { + archivesName = "youtube-v2" +} dependencies { - compileOnly(projects.common) + api(projects.common) compileOnly(libs.lavaplayer.v2) } -tasks.jar { - archiveBaseName.set("youtube-v2") -} - -val sourcesJar by tasks.registering(Jar::class) { - archiveClassifier.set("sources") - from(sourceSets["main"].allSource) -} - mavenPublishing { - configure( - JavaLibrary( - javadocJar = JavadocJar.Javadoc(), - sourcesJar = true - ) - ) - pom { - name = "Lavaplayer v2 YouTube Source" - description = "YouTube source for Lavaplayer v2" - } + configure(JavaLibrary(JavadocJar.Javadoc())) } \ No newline at end of file