Skip to content

Commit f4d63ed

Browse files
authored
Migrate to maven central (#637)
1 parent 76d5c20 commit f4d63ed

File tree

9 files changed

+128
-135
lines changed

9 files changed

+128
-135
lines changed

android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ if (project.hasProperty("sonatypeUsername") && project.hasProperty("sonatypePass
2424
apply plugin: 'io.github.gradle-nexus.publish-plugin'
2525
nexusPublishing {
2626
repositories {
27-
create("awsNexus") {
28-
nexusUrl.set(uri("https://aws.oss.sonatype.org/service/local/"))
29-
snapshotRepositoryUrl.set(uri("https://aws.oss.sonatype.org/content/repositories/snapshots/"))
27+
sonatype {
28+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
29+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
3030
username.set(project.property("sonatypeUsername") as String)
3131
password.set(project.property("sonatypePassword") as String)
3232
}

android/iotdevicesdk/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ afterEvaluate {
136136
publishing {
137137
repositories {
138138
maven {
139-
def snapshotRepo = "https://aws.oss.sonatype.org/content/repositories/snapshots"
140-
def releaseRepo = "https://aws.oss.sonatype.org/"
139+
def snapshotRepo = "https://central.sonatype.com/repository/maven-snapshots/"
140+
def releaseRepo = "https://ossrh-staging-api.central.sonatype.com/"
141141
url = version.endsWith('SNAPSHOT') ? snapshotRepo : releaseRepo
142142
}
143143
mavenLocal()

codebuild/cd/deploy-android.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
set -o pipefail # Ensure if any part of a pipeline fails, it propogates the error through the pipeline
5+
6+
git submodule update --init
7+
cd ./android
8+
9+
# Check if promote release mode is enabled
10+
PROMOTE_RELEASE="${PROMOTE_RELEASE:-false}"
11+
12+
GPG_KEY=$(cat /tmp/aws-sdk-common-runtime.key.asc)
13+
# Publish and release
14+
# As May30th, 2025, the Sonatype OSSRH has been deprecated and replaced with Central Publisher and the new API does't support `findSonatypeStagingRepository`.
15+
# the release will need to be invoked within the same call.
16+
# https://github.com/gradle-nexus/publish-plugin/issues/379
17+
18+
if [ "$PROMOTE_RELEASE" = "true" ]; then
19+
# close and release the staging repository to promote release
20+
./gradlew -PsigningKey=$"$GPG_KEY" -PsigningPassword=$MAVEN_GPG_PASSPHRASE -PsonatypeUsername=$ST_USERNAME -PsonatypePassword=$ST_PASSWORD publishToSonatype closeAndReleaseSonatypeStagingRepository
21+
else
22+
# close the staging repository without promoting release. NOTES: you need to manually clean up the staging repository in Maven Central.
23+
./gradlew -PnewVersion=$DEPLOY_VERSION -PsigningKey=$"$GPG_KEY" -PsigningPassword=$MAVEN_GPG_PASSPHRASE -PsonatypeUsername=$ST_USERNAME -PsonatypePassword=$ST_PASSWORD publishToSonatype closeSonatypeStagingRepository
24+
fi

codebuild/cd/deploy-snapshot-android.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

codebuild/cd/deploy-snapshot.yml

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,7 @@ phases:
1212
commands:
1313
- sudo add-apt-repository ppa:openjdk-r/ppa
1414
- sudo apt-get update -y
15-
# Android requires 11 for gradle
1615
- sudo apt-get install openjdk-11-jdk-headless maven wget unzip -y -f
17-
# install android sdk
18-
- wget --quiet https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
19-
- export ANDROID_SDK_ROOT=$CODEBUILD_SRC_DIR/android-sdk
20-
- mkdir -p $ANDROID_SDK_ROOT/cmdline-tools
21-
- unzip commandlinetools-linux-7583922_latest.zip -d $ANDROID_SDK_ROOT/cmdline-tools
22-
# This weird path needed for cmd tool to work
23-
- mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest
24-
# install android build tools
25-
- echo y | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --install "build-tools;30.0.3" "platforms;android-30" "ndk;21.4.7075529"
2616
- echo "\nBuild version data:"
2717
- echo "\nJava Version:"; java -version
2818
- echo "\nMaven Version:"; mvn --version
@@ -32,61 +22,41 @@ phases:
3222
commands:
3323
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2
3424
- export PKG_VERSION=$(cat $CODEBUILD_SRC_DIR/VERSION)
35-
25+
- echo $PKG_VERSION
3626
# install settings.xml to ~/.m2/settings.xml
3727
- mkdir -p $HOME/.m2
3828
- export CD_SETTINGS=$(aws secretsmanager get-secret-value --secret-id cd/aws-crt-java-settings/token --query "SecretString" | cut -f2 -d\")
3929
- echo $CD_SETTINGS > $HOME/.m2/settings.xml
4030

4131
# Use the password and username from secret manager to update the settings
42-
- export ST_USERNAME=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token | cut -f2 -d":" | cut -f1 -d"," | sed -e 's/[\\\"\}]//g')
43-
- export ST_PASSWORD=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token | cut -f3 -d":" | sed -e 's/[\\\"\}]//g')
32+
- export ST_USERNAME=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token --region us-east-1 | cut -f2 -d":" | cut -f1 -d"," | sed -e 's/[\\\"\}]//g')
33+
- export ST_PASSWORD=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token --region us-east-1 | cut -f3 -d":" | sed -e 's/[\\\"\}]//g')
34+
# Use the username and password from secret manager to update the settings
4435
- sed -i 's|token-username|'"$ST_USERNAME"'|g' $HOME/.m2/settings.xml
4536
- sed -i 's|token-password|'"$ST_PASSWORD"'|g' $HOME/.m2/settings.xml
46-
4737
# import gpg key
4838
- export CD_KEY=$(aws secretsmanager get-secret-value --secret-id cd/aws-crt-java-key --query "SecretString" | cut -f2 -d\")
4939
- echo $CD_KEY > /tmp/aws-sdk-common-runtime.key.asc
50-
40+
# for https://github.com/keybase/keybase-issues/issues/2798
41+
- export GPG_TTY=$(tty)
5142
- gpg --batch --import /tmp/aws-sdk-common-runtime.key.asc
52-
- export GPG_PASSPHRASE=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id cd/aws-crt-java-key/password | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
53-
54-
# Java 17 needs special JDK options apparently. It is a known Sonatype issue.
55-
# Issue link: https://issues.sonatype.org/browse/NEXUS-27902
56-
- export JDK_JAVA_OPTIONS='--add-opens java.base/java.util=ALL-UNNAMED'
57-
43+
# refer to https://maven.apache.org/plugins/maven-gpg-plugin/usage.html
44+
- export MAVEN_GPG_PASSPHRASE=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id cd/aws-crt-java-key/password | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
5845
build:
5946
commands:
6047
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2/sdk
6148
# update the CRT dependency to the latest released version
6249
- mvn -B versions:use-latest-versions -Dincludes=software.amazon.awssdk.crt*
6350

64-
# update the version to match the git tag, make a snapshot version we can test
65-
- mvn -B versions:set -DnewVersion=${PKG_VERSION}-SNAPSHOT
66-
# do a full build/deploy, but skip tests, since the shared libs were artifacts above
67-
- mvn -B deploy -Prelease -Dmaven.test.skip=true -Dgpg.passphrase=$GPG_PASSPHRASE
51+
# make a snapshot version we can test
52+
- export DEPLOY_VERSION=${PKG_VERSION}-SNAPSHOT
53+
- mvn -B versions:set -DnewVersion=${DEPLOY_VERSION}
54+
- mvn -B deploy -Prelease -Dmaven.test.skip=true
6855

69-
# update the version to match the git tag, make a staging release which we will release once snapshot testing passes
70-
- mvn -B versions:set -DnewVersion=${PKG_VERSION}
71-
- mvn -B deploy -Prelease -Dmaven.test.skip=true -Dgpg.passphrase=$GPG_PASSPHRASE | tee /tmp/deploy.log
72-
- cat /tmp/deploy.log | grep "Created staging repository with ID" | cut -d\" -f2 | tee /tmp/repositoryId.txt
73-
74-
# Store the repository ID in a secret for use later
75-
- aws secretsmanager update-secret --secret-id cd/aws-iot-device-sdk-java-v2/repository-id --secret-string "$(cat /tmp/repositoryId.txt)" --region us-east-1
76-
77-
# delploy android
78-
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2
79-
- ./codebuild/cd/deploy-snapshot-android.sh
80-
# Store the repository ID in a secret for use later
81-
- aws secretsmanager update-secret --secret-id cd/aws-iot-device-sdk-java-v2/repository-id-android --secret-string "$(cat /tmp/android_repositoryId.txt)" --region us-east-1
82-
83-
artifacts:
84-
discard-paths: yes
85-
files:
86-
- $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2/target/aws-crt-*.jar
87-
- $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2/target/aws-crt-*.asc
88-
- /tmp/repositoryId.txt
89-
- /tmp/android_repositoryId.txt
56+
post_build:
57+
commands:
58+
# --- TEST SNAPSHOT ---
59+
- mvn -B dependency:get -DrepoUrl=https://central.sonatype.com/repository/maven-snapshots/ -Dartifact=software.amazon.awssdk.iotdevicesdk:aws-iot-device-sdk:${DEPLOY_VERSION} -Dtransitive=false
9060

9161
cache:
9262
paths:
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Assumes are running using the Ubuntu Codebuild standard image
2+
# Makes the full release deployment.
3+
# This job is responsible for artifacting the JAR which will have all of the other shared libs stuffed
4+
# into it once all platforms are built and artifacted
5+
#
6+
# NOTE: This script assumes that the AWS CLI-V2 is pre-installed!
7+
# - AWS CLI-V2 is a requirement to run this script.
8+
9+
version: 0.2
10+
phases:
11+
install:
12+
commands:
13+
- sudo add-apt-repository ppa:openjdk-r/ppa
14+
- sudo apt-get update -y
15+
# Android requires 11 for gradle
16+
- sudo apt-get install openjdk-11-jdk-headless maven wget unzip -y -f
17+
# install android sdk
18+
- wget --quiet https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
19+
- export ANDROID_SDK_ROOT=$CODEBUILD_SRC_DIR/android-sdk
20+
- mkdir -p $ANDROID_SDK_ROOT/cmdline-tools
21+
- unzip commandlinetools-linux-7583922_latest.zip -d $ANDROID_SDK_ROOT/cmdline-tools
22+
# This weird path needed for cmd tool to work
23+
- mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest
24+
# install android build tools
25+
- echo y | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --install "build-tools;30.0.3" "platforms;android-30" "ndk;21.4.7075529"
26+
- echo "\nBuild version data:"
27+
- echo "\nJava Version:"; java -version
28+
- echo "\nMaven Version:"; mvn --version
29+
- echo "\n"
30+
31+
pre_build:
32+
commands:
33+
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2
34+
- export PKG_VERSION=$(cat $CODEBUILD_SRC_DIR/VERSION)
35+
- echo PKG_VERSION=$PKG_VERSION
36+
37+
# install settings.xml to ~/.m2/settings.xml
38+
- mkdir -p $HOME/.m2
39+
- export CD_SETTINGS=$(aws secretsmanager get-secret-value --secret-id cd/aws-crt-java-settings/token --query "SecretString" | cut -f2 -d\")
40+
- echo $CD_SETTINGS > $HOME/.m2/settings.xml
41+
- export ST_USERNAME=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token --region us-east-1 | cut -f2 -d":" | cut -f1 -d"," | sed -e 's/[\\\"\}]//g')
42+
- export ST_PASSWORD=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token --region us-east-1 | cut -f3 -d":" | sed -e 's/[\\\"\}]//g')
43+
# Use the username and password from secret manager to update the settings
44+
- sed -i 's|token-username|'"$ST_USERNAME"'|g' $HOME/.m2/settings.xml
45+
- sed -i 's|token-password|'"$ST_PASSWORD"'|g' $HOME/.m2/settings.xml
46+
47+
# import gpg key
48+
- export CD_KEY=$(aws secretsmanager get-secret-value --secret-id cd/aws-crt-java-key --query "SecretString" | cut -f2 -d\")
49+
- echo $CD_KEY > /tmp/aws-sdk-common-runtime.key.asc
50+
# for https://github.com/keybase/keybase-issues/issues/2798
51+
- export GPG_TTY=$(tty)
52+
53+
- gpg --batch --import /tmp/aws-sdk-common-runtime.key.asc
54+
# refer to https://maven.apache.org/plugins/maven-gpg-plugin/usage.html
55+
- export MAVEN_GPG_PASSPHRASE=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id cd/aws-crt-java-key/password | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
56+
57+
build:
58+
commands:
59+
# Deploy android
60+
- export PROMOTE_RELEASE=true
61+
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2
62+
- ./codebuild/cd/deploy-android.sh
63+
64+
cache:
65+
paths:
66+
- "/root/.m2/**/*"

codebuild/cd/promote-release.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ phases:
1212
commands:
1313
- sudo add-apt-repository ppa:openjdk-r/ppa
1414
- sudo apt-get update -y
15-
- sudo apt-get install openjdk-8-jdk-headless maven -y -f
15+
# Android requires 11 for gradle
16+
- sudo apt-get install openjdk-11-jdk-headless maven wget unzip -y -f
1617
- echo "\nBuild version data:"
1718
- echo "\nJava Version:"; java -version
1819
- echo "\nMaven Version:"; mvn --version
@@ -28,32 +29,27 @@ phases:
2829
- mkdir -p $HOME/.m2
2930
- export CD_SETTINGS=$(aws secretsmanager get-secret-value --secret-id cd/aws-crt-java-settings/token --query "SecretString" | cut -f2 -d\")
3031
- echo $CD_SETTINGS > $HOME/.m2/settings.xml
31-
32-
# Use the password and username from secret manager to update the settings
33-
- export ST_USERNAME=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token | cut -f2 -d":" | cut -f1 -d"," | sed -e 's/[\\\"\}]//g')
34-
- export ST_PASSWORD=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token | cut -f3 -d":" | sed -e 's/[\\\"\}]//g')
32+
- export ST_USERNAME=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token --region us-east-1 | cut -f2 -d":" | cut -f1 -d"," | sed -e 's/[\\\"\}]//g')
33+
- export ST_PASSWORD=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id Sonatype/JIRA/token --region us-east-1 | cut -f3 -d":" | sed -e 's/[\\\"\}]//g')
34+
# Use the username and password from secret manager to update the settings
3535
- sed -i 's|token-username|'"$ST_USERNAME"'|g' $HOME/.m2/settings.xml
3636
- sed -i 's|token-password|'"$ST_PASSWORD"'|g' $HOME/.m2/settings.xml
3737

3838
# import gpg key
3939
- export CD_KEY=$(aws secretsmanager get-secret-value --secret-id cd/aws-crt-java-key --query "SecretString" | cut -f2 -d\")
4040
- echo $CD_KEY > /tmp/aws-sdk-common-runtime.key.asc
41+
# for https://github.com/keybase/keybase-issues/issues/2798
42+
- export GPG_TTY=$(tty)
4143

4244
- gpg --batch --import /tmp/aws-sdk-common-runtime.key.asc
43-
- export GPG_PASSPHRASE=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id cd/aws-crt-java-key/password | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
44-
- export REPOSITORY_ID=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id cd/aws-iot-device-sdk-java-v2/repository-id --region us-east-1 | sed -e 's/[\\\"\}]//g')
45-
- export ANDROID_REPOSITORY_ID=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id cd/aws-iot-device-sdk-java-v2/repository-id-android --region us-east-1 | sed -e 's/[\\\"\}]//g')
46-
47-
# Java 17 needs special JDK options apparently. It is a known Sonatype issue.
48-
# Issue link: https://issues.sonatype.org/browse/NEXUS-27902
49-
- export JDK_JAVA_OPTIONS='--add-opens java.base/java.util=ALL-UNNAMED'
45+
# refer to https://maven.apache.org/plugins/maven-gpg-plugin/usage.html
46+
- export MAVEN_GPG_PASSPHRASE=$(aws --query "SecretString" secretsmanager get-secret-value --secret-id cd/aws-crt-java-key/password | cut -f2 -d":" | sed -e 's/[\\\"\}]//g')
5047

5148
build:
5249
commands:
5350
- cd $CODEBUILD_SRC_DIR/aws-iot-device-sdk-java-v2/sdk
5451
# Trigger the release of the last staged package in the staging repository
55-
- mvn -B nexus-staging:release -Prelease -DstagingRepositoryId=$REPOSITORY_ID
56-
- mvn -B nexus-staging:release -PnewVersion="$PKG_VERSION" -Prelease -DstagingRepositoryId=$ANDROID_REPOSITORY_ID
52+
- mvn deploy -DskipTests
5753

5854
cache:
5955
paths:

codebuild/cd/test-snapshot.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

sdk/pom.xml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -192,24 +192,18 @@
192192
<profiles>
193193
<profile>
194194
<id>release</id>
195-
<distributionManagement>
196-
<snapshotRepository>
197-
<id>ossrh</id>
198-
<url>https://aws.oss.sonatype.org/content/repositories/snapshots</url>
199-
</snapshotRepository>
200-
</distributionManagement>
201195
<build>
202196
<plugins>
203197
<!-- staging/release to Sonatype -->
204198
<plugin>
205-
<groupId>org.sonatype.plugins</groupId>
206-
<artifactId>nexus-staging-maven-plugin</artifactId>
207-
<version>1.6.13</version>
199+
<!-- staging/release to Sonatype Central -->
200+
<groupId>org.sonatype.central</groupId>
201+
<artifactId>central-publishing-maven-plugin</artifactId>
202+
<version>0.7.0</version>
208203
<extensions>true</extensions>
209204
<configuration>
210-
<serverId>ossrh</serverId>
211-
<nexusUrl>https://aws.oss.sonatype.org/</nexusUrl>
212-
<autoReleaseAfterClose>false</autoReleaseAfterClose>
205+
<publishingServerId>central</publishingServerId>
206+
<autoPublish>true</autoPublish>
213207
</configuration>
214208
</plugin>
215209
<!-- source jar -->
@@ -244,7 +238,7 @@
244238
<plugin>
245239
<groupId>org.apache.maven.plugins</groupId>
246240
<artifactId>maven-gpg-plugin</artifactId>
247-
<version>1.6</version>
241+
<version>3.2.7</version>
248242
<executions>
249243
<execution>
250244
<id>sign-artifacts</id>

0 commit comments

Comments
 (0)