Skip to content

Maven central release with nexus plugin #961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .ci/configure_signing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ signing.keyId=${signing_key: -8}
signing.password=${signing_password}
signing.secretKeyRingFile=${keyring_file}

ossrhUsername=${maven_username}
ossrhPassword=${maven_password}
sonatypeUsername=${maven_username}
sonatypePassword=${maven_password}
EOF

4 changes: 2 additions & 2 deletions .ci/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ if [[ "$CMD" == "release" ]]; then

if [[ "$DRY_RUN" = "true" ]]; then
echo "Dry run: building and publishing to the local repository"
gradle_task="java-client:publishAllPublicationsToBuildRepository"
gradle_task="publishAllPublicationsToDryRunRepository"
else
echo "Releasing to Maven snapshot repo"
gradle_task="java-client:publishAllPublicationsToMavenCentralRepository"
gradle_task="publishToSonatype closeAndReleaseStagingRepositories"
fi
docker run --rm --env VERSION=$VERSION -u "$(id -u)" \
$git_mount $src_mount $output_mount \
Expand Down
21 changes: 21 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@
* specific language governing permissions and limitations
* under the License.
*/
plugins {
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
}

nexusPublishing {
repositories {
sonatype()
}
}

repositories {
mavenCentral()
}

group = "co.elastic.clients"
description = "Maven central release of the official elasticsearch java client"

subprojects {
group = rootProject.group
version = rootProject.version
}

allprojects {
group = "co.elastic.clients"
Expand Down
18 changes: 2 additions & 16 deletions java-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ import java.io.FileWriter
plugins {
java
`java-library`
checkstyle
`maven-publish`
publishing
checkstyle
signing
id("com.github.jk1.dependency-license-report") version "2.2"
id("de.thetaphi.forbiddenapis") version "3.4"
Expand Down Expand Up @@ -129,21 +130,6 @@ publishing {
name = "Build"
url = uri("${rootProject.buildDir}/repository")
}

maven {
name = "MavenCentral"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
run {
if (gradle.startParameter.taskNames.find { it.contains("ToMavenCentralRepository") } != null) {
if (!providers.gradleProperty("ossrhUsername").isPresent) logger.error("ossrhUsername not set")
if (!providers.gradleProperty("ossrhPassword").isPresent) logger.error("ossrhPassword not set")
}
}
username = providers.gradleProperty("ossrhUsername").orNull
password = providers.gradleProperty("ossrhPassword").orNull
}
}
}

publications {
Expand Down
16 changes: 1 addition & 15 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,4 @@ import java.nio.file.Paths

rootProject.name = "elasticsearch-java"

// Include as subprojects all subdirectories that have a "build.gradle.kts" and no ".gradle-standalone"
fun listFiles(dir: File){
(dir.listFiles() ?: arrayOf<File>()).
filter { File(it, "build.gradle.kts").exists() }.
filter { !File(it, ".gradle-standalone").exists() }.
filter { it.name != "buildSrc" }.
toTypedArray().
forEach { dir ->
include(dir.name)
project(":" + dir.name).projectDir = dir
}
}

listFiles(rootProject.projectDir)
listFiles(Paths.get(rootProject.projectDir.path,"examples").toFile())
include("java-client")
Loading