Skip to content

Commit

Permalink
updating build config
Browse files Browse the repository at this point in the history
  • Loading branch information
jkyberneees committed Nov 29, 2024
1 parent eab2d4e commit 2994f21
Showing 1 changed file with 36 additions and 43 deletions.
79 changes: 36 additions & 43 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ dependencies {

testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
// https://mvnrepository.com/artifact/org.mockito/mockito-core
testImplementation("org.mockito:mockito-core:5.14.2")
}

tasks.test {
useJUnitPlatform()
}

// Dynamically set the version from the latest Git tag
version = run {
// Function to check if Git is available
fun isGitAvailable(): Boolean {
return try {
exec {
Expand All @@ -57,27 +56,52 @@ version = run {
isIgnoreExitValue = true
}
val gitTag = stdout.toString().trim()
gitTag.ifEmpty {
"1.0.0-SNAPSHOT" // Default version if no tag is found
}
if (gitTag.isNotEmpty()) gitTag else "1.0.0-SNAPSHOT"
} catch (e: Exception) {
"1.0.0-SNAPSHOT" // Default version if Git command fails
"1.0.0-SNAPSHOT"
}
} else {
"1.0.0-SNAPSHOT" // Default version if Git is not available
"1.0.0-SNAPSHOT"
}
}

java {
withSourcesJar()
withJavadocJar()
}

sourceSets {
main {
java {
exclude("samples/**")
}
}
}

tasks.named<Jar>("jar") {
exclude("samples/**")
}

tasks.named<Jar>("sourcesJar") {
exclude("samples/**")
}

tasks.named<Javadoc>("javadoc") {
exclude("samples/**")
}

publishing {
publications {
create<MavenPublication>("gpr") {
from(components["java"])

// Attach sources and Javadoc JARs
artifact(tasks.named("sourcesJar"))
artifact(tasks.named("javadocJar"))

groupId = "de.n21no.realtime.pubsub"
artifactId = "core"
version = version

artifact(tasks["sourcesJar"])
artifact(tasks["javadocJar"])
version = project.version.toString()

pom {
name.set("Realtime Pub/Sub Client")
Expand All @@ -93,7 +117,7 @@ publishing {
developer {
id.set("BackendStack21")
name.set("21no.de")
email.set("contact@21no.de")
email.set("realtime.contact@21no.de")
}
}
scm {
Expand All @@ -108,37 +132,6 @@ publishing {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/BackendStack21/realtime-pubsub-client-java")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}

sourceSets {
main {
java {
srcDirs("src/main/java")
exclude("samples/**")
}
}
}

tasks.named<Jar>("jar") {
exclude("samples/**")
}

tasks.named<Jar>("sourcesJar") {
exclude("samples/**")
}

tasks.named<Javadoc>("javadoc") {
exclude("samples/**")
}

java {
// Include sources and Javadoc JARs
withSourcesJar()
withJavadocJar()
}

0 comments on commit 2994f21

Please sign in to comment.