Skip to content

Commit 71374f9

Browse files
committed
fix maven publish
1 parent 4bfb003 commit 71374f9

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

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

0 commit comments

Comments
 (0)