Skip to content

Commit

Permalink
let's try again
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Apr 28, 2024
1 parent 7df8208 commit 9b76225
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 96 deletions.
48 changes: 24 additions & 24 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@ 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()
mavenCentral()
maven(url = "https://maven.lavalink.dev/releases")
maven(url = "https://jitpack.io")
}
}

apply(plugin = "java")
subprojects {
apply<JavaPlugin>()
apply<MavenPublishPlugin>()

java {
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
Expand All @@ -30,44 +36,38 @@ 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<PublishingExtension> {
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<PublishingExtension> {
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<String, Boolean> {
Grgit.open(mapOf("currentDir" to project.rootDir)).use { git ->
val headTag = git.tag
.list()
.find { it.commit.id == git.head().id }

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
}
}
}
24 changes: 4 additions & 20 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
35 changes: 4 additions & 31 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -17,6 +12,10 @@ lavalinkPlugin {
configurePublishing = false
}

base {
archivesName = "youtube-plugin"
}

dependencies {
implementation(projects.common)
implementation(projects.v2)
Expand All @@ -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"
}
}
26 changes: 5 additions & 21 deletions v2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}

0 comments on commit 9b76225

Please sign in to comment.