Skip to content

Commit 16b227d

Browse files
authored
Merge pull request #573 from splitio/FME-4167-sonatype
Sonatype Central updated
2 parents 5b9b93c + 6d424b7 commit 16b227d

File tree

7 files changed

+205
-56
lines changed

7 files changed

+205
-56
lines changed

client/pom.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
<build>
2020
<plugins>
2121
<plugin>
22-
<groupId>org.sonatype.plugins</groupId>
23-
<artifactId>nexus-staging-maven-plugin</artifactId>
24-
<version>1.6.3</version>
22+
<groupId>org.sonatype.central</groupId>
23+
<artifactId>central-publishing-maven-plugin</artifactId>
24+
<version>0.8.0</version>
2525
<extensions>true</extensions>
2626
<configuration>
27-
<skipNexusStagingDeployMojo>false</skipNexusStagingDeployMojo>
27+
<ignorePublishedComponents>true</ignorePublishedComponents>
28+
<publishingServerId>central</publishingServerId>
29+
<autoPublish>false</autoPublish>
30+
<waitUntil>published</waitUntil>
2831
</configuration>
2932
</plugin>
3033
</plugins>

okhttp-modules/pom.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@
2020
<build>
2121
<plugins>
2222
<plugin>
23-
<groupId>org.sonatype.plugins</groupId>
24-
<artifactId>nexus-staging-maven-plugin</artifactId>
25-
<version>1.6.3</version>
23+
<groupId>org.sonatype.central</groupId>
24+
<artifactId>central-publishing-maven-plugin</artifactId>
25+
<version>0.8.0</version>
2626
<extensions>true</extensions>
2727
<configuration>
28-
<skipNexusStagingDeployMojo>false</skipNexusStagingDeployMojo>
28+
<ignorePublishedComponents>true</ignorePublishedComponents>
29+
<publishingServerId>central</publishingServerId>
30+
<autoPublish>false</autoPublish>
31+
<waitUntil>published</waitUntil>
2932
</configuration>
3033
</plugin>
3134
</plugins>

pluggable-storage/pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
<build>
2222
<plugins>
2323
<plugin>
24-
<groupId>org.sonatype.plugins</groupId>
25-
<artifactId>nexus-staging-maven-plugin</artifactId>
26-
<version>1.6.3</version>
24+
<groupId>org.sonatype.central</groupId>
25+
<artifactId>central-publishing-maven-plugin</artifactId>
26+
<version>0.8.0</version>
2727
<extensions>true</extensions>
2828
<configuration>
29-
<serverId>ossrh</serverId>
30-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
31-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
32-
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
29+
<ignorePublishedComponents>true</ignorePublishedComponents>
30+
<publishingServerId>central</publishingServerId>
31+
<autoPublish>false</autoPublish>
32+
<waitUntil>published</waitUntil>
3333
</configuration>
3434
</plugin>
3535
</plugins>

pom.xml

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,7 @@
4747
<developerConnection>scm:git@github.com:splitio/java-client.git</developerConnection>
4848
<url>git@github.com:splitio/java-client.git</url>
4949
</scm>
50-
<distributionManagement>
51-
<snapshotRepository>
52-
<id>ossrh</id>
53-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
54-
</snapshotRepository>
55-
<repository>
56-
<id>ossrh</id>
57-
<url>https://oss.sonatype.org/content/repositories/releases</url>
58-
</repository>
59-
</distributionManagement>
50+
<!-- distributionManagement block removed as it's not needed with central-publishing-maven-plugin -->
6051
<repositories>
6152
<repository>
6253
<id>ossrh</id>
@@ -188,16 +179,7 @@
188179

189180
<profile>
190181
<id>release</id>
191-
<distributionManagement>
192-
<snapshotRepository>
193-
<id>ossrh</id>
194-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
195-
</snapshotRepository>
196-
<repository>
197-
<id>ossrh</id>
198-
<url>https://oss.sonatype.org/content/repositories/releases</url>
199-
</repository>
200-
</distributionManagement>
182+
<!-- distributionManagement block removed as it's not needed with central-publishing-maven-plugin -->
201183
<build>
202184
<plugins>
203185
<plugin>
@@ -230,16 +212,16 @@
230212
</execution>
231213
</executions>
232214
</plugin>
233-
<!-- Release plugin -->
215+
<!-- Central Repository publishing plugin -->
234216
<plugin>
235-
<groupId>org.sonatype.plugins</groupId>
236-
<artifactId>nexus-staging-maven-plugin</artifactId>
237-
<version>1.6.3</version>
217+
<groupId>org.sonatype.central</groupId>
218+
<artifactId>central-publishing-maven-plugin</artifactId>
219+
<version>0.8.0</version>
238220
<extensions>true</extensions>
239221
<configuration>
240-
<serverId>ossrh</serverId>
241-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
242-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
222+
<publishingServerId>central</publishingServerId>
223+
<autoPublish>false</autoPublish>
224+
<waitUntil>published</waitUntil>
243225
</configuration>
244226
</plugin>
245227
</plugins>

