Skip to content

Commit 3208b9b

Browse files
authored
Road grading (#2)
Signed-off-by: Laird Nelson <[email protected]>
1 parent 77032fc commit 3208b9b

File tree

15 files changed

+416
-232
lines changed

15 files changed

+416
-232
lines changed

.github/workflows/mvn-release-prepare-perform.yaml

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,24 @@ jobs:
2424
steps:
2525
- id: 'checkout'
2626
name: 'Step: Check Out Project'
27-
uses: 'actions/checkout@v4'
27+
uses: 'actions/checkout@v6'
2828
with:
2929
fetch-depth: 1
3030
persist-credentials: false
3131
- id: 'setup-java'
3232
name: 'Step: Set Up Java and Maven'
33-
uses: 'actions/setup-java@v4'
33+
uses: 'actions/setup-java@v5'
3434
with:
3535
cache: 'maven'
3636
distribution: 'temurin'
3737
gpg-passphrase: 'GPG_PASSPHRASE'
3838
gpg-private-key: '${{ secrets.GPG_PRIVATE_KEY }}'
39-
java-version: '23'
40-
mvn-toolchain-id: 'Temurin 23'
39+
java-version: '25'
40+
mvn-toolchain-id: 'Temurin 25'
4141
mvn-toolchain-vendor: 'openjdk' # see ../../pom.xml
42-
server-id: 'sonatype-oss-repository-hosting' # see https://github.com/microbean/microbean-parent/blob/master/pom.xml#L38
43-
server-password: 'SONATYPE_OSSRH_PASSWORD'
44-
server-username: 'SONATYPE_OSSRH_USERNAME'
42+
server-id: 'central.sonatype.com'
43+
server-password: 'CENTRAL_SONATYPE_COM_PASSWORD'
44+
server-username: 'CENTRAL_SONATYPE_COM_USERNAME'
4545
- id: 'setup-askpass'
4646
name: 'Step: Set Up GIT_ASKPASS'
4747
run: |
@@ -58,29 +58,28 @@ jobs:
5858
- id: 'mvn-release-prepare'
5959
name: 'Step: Maven Release: Prepare, Perform and Publish Site'
6060
env:
61+
CENTRAL_SONATYPE_COM_PASSWORD: '${{ secrets.CENTRAL_SONATYPE_COM_PASSWORD }}'
62+
CENTRAL_SONATYPE_COM_USERNAME: '${{ secrets.CENTRAL_SONATYPE_COM_USERNAME }}'
6163
DRY_RUN: '${{ inputs.dryRun }}'
6264
GIT_ASKPASS: '${{ runner.temp }}/.askpass'
6365
GPG_PASSPHRASE: '${{ secrets.GPG_PASSPHRASE }}'
6466
MVN_DEBUG: ${{ inputs.mvnDebug && '--debug' || '' }}
6567
MVN_TRANSFER_LOGGING: ${{ inputs.mvnTransferLogging && '' || '--no-transfer-progress' }}
6668
PUSH_TOKEN : '${{ secrets.PUSH_TOKEN }}' # critical; see ${GIT_ASKPASS} file
6769
SCM_GIT_HTTPS_URL: 'scm:git:${{ github.server_url }}/${{ github.repository }}.git'
68-
SONATYPE_OSSRH_PASSWORD: '${{ secrets.SONATYPE_OSSRH_PASSWORD }}'
69-
SONATYPE_OSSRH_STAGING_PROFILE_ID: '${{ vars.SONATYPE_OSSRH_STAGING_PROFILE_ID }}'
70-
SONATYPE_OSSRH_USERNAME: '${{ secrets.SONATYPE_OSSRH_USERNAME }}'
7170
shell: 'bash -e {0}'
7271
run: >
7372
git config --global user.email '[email protected]'
7473
7574
git config --global user.name 'microbean'
7675
7776
echo "::group::Running mvn prepare"
78-
77+
7978
./mvnw --batch-mode ${MVN_DEBUG} --errors ${MVN_TRANSFER_LOGGING} release:prepare
8079
-DdryRun="${DRY_RUN}"
8180
-Darguments="${MVN_TRANSFER_LOGGING}"
8281
-Dscm.url="${SCM_GIT_HTTPS_URL}"
83-
82+
8483
scm_tag="$(grep '^scm.tag=' release.properties | cut -f 2 -d =)"
8584
8685
echo "Prepared ${scm_tag}" >> "${GITHUB_STEP_SUMMARY}"
@@ -90,37 +89,13 @@ jobs:
9089
echo "::endgroup::"
9190
9291
echo "::group::Running mvn perform"
93-
94-
set +e
9592
96-
{
9793
./mvnw --batch-mode ${MVN_DEBUG} --errors ${MVN_TRANSFER_LOGGING} release:perform
98-
-Darguments="${MVN_TRANSFER_LOGGING} -Dscmpublish.dryRun=${DRY_RUN} -Dscmpublish.pubScmUrl=${SCM_GIT_HTTPS_URL} -DskipTests -DstagingProfileId=${SONATYPE_OSSRH_STAGING_PROFILE_ID}"
94+
-Darguments="${MVN_TRANSFER_LOGGING} -Dscmpublish.dryRun=${DRY_RUN} -Dscmpublish.pubScmUrl=${SCM_GIT_HTTPS_URL} -DskipTests -DautoPublish=true -DwaitUntil=published -DwaitMaxTime=3600"
9995
-DdryRun="${DRY_RUN}"
10096
-Dgoals="process-classes,post-site,scm-publish:publish-scm,deploy"
10197
-Dscm.url="${SCM_GIT_HTTPS_URL}"
102-
|
103-
tee /dev/fd/3
104-
|
105-
grep --invert-match --silent 'Java class com.sonatype.nexus.staging.api.dto.StagingProfileRepositoryDTO' || cat > /dev/null
106-
;
107-
}
108-
3>&1
10998
110-
exit_codes=(${PIPESTATUS[@]})
99+
echo "Released ${scm_tag} successfully" >> "${GITHUB_STEP_SUMMARY}";
111100
112101
echo "::endgroup::"
113-
114-
set -e
115-
116-
if [ "${exit_codes[2]}" -ne 0 ] ; then
117-
# grep "failed" (found com.sonatype.nexus.staging.api.dto.StagingProfileRepositoryDTO) and mvn failed
118-
echo "Released ${scm_tag} successfully, but verify that the staging repository was successfully released" >> "${GITHUB_STEP_SUMMARY}";
119-
# Treat this as a successful run
120-
exit 0;
121-
elif [ "${exit_codes[0]}" -eq 0 ] ; then
122-
# mvn succeeded and grep "succeeded" (did not find com.sonatype.nexus.staging.api.dto.StagingProfileRepositoryDTO)
123-
echo "Released ${scm_tag} successfully" >> "${GITHUB_STEP_SUMMARY}";
124-
fi
125-
126-
exit "${exit_codes[0]}"

.github/workflows/mvn-verify.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ jobs:
1212
steps:
1313
- id: 'checkout'
1414
name: 'Step: Checkout'
15-
uses: 'actions/checkout@v4'
15+
uses: 'actions/checkout@v6'
1616
with:
1717
fetch-depth: 1
1818
persist-credentials: false
1919
- id: 'setup-java'
2020
name: 'Step: Set Up Java and Maven'
21-
uses: 'actions/setup-java@v4'
21+
uses: 'actions/setup-java@v5'
2222
with:
2323
cache: 'maven'
2424
distribution: 'temurin'
25-
java-version: '23'
26-
mvn-toolchain-id: 'Temurin 23'
25+
java-version: '25'
26+
mvn-toolchain-id: 'Temurin 25'
2727
mvn-toolchain-vendor: 'openjdk' # see ../../pom.xml
2828
- id: 'mvn-verify'
2929
name: 'Step: Maven Verify'
Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
# Licensed to the Apache Software Foundation (ASF) under one
2-
# or more contributor license agreements. See the NOTICE file
3-
# distributed with this work for additional information
4-
# regarding copyright ownership. The ASF licenses this file
5-
# to you under the Apache License, Version 2.0 (the
6-
# "License"); you may not use this file except in compliance
7-
# with the License. You may obtain a copy of the License at
1+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
2+
# file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
3+
# to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
4+
# License. You may obtain a copy of the License at
85
#
96
# http://www.apache.org/licenses/LICENSE-2.0
107
#
11-
# Unless required by applicable law or agreed to in writing,
12-
# software distributed under the License is distributed on an
13-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14-
# KIND, either express or implied. See the License for the
15-
# specific language governing permissions and limitations
16-
# under the License.
17-
wrapperVersion=3.3.2
8+
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
9+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10+
# specific language governing permissions and limitations under the License.
11+
wrapperVersion=3.3.4
1812
distributionType=only-script
19-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
20-
13+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Client Proxy: Byte Buddy as a Maven dependency:
3030
<groupId>org.microbean</groupId>
3131
<artifactId>microbean-clientproxy-bytebuddy</artifactId>
3232
<!-- Always check https://search.maven.org/artifact/org.microbean/microbean-clientproxy-bytebuddy for up-to-date available versions. -->
33-
<version>0.0.1</version>
33+
<version>0.0.2</version>
3434
</dependency>
3535
```
3636

mvnw

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# ----------------------------------------------------------------------------
2020

2121
# ----------------------------------------------------------------------------
22-
# Apache Maven Wrapper startup batch script, version 3.3.2
22+
# Apache Maven Wrapper startup batch script, version 3.3.4
2323
#
2424
# Optional ENV vars
2525
# -----------------
@@ -105,14 +105,17 @@ trim() {
105105
printf "%s" "${1}" | tr -d '[:space:]'
106106
}
107107

108+
scriptDir="$(dirname "$0")"
109+
scriptName="$(basename "$0")"
110+
108111
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
109112
while IFS="=" read -r key value; do
110113
case "${key-}" in
111114
distributionUrl) distributionUrl=$(trim "${value-}") ;;
112115
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
113116
esac
114-
done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties"
115-
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties"
117+
done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
118+
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
116119

117120
case "${distributionUrl##*/}" in
118121
maven-mvnd-*bin.*)
@@ -130,7 +133,7 @@ maven-mvnd-*bin.*)
130133
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
131134
;;
132135
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
133-
*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
136+
*) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
134137
esac
135138

136139
# apply MVNW_REPOURL and calculate MAVEN_HOME
@@ -227,7 +230,7 @@ if [ -n "${distributionSha256Sum-}" ]; then
227230
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
228231
exit 1
229232
elif command -v sha256sum >/dev/null; then
230-
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then
233+
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
231234
distributionSha256Result=true
232235
fi
233236
elif command -v shasum >/dev/null; then
@@ -252,8 +255,41 @@ if command -v unzip >/dev/null; then
252255
else
253256
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
254257
fi
255-
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url"
256-
mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
258+
259+
# Find the actual extracted directory name (handles snapshots where filename != directory name)
260+
actualDistributionDir=""
261+
262+
# First try the expected directory name (for regular distributions)
263+
if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
264+
if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
265+
actualDistributionDir="$distributionUrlNameMain"
266+
fi
267+
fi
268+
269+
# If not found, search for any directory with the Maven executable (for snapshots)
270+
if [ -z "$actualDistributionDir" ]; then
271+
# enable globbing to iterate over items
272+
set +f
273+
for dir in "$TMP_DOWNLOAD_DIR"/*; do
274+
if [ -d "$dir" ]; then
275+
if [ -f "$dir/bin/$MVN_CMD" ]; then
276+
actualDistributionDir="$(basename "$dir")"
277+
break
278+
fi
279+
fi
280+
done
281+
set -f
282+
fi
283+
284+
if [ -z "$actualDistributionDir" ]; then
285+
verbose "Contents of $TMP_DOWNLOAD_DIR:"
286+
verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
287+
die "Could not find Maven distribution directory in extracted archive"
288+
fi
289+
290+
verbose "Found extracted Maven distribution directory: $actualDistributionDir"
291+
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
292+
mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
257293

258294
clean || :
259295
exec_maven "$@"

mvnw.cmd

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@REM ----------------------------------------------------------------------------
2020

2121
@REM ----------------------------------------------------------------------------
22-
@REM Apache Maven Wrapper startup batch script, version 3.3.2
22+
@REM Apache Maven Wrapper startup batch script, version 3.3.4
2323
@REM
2424
@REM Optional ENV vars
2525
@REM MVNW_REPOURL - repo url base for downloading maven distribution
@@ -40,7 +40,7 @@
4040
@SET __MVNW_ARG0_NAME__=
4141
@SET MVNW_USERNAME=
4242
@SET MVNW_PASSWORD=
43-
@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*)
43+
@IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*)
4444
@echo Cannot start maven from wrapper >&2 && exit /b 1
4545
@GOTO :EOF
4646
: end batch / begin powershell #>
@@ -73,16 +73,30 @@ switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
7373
# apply MVNW_REPOURL and calculate MAVEN_HOME
7474
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
7575
if ($env:MVNW_REPOURL) {
76-
$MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" }
77-
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')"
76+
$MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" }
77+
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')"
7878
}
7979
$distributionUrlName = $distributionUrl -replace '^.*/',''
8080
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
81-
$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain"
81+
82+
$MAVEN_M2_PATH = "$HOME/.m2"
8283
if ($env:MAVEN_USER_HOME) {
83-
$MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain"
84+
$MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
85+
}
86+
87+
if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
88+
New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
89+
}
90+
91+
$MAVEN_WRAPPER_DISTS = $null
92+
if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) {
93+
$MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
94+
} else {
95+
$MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
8496
}
85-
$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
97+
98+
$MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
99+
$MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
86100
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
87101

88102
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
@@ -134,7 +148,33 @@ if ($distributionSha256Sum) {
134148

135149
# unzip and move
136150
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
137-
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null
151+
152+
# Find the actual extracted directory name (handles snapshots where filename != directory name)
153+
$actualDistributionDir = ""
154+
155+
# First try the expected directory name (for regular distributions)
156+
$expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain"
157+
$expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD"
158+
if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) {
159+
$actualDistributionDir = $distributionUrlNameMain
160+
}
161+
162+
# If not found, search for any directory with the Maven executable (for snapshots)
163+
if (!$actualDistributionDir) {
164+
Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object {
165+
$testPath = Join-Path $_.FullName "bin/$MVN_CMD"
166+
if (Test-Path -Path $testPath -PathType Leaf) {
167+
$actualDistributionDir = $_.Name
168+
}
169+
}
170+
}
171+
172+
if (!$actualDistributionDir) {
173+
Write-Error "Could not find Maven distribution directory in extracted archive"
174+
}
175+
176+
Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir"
177+
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null
138178
try {
139179
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
140180
} catch {

0 commit comments

Comments
 (0)