From 9751123deefb9f276d76f34ebc0eb5e9fde3f90c Mon Sep 17 00:00:00 2001 From: muzahidul-opti Date: Tue, 26 Aug 2025 17:38:16 +0600 Subject: [PATCH 1/5] feat build.gradle: update maven repositories for improved security and reliability - Switch from jcenter to mavenCentral as the primary repository - Enable plugins Gradle repository to use https://plugins.gradle.org/m2/ for plugin downloads - Update Maven Central URLs for release and snapshot repositories - Securely authenticate with Sonatype using environment variables --- build.gradle | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 845830761..76a0e7b8f 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,10 @@ allprojects { apply plugin: 'jacoco' repositories { - jcenter() + mavenCentral() + maven { + url 'https://plugins.gradle.org/m2/' + } } jacoco { @@ -47,12 +50,12 @@ configure(publishedProjects) { sourceCompatibility = 1.8 targetCompatibility = 1.8 - repositories { - jcenter() - maven { - url 'https://plugins.gradle.org/m2/' - } - } + // repositories { + // // jcenter() + // maven { + // url 'https://plugins.gradle.org/m2/' + // } + // } task sourcesJar(type: Jar, dependsOn: classes) { archiveClassifier.set('sources') @@ -139,8 +142,8 @@ configure(publishedProjects) { } repositories { maven { - def releaseUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2" - def snapshotUrl = "https://oss.sonatype.org/content/repositories/snapshots" + def releaseUrl = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2" + def snapshotUrl = "https://central.sonatype.com/repository/maven-snapshots/" url = isReleaseVersion ? releaseUrl : snapshotUrl credentials { username System.getenv('MAVEN_CENTRAL_USERNAME') From 894f919e62337b08b40f3b96acb6c5d0c66de1ff Mon Sep 17 00:00:00 2001 From: muzahidul-opti Date: Tue, 26 Aug 2025 23:00:46 +0600 Subject: [PATCH 2/5] feat: add release script --- release.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 release.sh diff --git a/release.sh b/release.sh new file mode 100755 index 000000000..53a573e2e --- /dev/null +++ b/release.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -e + +# This script is used to release the Optimizely Java SDK. + +# Usage: +# ./release.sh + +if [ -z "$1" ]; then + echo "Usage: ./release.sh " + exit 1 +fi + +RELEASE_VERSION=$1 + +# Create a new tag +git tag -a "$RELEASE_VERSION" -m "Release $RELEASE_VERSION" + +# Push the tag to the master branch +git push origin "$RELEASE_VERSION" From 045d04c65c225e3267f3390f1607b11b5e8ac962 Mon Sep 17 00:00:00 2001 From: muzahidul-opti Date: Wed, 27 Aug 2025 06:23:30 +0600 Subject: [PATCH 3/5] fix(build.gradle): Update Nexus publishing configuration for Sonatype staging repository --- build.gradle | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index 76a0e7b8f..ae92f058b 100644 --- a/build.gradle +++ b/build.gradle @@ -6,6 +6,8 @@ plugins { id 'com.github.hierynomus.license' version '0.16.1' id 'com.github.spotbugs' version "6.0.14" id 'maven-publish' + id 'signing' + id 'io.github.gradle-nexus.publish-plugin' version '2.0.0' } allprojects { @@ -140,17 +142,17 @@ configure(publishedProjects) { artifact javadocJar } } - repositories { - maven { - def releaseUrl = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2" - def snapshotUrl = "https://central.sonatype.com/repository/maven-snapshots/" - url = isReleaseVersion ? releaseUrl : snapshotUrl - credentials { - username System.getenv('MAVEN_CENTRAL_USERNAME') - password System.getenv('MAVEN_CENTRAL_PASSWORD') - } - } - } + // repositories { + // maven { + // def releaseUrl = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2" + // def snapshotUrl = "https://central.sonatype.com/repository/maven-snapshots/" + // url = isReleaseVersion ? releaseUrl : snapshotUrl + // credentials { + // username System.getenv('MAVEN_CENTRAL_USERNAME') + // password System.getenv('MAVEN_CENTRAL_PASSWORD') + // } + // } + // } } signing { @@ -186,7 +188,18 @@ configure(publishedProjects) { } task ship() { - dependsOn(':core-api:ship', ':core-httpclient-impl:ship') + dependsOn(':core-httpclient-impl:ship', ':core-api:ship', 'publishToSonatype', 'closeSonatypeStagingRepository') +} + +nexusPublishing { + repositories { + sonatype { + nexusUrl.set(uri('https://ossrh-staging-api.central.sonatype.com/service/local/')) + snapshotRepositoryUrl.set(uri('https://central.sonatype.com/repository/maven-snapshots/')) + username = System.getenv('MAVEN_CENTRAL_USERNAME') + password = System.getenv('MAVEN_CENTRAL_PASSWORD') + } + } } task jacocoMerge(type: JacocoMerge) { From 86dcbe1c945484f6878d8cd0935f5f84851a6b85 Mon Sep 17 00:00:00 2001 From: muzahidul-opti Date: Wed, 27 Aug 2025 06:24:43 +0600 Subject: [PATCH 4/5] fix: remove release script --- release.sh | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100755 release.sh diff --git a/release.sh b/release.sh deleted file mode 100755 index 53a573e2e..000000000 --- a/release.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -set -e - -# This script is used to release the Optimizely Java SDK. - -# Usage: -# ./release.sh - -if [ -z "$1" ]; then - echo "Usage: ./release.sh " - exit 1 -fi - -RELEASE_VERSION=$1 - -# Create a new tag -git tag -a "$RELEASE_VERSION" -m "Release $RELEASE_VERSION" - -# Push the tag to the master branch -git push origin "$RELEASE_VERSION" From 86c47b004c4a6ef35d8fd7ff270d96a39c27453e Mon Sep 17 00:00:00 2001 From: muzahidul-opti Date: Wed, 27 Aug 2025 06:56:13 +0600 Subject: [PATCH 5/5] feat build: implement GitHub tag-based versioning and signing for Maven project --- build.gradle | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/build.gradle b/build.gradle index ae92f058b..5b449a47e 100644 --- a/build.gradle +++ b/build.gradle @@ -29,9 +29,9 @@ allprojects { allprojects { group = 'com.optimizely.ab' - def travis_defined_version = System.getenv('GITHUB_TAG') - if (travis_defined_version != null) { - version = travis_defined_version + def github_tagged_version = System.getenv('GITHUB_TAG') + if (github_tagged_version != null) { + version = github_tagged_version } ext.isReleaseVersion = !version.endsWith("SNAPSHOT") @@ -52,13 +52,6 @@ configure(publishedProjects) { sourceCompatibility = 1.8 targetCompatibility = 1.8 - // repositories { - // // jcenter() - // maven { - // url 'https://plugins.gradle.org/m2/' - // } - // } - task sourcesJar(type: Jar, dependsOn: classes) { archiveClassifier.set('sources') from sourceSets.main.allSource @@ -125,7 +118,6 @@ configure(publishedProjects) { } } - def docTitle = "Optimizely Java SDK" if (name.equals('core-httpclient-impl')) { docTitle = "Optimizely Java SDK: Httpclient" @@ -142,17 +134,6 @@ configure(publishedProjects) { artifact javadocJar } } - // repositories { - // maven { - // def releaseUrl = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2" - // def snapshotUrl = "https://central.sonatype.com/repository/maven-snapshots/" - // url = isReleaseVersion ? releaseUrl : snapshotUrl - // credentials { - // username System.getenv('MAVEN_CENTRAL_USERNAME') - // password System.getenv('MAVEN_CENTRAL_PASSWORD') - // } - // } - // } } signing { @@ -240,7 +221,6 @@ tasks.coveralls { } // standard POM format required by MavenCentral - def customizePom(pom, title) { pom.withXml { asNode().children().last() + {