Skip to content

Commit 6e6f40e

Browse files
committed
Add publishing task for the Elastic release manager
1 parent 90b97bb commit 6e6f40e

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

.ci/make.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ if [[ "$CMD" == "assemble" ]]; then
152152
docker run --rm --env VERSION=$VERSION \
153153
$git_mount $src_mount $output_mount \
154154
$docker_image \
155-
java-client:publishAllPublicationsToBuildRepository
155+
publishForReleaseManager
156156

157-
if compgen -G ".ci/output/*" > /dev/null; then
157+
if compgen -G ".ci/output/release/*" > /dev/null; then
158158
echo -e "\033[32;1mTARGET: successfully assembled client version $VERSION\033[0m"
159159
else
160160
echo -e "\033[31;1mTARGET: assemble failed, empty workspace!\033[0m"

build.gradle.kts

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
21-
subprojects {
20+
allprojects {
2221
group = "co.elastic.clients"
2322
version = System.getenv("VERSION") ?: "8.0.0-SNAPSHOT"
2423

@@ -50,3 +49,41 @@ tasks.register<Task>(name = "resolveDependencies") {
5049
}
5150
}
5251
}
52+
53+
tasks.register<Task>(name = "publishForReleaseManager") {
54+
group = "Publishing"
55+
description = "Publishes artifacts in a format suitable for the Elastic release manager"
56+
dependsOn(":java-client:publishAllPublicationsToBuildRepository")
57+
doLast {
58+
val version = this.project.version.toString()
59+
val isSnapshot = version.endsWith("SNAPSHOT")
60+
61+
println("Releasing version $version")
62+
63+
val releaseDir = File(rootProject.buildDir, "release")
64+
releaseDir.mkdirs()
65+
66+
File(rootProject.buildDir, "repository/co/elastic/clients").listFiles()?.forEach { artifact ->
67+
println("Releasing artifact " + artifact.name)
68+
69+
val versionDir = File(artifact, version)
70+
var gotPom = false;
71+
72+
versionDir.listFiles()?.forEach { file ->
73+
if (file.name.endsWith(".jar") || file.name.endsWith(".pom")) {
74+
var name = file.name
75+
76+
if (isSnapshot) {
77+
if (file.name.endsWith(".pom")) {
78+
if (gotPom) throw GradleException("Multiple snapshots found in " + file.parentFile)
79+
gotPom = true
80+
}
81+
name = name.replace(Regex("-\\d{8}\\.\\d{6}-\\d+"), "-SNAPSHOT")
82+
}
83+
84+
file.copyTo(File(releaseDir, name), overwrite = true)
85+
}
86+
}
87+
}
88+
}
89+
}

java-client/build.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ plugins {
2828
java {
2929
targetCompatibility = JavaVersion.VERSION_1_8
3030
sourceCompatibility = JavaVersion.VERSION_1_8
31+
32+
withJavadocJar()
33+
withSourcesJar()
3134
}
3235

3336
tasks.withType<Jar> {
@@ -79,7 +82,7 @@ publishing {
7982
url.set("https://github.com/elastic/elasticsearch-java/")
8083
licenses {
8184
license {
82-
name.set("The Apache License, Version 2.0")
85+
name.set("The Apache Software License, Version 2.0")
8386
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
8487
}
8588
}

0 commit comments

Comments
 (0)