Skip to content

Commit 554c821

Browse files
RanVakninRan Vaknin
andauthored
Maven Central Migration (#6375)
* adding maven central migration plugin, config and new buildspec * Update profile config * fix gpg plugin * Remove redundant plugin config * force java 8 on the codebuild * Fix staging dir path * Fix cloudwatch reporting * Fix cloudwatch reporting * Fix buildspec, add comment --------- Co-authored-by: Ran Vaknin <rvaknin@dev-dsk-rvaknin2-2a-e69e90c1.us-west-2.amazon.com> Co-authored-by: RanVaknin <>
1 parent 3c142fb commit 554c821

File tree

7 files changed

+192
-5
lines changed

7 files changed

+192
-5
lines changed

archetypes/archetype-tools/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<modelVersion>4.0.0</modelVersion>
2626

2727
<artifactId>archetype-tools</artifactId>
28-
28+
<name>AWS Java SDK :: Archetype Tools</name>
2929
<dependencies>
3030
<!-- Depends on the artifacts of all services to generate serviceMapping.vm -->
3131
<dependency>

bom-internal/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<modelVersion>4.0.0</modelVersion>
2626

2727
<artifactId>bom-internal</artifactId>
28-
28+
<name>AWS Java SDK :: Bill of Materials Internal</name>
2929
<dependencyManagement>
3030
<dependencies>
3131
<!-- Non-Test Dependencies -->
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
version: 0.2
2+
3+
phases:
4+
install:
5+
commands:
6+
- pip install awscli --upgrade --user
7+
8+
pre_build:
9+
commands:
10+
- ROOT=`pwd`
11+
- SETTINGS_XML_TEMPLATE=buildspecs/resources/maven-central-release-settings.xml
12+
- SETTINGS_XML=release-settings-final.xml
13+
- SDK_SIGNING_GPG_SECRING=secring.gpg
14+
- SDK_SIGNING_GPG_SECRING_ARN="arn:aws:secretsmanager:us-east-1:103431983078:secret:sdk-signing-gpg-secret-ring-9d0YXc"
15+
- SDK_SIGNING_GPG_KEYNAME_ARN="arn:aws:secretsmanager:us-east-1:103431983078:secret:sdk-signing-gpg-keyname-wFsOOg"
16+
- SDK_SIGNING_GPG_PASSPHRASE_ARN="arn:aws:secretsmanager:us-east-1:103431983078:secret:sdk-signing-gpg-passphrase-A0H1Kq"
17+
- SONATYPE_PASSWORD_ARN="arn:aws:secretsmanager:us-east-1:103431983078:secret:maven-central-publishing-password-yktnUc"
18+
- SONATYPE_USERNAME_ARN="arn:aws:secretsmanager:us-east-1:103431983078:secret:maven-central-publishing-username-RDvOnW"
19+
- MODULES_TO_SKIP="protocol-tests,protocol-tests-core,codegen-generated-classes-test,sdk-benchmarks,module-path-tests,tests-coverage-reporting,stability-tests,sdk-native-image-test,auth-tests,s3-benchmarks,http-client-benchmarks,region-testing,old-client-version-compatibility-test,crt-unavailable-tests,bundle-shading-tests,v2-migration-tests,architecture-tests,s3-tests"
20+
21+
build:
22+
commands:
23+
- RELEASE_VERSION=`mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec`
24+
- ARTIFACT_URL="https://repo1.maven.org/maven2/software/amazon/awssdk/aws-sdk-java/$RELEASE_VERSION/"
25+
- |
26+
if ! curl -f --head $ARTIFACT_URL; then
27+
SONATYPE_USERNAME=`aws secretsmanager get-secret-value --secret-id $SONATYPE_USERNAME_ARN --query SecretString --output text`
28+
SONATYPE_PASSWORD=`aws secretsmanager get-secret-value --secret-id $SONATYPE_PASSWORD_ARN --query SecretString --output text`
29+
SDK_SIGNING_GPG_KEYNAME=`aws secretsmanager get-secret-value --secret-id $SDK_SIGNING_GPG_KEYNAME_ARN --query SecretString --output text`
30+
SDK_SIGNING_GPG_PASSPHRASE=`aws secretsmanager get-secret-value --secret-id $SDK_SIGNING_GPG_PASSPHRASE_ARN --query SecretString --output text`
31+
aws secretsmanager get-secret-value --secret-id $SDK_SIGNING_GPG_SECRING_ARN --query SecretBinary --output text | base64 -d > $SDK_SIGNING_GPG_SECRING
32+
gpg --passphrase $SDK_SIGNING_GPG_PASSPHRASE --batch --import $SDK_SIGNING_GPG_SECRING
33+
34+
cat $SETTINGS_XML_TEMPLATE | \
35+
awk 'BEGIN { var=ENVIRON["SONATYPE_USERNAME"] } { gsub("\\$SONATYPE_USERNAME", var, $0); print }' | \
36+
awk 'BEGIN { var=ENVIRON["SONATYPE_PASSWORD"] } { gsub("\\$SONATYPE_PASSWORD", var, $0); print }' | \
37+
awk 'BEGIN { var=ENVIRON["SDK_SIGNING_GPG_PASSPHRASE"] } { gsub("\\$SDK_SIGNING_GPG_PASSPHRASE", var, $0); print }' | \
38+
awk 'BEGIN { var=ENVIRON["SDK_SIGNING_GPG_KEYNAME"] } { gsub("\\$SDK_SIGNING_GPG_KEYNAME", var, $0); print }' > \
39+
$SETTINGS_XML
40+
41+
# Convert comma-separated list to space-separated list with !: prefix for each module
42+
MODULES_TO_SKIP_FORMATTED=$(echo $MODULES_TO_SKIP | sed 's/,/,!:/g' | sed 's/^/!:/')
43+
44+
mvn clean deploy -B -s $SETTINGS_XML -Pcentral-portal-publishing -DperformRelease -DautoPublish=true -DdeploymentName="software.amazon.awssdk-$RELEASE_VERSION" -Dspotbugs.skip -DskipTests -Dcheckstyle.skip -Djapicmp.skip -Ddoclint=none -DstagingProgressTimeoutMinutes=30 -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.requestSentEnabled=true -pl $MODULES_TO_SKIP_FORMATTED
45+
46+
# Report staging folder size to CloudWatch
47+
if [ -d "target/central-staging" ]; then
48+
STAGING_SIZE_MB=$(du -sm target/central-staging | cut -f1)
49+
aws cloudwatch put-metric-data \
50+
--namespace "AwsJavaSdkRelease" \
51+
--metric-data "MetricName=StagingFolderSize,Value=$STAGING_SIZE_MB,Unit=Megabytes"
52+
else
53+
echo "Staging folder target/central-staging not found"
54+
fi
55+
else
56+
echo "This version was already released."
57+
fi
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<settings>
2+
<servers>
3+
<server>
4+
<id>central</id>
5+
<username>$SONATYPE_USERNAME</username>
6+
<password>$SONATYPE_PASSWORD</password>
7+
</server>
8+
</servers>
9+
<profiles>
10+
<profile>
11+
<id>central-portal-publishing</id>
12+
<activation>
13+
<activeByDefault>false</activeByDefault>
14+
</activation>
15+
<properties>
16+
<gpg.keyname>$SDK_SIGNING_GPG_KEYNAME</gpg.keyname>
17+
<gpg.passphrase>$SDK_SIGNING_GPG_PASSPHRASE</gpg.passphrase>
18+
</properties>
19+
</profile>
20+
</profiles>
21+
</settings>

bundle-sdk/pom.xml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@
238238
</build>
239239

240240
<profiles>
241-
<profile>
241+
<profile>
242242
<id>publishing</id>
243243
<build>
244244
<plugins>
@@ -268,6 +268,36 @@
268268
</plugins>
269269
</build>
270270
</profile>
271+
<profile>
272+
<id>central-portal-publishing</id>
273+
<build>
274+
<plugins>
275+
<plugin>
276+
<groupId>org.apache.maven.plugins</groupId>
277+
<artifactId>maven-shade-plugin</artifactId>
278+
<configuration>
279+
<createSourcesJar>true</createSourcesJar>
280+
</configuration>
281+
</plugin>
282+
<plugin>
283+
<artifactId>maven-javadoc-plugin</artifactId>
284+
<executions>
285+
<execution>
286+
<id>javadoc-jar</id>
287+
<phase>package</phase>
288+
<goals>
289+
<goal>jar</goal>
290+
</goals>
291+
</execution>
292+
</executions>
293+
<configuration>
294+
<sourcepath>${basedir}/../core/profiles/src/main/java/software/amazon/awssdk/profiles;${basedir}/../core/sdk-core/src/main/java/software/amazon/awssdk/core</sourcepath>
295+
<failOnError>false</failOnError>
296+
</configuration>
297+
</plugin>
298+
</plugins>
299+
</build>
300+
</profile>
271301
</profiles>
272302

273303
</project>

bundle/pom.xml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,47 @@
9090
</plugin>
9191
</plugins>
9292
</build>
93-
9493
<profiles>
94+
<profile>
95+
<id>central-portal-publishing</id>
96+
<build>
97+
<plugins>
98+
<plugin>
99+
<groupId>org.apache.maven.plugins</groupId>
100+
<artifactId>maven-shade-plugin</artifactId>
101+
<configuration>
102+
<createSourcesJar>true</createSourcesJar>
103+
</configuration>
104+
</plugin>
105+
<plugin>
106+
<artifactId>maven-javadoc-plugin</artifactId>
107+
<executions>
108+
<execution>
109+
<id>javadoc-jar</id>
110+
<phase>package</phase>
111+
<goals>
112+
<goal>jar</goal>
113+
</goals>
114+
</execution>
115+
</executions>
116+
<configuration>
117+
<sourcepath>${basedir}/../core/profiles/src/main/java/software/amazon/awssdk/profiles;${basedir}/../core/sdk-core/src/main/java/software/amazon/awssdk/core</sourcepath>
118+
<failOnError>false</failOnError>
119+
</configuration>
120+
</plugin>
121+
<plugin>
122+
<groupId>org.apache.maven.plugins</groupId>
123+
<artifactId>maven-dependency-plugin</artifactId>
124+
<configuration>
125+
<ignoredUnusedDeclaredDependencies>
126+
<ignoredUnusedDeclaredDependency>software.amazon.awssdk:bundle-sdk</ignoredUnusedDeclaredDependency>
127+
<ignoredUnusedDeclaredDependency>software.amazon.awssdk:bundle-logging-bridge</ignoredUnusedDeclaredDependency>
128+
</ignoredUnusedDeclaredDependencies>
129+
</configuration>
130+
</plugin>
131+
</plugins>
132+
</build>
133+
</profile>
95134
<profile>
96135
<id>publishing</id>
97136
<build>

pom.xml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
164164
<checkstyle.version>8.42</checkstyle.version>
165165
<jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
166+
<central-publishing-maven-plugin.version>0.8.0</central-publishing-maven-plugin.version>
166167
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
167168
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
168169
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
@@ -747,7 +748,46 @@
747748
<javadoc.skip>true</javadoc.skip>
748749
</properties>
749750
</profile>
750-
751+
<profile>
752+
<!-- This is the new maven publishing profile. It's similar to the "publishing" profile except
753+
for the fact that it uses the maven central publishing plugin instead of the nexus publishing plugin.
754+
Once OSSRH is disabled we can rename this "publishing", and remove the existing publishing profile -->
755+
<id>central-portal-publishing</id>
756+
<build>
757+
<plugins>
758+
<plugin>
759+
<groupId>org.apache.maven.plugins</groupId>
760+
<artifactId>maven-gpg-plugin</artifactId>
761+
<version>${maven-gpg-plugin.version}</version>
762+
<executions>
763+
<execution>
764+
<id>sign-artifacts</id>
765+
<phase>verify</phase>
766+
<goals>
767+
<goal>sign</goal>
768+
</goals>
769+
</execution>
770+
</executions>
771+
<configuration>
772+
<gpgArguments>
773+
<arg>--batch</arg>
774+
<arg>--pinentry-mode</arg>
775+
<arg>loopback</arg>
776+
</gpgArguments>
777+
</configuration>
778+
</plugin>
779+
<plugin>
780+
<groupId>org.sonatype.central</groupId>
781+
<artifactId>central-publishing-maven-plugin</artifactId>
782+
<version>${central-publishing-maven-plugin.version}</version>
783+
<extensions>true</extensions>
784+
<configuration>
785+
<publishingServerId>central</publishingServerId>
786+
</configuration>
787+
</plugin>
788+
</plugins>
789+
</build>
790+
</profile>
751791
<profile>
752792
<id>publishing</id>
753793
<build>

0 commit comments

Comments
 (0)