redis-wrapper/pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@
4343
<build>
4444
<plugins>
4545
<plugin>
46-
<groupId>org.sonatype.plugins</groupId>
47-
<artifactId>nexus-staging-maven-plugin</artifactId>
48-
<version>1.6.3</version>
46+
<groupId>org.sonatype.central</groupId>
47+
<artifactId>central-publishing-maven-plugin</artifactId>
48+
<version>0.8.0</version>
4949
<extensions>true</extensions>
5050
<configuration>
51-
<serverId>ossrh</serverId>
52-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
53-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
54-
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
51+
<ignorePublishedComponents>true</ignorePublishedComponents>
52+
<publishingServerId>central</publishingServerId>
53+
<autoPublish>false</autoPublish>
54+
<waitUntil>published</waitUntil>
5555
</configuration>
5656
</plugin>
5757
</plugins>

testing/pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
<build>
3232
<plugins>
3333
<plugin>
34-
<groupId>org.sonatype.plugins</groupId>
35-
<artifactId>nexus-staging-maven-plugin</artifactId>
36-
<version>1.6.3</version>
34+
<groupId>org.sonatype.central</groupId>
35+
<artifactId>central-publishing-maven-plugin</artifactId>
36+
<version>0.8.0</version>
3737
<extensions>true</extensions>
3838
<configuration>
39-
<serverId>ossrh</serverId>
40-
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
41-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
42-
<skipNexusStagingDeployMojo>false</skipNexusStagingDeployMojo>
39+
<publishingServerId>central</publishingServerId>
40+
<autoPublish>false</autoPublish>
41+
<waitUntil>published</waitUntil>
42+
<ignorePublishedComponents>true</ignorePublishedComponents>
4343
</configuration>
4444
</plugin>
4545
</plugins>

