Skip to content

Commit b2991c4

Browse files
committed
fix maven publish
1 parent 97cd32d commit b2991c4

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

.ci/make.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ if [[ "$CMD" == "release" ]]; then
196196
echo "Dry run: building and publishing to the local repository"
197197
gradle_task="publishForReleaseManager"
198198
else
199-
echo "Releasing to Maven snapshot repo"
200-
gradle_task="publishToSonatype closeAndReleaseStagingRepositories"
199+
echo "Releasing to Maven repo"
200+
gradle_task="publishForMavenCentral"
201201
fi
202202
docker run --rm --env VERSION=$VERSION -u "$(id -u)" \
203203
$git_mount $src_mount $output_mount \

build.gradle.kts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,40 @@ tasks.register<Task>(name = "resolveDependencies") {
7979
}
8080
}
8181

82+
// gradle tasks --all to check tasks in subprojects
83+
tasks.register<Task>(name = "publishForMavenCentral") {
84+
group = "Publishing"
85+
description = "Publishes artifacts to Maven Central"
86+
dependsOn(
87+
":java-client:publishAllPublicationsToBuildRepository",
88+
":java-client:generateLicenseReport",
89+
":java-client:publishToSonatype",
90+
"closeAndReleaseStagingRepositories",
91+
)
92+
doLast {
93+
val version = this.project.version.toString()
94+
println("Releasing version $version")
95+
96+
val releaseDir = File(rootProject.layout.buildDirectory.get().asFile, "release")
97+
releaseDir.mkdirs()
98+
99+
File(rootProject.layout.buildDirectory.get().asFile, "repository/co/elastic/clients").listFiles()?.forEach { artifact ->
100+
println("Releasing artifact " + artifact.name)
101+
102+
val versionDir = File(artifact, version)
103+
104+
versionDir.listFiles()?.forEach { file ->
105+
if (file.name.endsWith(".jar") || file.name.endsWith(".pom")) {
106+
var name = file.name
107+
108+
file.copyTo(File(releaseDir, name), overwrite = true)
109+
}
110+
}
111+
}
112+
}
113+
}
114+
115+
// TODO delete
82116
tasks.register<Task>(name = "publishForReleaseManager") {
83117
group = "Publishing"
84118
description = "Publishes artifacts in a format suitable for the Elastic release manager"

0 commit comments

Comments
 (0)