Skip to content

Commit 2994f21

Browse files
committed
updating build config
1 parent eab2d4e commit 2994f21

File tree

1 file changed

+36
-43
lines changed

1 file changed

+36
-43
lines changed

build.gradle.kts

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@ dependencies {
2424

2525
testImplementation(platform("org.junit:junit-bom:5.10.0"))
2626
testImplementation("org.junit.jupiter:junit-jupiter")
27-
// https://mvnrepository.com/artifact/org.mockito/mockito-core
2827
testImplementation("org.mockito:mockito-core:5.14.2")
2928
}
29+
3030
tasks.test {
3131
useJUnitPlatform()
3232
}
3333

3434
// Dynamically set the version from the latest Git tag
3535
version = run {
36-
// Function to check if Git is available
3736
fun isGitAvailable(): Boolean {
3837
return try {
3938
exec {
@@ -57,27 +56,52 @@ version = run {
5756
isIgnoreExitValue = true
5857
}
5958
val gitTag = stdout.toString().trim()
60-
gitTag.ifEmpty {
61-
"1.0.0-SNAPSHOT" // Default version if no tag is found
62-
}
59+
if (gitTag.isNotEmpty()) gitTag else "1.0.0-SNAPSHOT"
6360
} catch (e: Exception) {
64-
"1.0.0-SNAPSHOT" // Default version if Git command fails
61+
"1.0.0-SNAPSHOT"
6562
}
6663
} else {
67-
"1.0.0-SNAPSHOT" // Default version if Git is not available
64+
"1.0.0-SNAPSHOT"
65+
}
66+
}
67+
68+
java {
69+
withSourcesJar()
70+
withJavadocJar()
71+
}
72+
73+
sourceSets {
74+
main {
75+
java {
76+
exclude("samples/**")
77+
}
6878
}
6979
}
7080

81+
tasks.named<Jar>("jar") {
82+
exclude("samples/**")
83+
}
84+
85+
tasks.named<Jar>("sourcesJar") {
86+
exclude("samples/**")
87+
}
88+
89+
tasks.named<Javadoc>("javadoc") {
90+
exclude("samples/**")
91+
}
92+
7193
publishing {
7294
publications {
7395
create<MavenPublication>("gpr") {
7496
from(components["java"])
97+
98+
// Attach sources and Javadoc JARs
99+
artifact(tasks.named("sourcesJar"))
100+
artifact(tasks.named("javadocJar"))
101+
75102
groupId = "de.n21no.realtime.pubsub"
76103
artifactId = "core"
77-
version = version
78-
79-
artifact(tasks["sourcesJar"])
80-
artifact(tasks["javadocJar"])
104+
version = project.version.toString()
81105

82106
pom {
83107
name.set("Realtime Pub/Sub Client")
@@ -93,7 +117,7 @@ publishing {
93117
developer {
94118
id.set("BackendStack21")
95119
name.set("21no.de")
96-
email.set("[email protected]")
120+
email.set("realtime.[email protected]")
97121
}
98122
}
99123
scm {
@@ -108,37 +132,6 @@ publishing {
108132
maven {
109133
name = "GitHubPackages"
110134
url = uri("https://maven.pkg.github.com/BackendStack21/realtime-pubsub-client-java")
111-
credentials {
112-
username = System.getenv("GITHUB_ACTOR")
113-
password = System.getenv("GITHUB_TOKEN")
114-
}
115-
}
116-
}
117-
}
118-
119-
sourceSets {
120-
main {
121-
java {
122-
srcDirs("src/main/java")
123-
exclude("samples/**")
124135
}
125136
}
126137
}
127-
128-
tasks.named<Jar>("jar") {
129-
exclude("samples/**")
130-
}
131-
132-
tasks.named<Jar>("sourcesJar") {
133-
exclude("samples/**")
134-
}
135-
136-
tasks.named<Javadoc>("javadoc") {
137-
exclude("samples/**")
138-
}
139-
140-
java {
141-
// Include sources and Javadoc JARs
142-
withSourcesJar()
143-
withJavadocJar()
144-
}

0 commit comments

Comments
 (0)