Skip to content

Commit 54ce1e8

Browse files
committed
fix maven publish
1 parent 876792b commit 54ce1e8

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
@@ -86,6 +86,40 @@ tasks.register<Task>(name = "resolveDependencies") {
8686
}
8787
}
8888

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

0 commit comments

Comments
 (0)