update_maven_settings.sh

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
#!/bin/bash
2+
3+
# Script to update Maven settings.xml with Central Repository credentials using xmlstarlet
4+
5+
# ANSI color codes
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[0;33m'
8+
BLUE='\033[0;34m'
9+
RED='\033[0;31m'
10+
NC='\033[0m' # No Color
11+
12+
# Check if xmlstarlet is installed
13+
if ! command -v xmlstarlet &> /dev/null; then
14+
echo -e "${RED}Error: xmlstarlet is not installed.${NC}"
15+
echo "Please install xmlstarlet first:"
16+
echo " macOS: brew install xmlstarlet"
17+
echo " Debian/Ubuntu: sudo apt-get install xmlstarlet"
18+
echo " RHEL/CentOS/Fedora: sudo yum install xmlstarlet"
19+
echo "Then run this script again."
20+
exit 1
21+
fi
22+
23+
# Default values
24+
DEFAULT_SETTINGS_PATH="$HOME/.m2/settings.xml"
25+
DEFAULT_SERVER_ID="central"
26+
27+
echo -e "${BLUE}Maven Settings.xml Update Script${NC}"
28+
echo "This script will update your Maven settings.xml with Central Repository credentials."
29+
echo
30+
31+
# Ask for settings.xml path or use default
32+
read -p "Path to settings.xml [$DEFAULT_SETTINGS_PATH]: " SETTINGS_PATH
33+
SETTINGS_PATH=${SETTINGS_PATH:-$DEFAULT_SETTINGS_PATH}
34+
35+
# Variables to store existing values
36+
EXISTING_USERNAME=""
37+
EXISTING_PASSWORD=""
38+
39+
# Extract existing values if settings.xml exists
40+
if [ -f "$SETTINGS_PATH" ] && command -v xmlstarlet &> /dev/null; then
41+
# Check if the file is valid XML
42+
if xmlstarlet val "$SETTINGS_PATH" &> /dev/null; then
43+
echo -e "${YELLOW}Reading existing settings from ${SETTINGS_PATH}...${NC}"
44+
45+
# Extract existing server ID
46+
DEFAULT_SERVER_ID=$(xmlstarlet sel -t -v "/settings/servers/server[1]/id" "$SETTINGS_PATH" 2>/dev/null || echo "$DEFAULT_SERVER_ID")
47+
48+
# Extract existing username and password for the server
49+
EXISTING_USERNAME=$(xmlstarlet sel -t -v "/settings/servers/server[id='$DEFAULT_SERVER_ID']/username" "$SETTINGS_PATH" 2>/dev/null || echo "")
50+
EXISTING_PASSWORD=$(xmlstarlet sel -t -v "/settings/servers/server[id='$DEFAULT_SERVER_ID']/password" "$SETTINGS_PATH" 2>/dev/null || echo "")
51+
fi
52+
fi
53+
54+
# Ask for server ID or use default/existing
55+
read -p "Server ID [$DEFAULT_SERVER_ID]: " SERVER_ID
56+
SERVER_ID=${SERVER_ID:-$DEFAULT_SERVER_ID}
57+
58+
# Ask for username (show existing if available)
59+
USERNAME_PROMPT="Username"
60+
if [ -n "$EXISTING_USERNAME" ]; then
61+
USERNAME_PROMPT="Username (current: $EXISTING_USERNAME)"
62+
fi
63+
read -p "$USERNAME_PROMPT: " USERNAME
64+
USERNAME=${USERNAME:-$EXISTING_USERNAME}
65+
66+
# Ask for password (indicate if existing)
67+
PASSWORD_PROMPT="Password"
68+
if [ -n "$EXISTING_PASSWORD" ]; then
69+
PASSWORD_PROMPT="Password (leave empty to keep current)"
70+
fi
71+
read -s -p "$PASSWORD_PROMPT: " PASSWORD
72+
echo
73+
# Only use existing password if the user didn't enter a new one
74+
if [ -z "$PASSWORD" ] && [ -n "$EXISTING_PASSWORD" ]; then
75+
PASSWORD="$EXISTING_PASSWORD"
76+
fi
77+
78+
# Create .m2 directory if it doesn't exist
79+
M2_DIR=$(dirname "$SETTINGS_PATH")
80+
mkdir -p "$M2_DIR"
81+
82+
# No GPG configuration needed
83+
84+
# Function to create a new settings.xml file
85+
create_new_settings() {
86+
echo -e "${YELLOW}Creating new settings.xml file...${NC}"
87+
cat > "$SETTINGS_PATH" << EOF
88+
<?xml version="1.0" encoding="UTF-8"?>
89+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
90+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
91+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
92+
<servers>
93+
<server>
94+
<id>$SERVER_ID</id>
95+
<username>$USERNAME</username>
96+
<password>$PASSWORD</password>
97+
</server>
98+
</servers>
99+
</settings>
100+
EOF
101+
}
102+
103+
# Check if settings.xml exists
104+
if [ -f "$SETTINGS_PATH" ]; then
105+
echo -e "${YELLOW}Existing settings.xml found. Backing up to ${SETTINGS_PATH}.bak${NC}"
106+
cp "$SETTINGS_PATH" "${SETTINGS_PATH}.bak"
107+
108+
# Check if the file is valid XML
109+
if ! xmlstarlet val "$SETTINGS_PATH" &> /dev/null; then
110+
echo -e "${RED}Warning: The existing settings.xml is not valid XML.${NC}"
111+
read -p "Do you want to create a new settings.xml file? (y/n): " CREATE_NEW
112+
if [[ $CREATE_NEW =~ ^[Yy]$ ]]; then
113+
create_new_settings
114+
else
115+
echo -e "${RED}Exiting without making changes.${NC}"
116+
exit 1
117+
fi
118+
else
119+
# Check if servers element exists
120+
if ! xmlstarlet sel -t -v "/settings/servers" "$SETTINGS_PATH" &> /dev/null; then
121+
echo -e "${YELLOW}No servers section found. Adding servers section...${NC}"
122+
xmlstarlet ed --inplace \
123+
-s "/settings" -t elem -n "servers" \
124+
-s "/settings/servers" -t elem -n "server" \
125+
-s "/settings/servers/server" -t elem -n "id" -v "$SERVER_ID" \
126+
-s "/settings/servers/server" -t elem -n "username" -v "$USERNAME" \
127+
-s "/settings/servers/server" -t elem -n "password" -v "$PASSWORD" \
128+
"$SETTINGS_PATH"
129+
else
130+
# Check if server with this ID already exists
131+
if xmlstarlet sel -t -v "/settings/servers/server[id='$SERVER_ID']" "$SETTINGS_PATH" &> /dev/null; then
132+
echo -e "${YELLOW}Server with ID '$SERVER_ID' already exists. Updating credentials...${NC}"
133+
# Update existing server credentials
134+
xmlstarlet ed --inplace \
135+
-u "/settings/servers/server[id='$SERVER_ID']/username" -v "$USERNAME" \
136+
-u "/settings/servers/server[id='$SERVER_ID']/password" -v "$PASSWORD" \
137+
"$SETTINGS_PATH"
138+
else
139+
echo -e "${YELLOW}Adding new server with ID '$SERVER_ID'...${NC}"
140+
# Add new server to existing servers section
141+
xmlstarlet ed --inplace \
142+
-s "/settings/servers" -t elem -n "server" \
143+
-s "/settings/servers/server[last()]" -t elem -n "id" -v "$SERVER_ID" \
144+
-s "/settings/servers/server[last()]" -t elem -n "username" -v "$USERNAME" \
145+
-s "/settings/servers/server[last()]" -t elem -n "password" -v "$PASSWORD" \
146+
"$SETTINGS_PATH"
147+
fi
148+
fi
149+
fi
150+
else
151+
create_new_settings
152+
fi
153+
154+
# Make sure the file has the right permissions
155+
chmod 600 "$SETTINGS_PATH"
156+
157+
echo -e "${GREEN}Maven settings.xml updated successfully at $SETTINGS_PATH${NC}"
158+
echo -e "${GREEN}Server ID: $SERVER_ID${NC}"
159+
echo -e "${GREEN}Username: $USERNAME${NC}"
160+
echo -e "${GREEN}Password: ********${NC}"
161+

0 commit comments

Comments
 (0)