Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions maven-wrapper-distribution/src/resources/only-mvnw
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ fi

# If not found, search for any directory with the Maven executable (for snapshots)
if [ -z "$actualDistributionDir" ]; then
# enable globbing to iterate over items
set +f
for dir in "$TMP_DOWNLOAD_DIR"/*; do
if [ -d "$dir" ]; then
if [ -f "$dir/bin/$MVN_CMD" ]; then
Expand All @@ -276,9 +278,12 @@ if [ -z "$actualDistributionDir" ]; then
fi
fi
done
set -f
fi

if [ -z "$actualDistributionDir" ]; then
verbose "Contents of $TMP_DOWNLOAD_DIR:"
verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
die "Could not find Maven distribution directory in extracted archive"
fi

Expand Down
26 changes: 5 additions & 21 deletions maven-wrapper-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ under the License.
</extraArtifacts>
<scriptVariables>
<wrapperCurrentVersion>${project.version}</wrapperCurrentVersion>
<mrmRepositoryUrl>${mrm.repository.url}</mrmRepositoryUrl>
</scriptVariables>
</configuration>
<executions>
Expand All @@ -188,33 +189,16 @@ under the License.
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-snapshot-distribution</id>
<goals>
<goal>run</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<target>
<mkdir dir="${project.build.directory}/local-repo/org/apache/maven/apache-maven/4.1.0-SNAPSHOT" />
<copy file="${project.basedir}/../src/test/resources/repository/org/apache/maven/apache-maven/4.1.0-SNAPSHOT/apache-maven-4.1.0-20250710.120440-1-bin.zip" todir="${project.build.directory}/local-repo/org/apache/maven/apache-maven/4.1.0-SNAPSHOT" />
</target>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>mrm-maven-plugin</artifactId>
<version>1.7.0</version>
<configuration>
<repositories>
<mockRepo>
<source>src/it/repository</source>
<cloneTo>${project.build.directory}/mock-repo</cloneTo>
</mockRepo>
<localRepo>
<source>${project.build.directory}/local-repo</source>
</localRepo>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ under the License.
<configuration>
<executable>mvnw${cmd}</executable>
<successCodes>
<successCode>1</successCode>
<successCode>0</successCode>
</successCodes>
<arguments>
<argument>-v</argument>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

def userProperties = context.get('userProperties')

userProperties.put('distributionUrl', mrmRepositoryUrl + '/org/apache/maven/apache-maven/4.9.999-SNAPSHOT/apache-maven-4.9.999-20250710.120440-1-bin.zip')
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@

# Test properties for snapshot distribution integration test
type=only-script
[email protected]@/org/apache/maven/apache-maven/4.1.0-SNAPSHOT/apache-maven-4.1.0-20250710.120440-1-bin.zip
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ assert props.distributionType.equals("only-script")

// The plugin should have used our custom timestamped snapshot URL
println "Generated distribution URL: ${props.distributionUrl}"
assert props.distributionUrl.contains("apache-maven-4.1.0-20250710.120440-1-bin.zip"), "Expected timestamped snapshot distribution URL but got: ${props.distributionUrl}"
assert props.distributionUrl.contains("/org/apache/maven/apache-maven/4.1.0-SNAPSHOT/"), "Expected Maven repository path but got: ${props.distributionUrl}"
assert props.distributionUrl.contains("apache-maven-4.9.999-20250710.120440-1-bin.zip"), "Expected timestamped snapshot distribution URL but got: ${props.distributionUrl}"
assert props.distributionUrl.contains("/org/apache/maven/apache-maven/4.9.999-SNAPSHOT/"), "Expected Maven repository path but got: ${props.distributionUrl}"

println "✓ Plugin correctly used custom distributionUrl parameter"
println "✓ Distribution URL: ${props.distributionUrl}"
Expand All @@ -54,3 +54,7 @@ println "✓ Plugin correctly accepted custom distributionUrl parameter"
println "✓ Wrapper configured to use timestamped snapshot URL: ${props.distributionUrl}"
println "✓ This tests the scenario where ZIP filename != directory name inside ZIP"
println "✓ Our fix should handle: apache-maven-4.1.0-20250710.120440-1-bin.zip -> apache-maven-4.1.0-SNAPSHOT/"

log = new File(basedir, 'build.log').text
// check "mvnw" output
assert log.contains('Apache Maven 4.9.999 from SNAPSHOT distribution'), "Expected 'Apache Maven 4.9.999 from SNAPSHOT distribution' in build.log but not found"
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#\!/bin/bash
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------

# Minimal fake Maven script for testing
echo "Apache Maven 4.9.999 from SNAPSHOT distribution"
echo "Maven home: $(dirname "$(dirname "$(readlink -f "$0")")")"
exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@echo off
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------

rem Minimal fake Maven script for testing
echo Apache Maven 4.9.999 from SNAPSHOT distribution
echo Maven home: %~dp0..
exit /b 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven</groupId>
<artifactId>apache-maven</artifactId>
<version>4.9.999-SNAPSHOT</version>
</project>
Binary file not shown.
Loading