From 95252715e72e76eb1227da2f0bed12f03662526f Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Wed, 17 Apr 2024 11:11:15 +0200 Subject: [PATCH] [MWRAPPER-125] Make only-script the default (#127) This makes only-script the default. --- https://issues.apache.org/jira/browse/MWRAPPER-125 --- .../src/it/projects/default/verify.groovy | 3 +-- .../src/it/projects/mavenversion-empty1/verify.groovy | 2 +- .../src/it/projects/mavenversion-empty2/verify.groovy | 2 +- .../src/it/projects/mavenversion/verify.groovy | 2 +- .../it/projects/sha256_distribution/test.properties | 1 + .../src/it/projects/sha256_wrapper/test.properties | 1 + .../org/apache/maven/plugins/wrapper/WrapperMojo.java | 6 +++--- maven-wrapper-plugin/src/site/markdown/usage.md | 4 ++-- src/site/markdown/index.md | 10 +++++----- 9 files changed, 16 insertions(+), 15 deletions(-) diff --git a/maven-wrapper-plugin/src/it/projects/default/verify.groovy b/maven-wrapper-plugin/src/it/projects/default/verify.groovy index fce6dda1..c1a1aa11 100644 --- a/maven-wrapper-plugin/src/it/projects/default/verify.groovy +++ b/maven-wrapper-plugin/src/it/projects/default/verify.groovy @@ -23,10 +23,9 @@ assert new File(basedir,'mvnw.cmd').exists() assert !(new File(basedir,'mvnwDebug').exists()) assert !(new File(basedir,'mvnwDebug.cmd').exists()) assert new File(basedir,'.mvn/wrapper/maven-wrapper.properties').exists() -assert new File(basedir,'.mvn/wrapper/maven-wrapper.jar').exists() log = new File(basedir, 'build.log').text // check "mvn wrapper:wrapper" output -assert log.contains('[INFO] Unpacked bin type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:bin:') +assert log.contains('[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:') // check "mvnw -v" output assert log.contains('Apache Maven ') diff --git a/maven-wrapper-plugin/src/it/projects/mavenversion-empty1/verify.groovy b/maven-wrapper-plugin/src/it/projects/mavenversion-empty1/verify.groovy index 0ee5d422..ba74a1e2 100644 --- a/maven-wrapper-plugin/src/it/projects/mavenversion-empty1/verify.groovy +++ b/maven-wrapper-plugin/src/it/projects/mavenversion-empty1/verify.groovy @@ -36,6 +36,6 @@ assert mavenVersion1 == mavenVersion2 log = new File( basedir, 'build.log' ).text // check "mvn wrapper:wrapper" output -assert log.contains( '[INFO] Unpacked bin type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:bin:' ) +assert log.contains( '[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:' ) // check "mvnw -v" output assert log.contains( 'Apache Maven ' + mavenVersion1 ) diff --git a/maven-wrapper-plugin/src/it/projects/mavenversion-empty2/verify.groovy b/maven-wrapper-plugin/src/it/projects/mavenversion-empty2/verify.groovy index 0ee5d422..ba74a1e2 100644 --- a/maven-wrapper-plugin/src/it/projects/mavenversion-empty2/verify.groovy +++ b/maven-wrapper-plugin/src/it/projects/mavenversion-empty2/verify.groovy @@ -36,6 +36,6 @@ assert mavenVersion1 == mavenVersion2 log = new File( basedir, 'build.log' ).text // check "mvn wrapper:wrapper" output -assert log.contains( '[INFO] Unpacked bin type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:bin:' ) +assert log.contains( '[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:' ) // check "mvnw -v" output assert log.contains( 'Apache Maven ' + mavenVersion1 ) diff --git a/maven-wrapper-plugin/src/it/projects/mavenversion/verify.groovy b/maven-wrapper-plugin/src/it/projects/mavenversion/verify.groovy index ff4e3e0b..0f79fd60 100644 --- a/maven-wrapper-plugin/src/it/projects/mavenversion/verify.groovy +++ b/maven-wrapper-plugin/src/it/projects/mavenversion/verify.groovy @@ -35,6 +35,6 @@ assert props.distributionUrl.endsWith('/org/apache/maven/apache-maven/3.6.3/apac log = new File(basedir, 'build.log').text // check "mvn wrapper:wrapper" output -assert log.contains('[INFO] Unpacked bin type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:bin:') +assert log.contains('[INFO] Unpacked only-script type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:only-script:') // check "mvnw -v" output assert log.contains('Apache Maven 3.6.3') diff --git a/maven-wrapper-plugin/src/it/projects/sha256_distribution/test.properties b/maven-wrapper-plugin/src/it/projects/sha256_distribution/test.properties index ed4403b3..c8a102d4 100644 --- a/maven-wrapper-plugin/src/it/projects/sha256_distribution/test.properties +++ b/maven-wrapper-plugin/src/it/projects/sha256_distribution/test.properties @@ -16,4 +16,5 @@ # under the License. alwaysUnpack=true +type=bin distributionSha256Sum=7e0c63c6a99639e57cc64375d6717d72e301d8ab829fef2e145ee860317bc3cb \ No newline at end of file diff --git a/maven-wrapper-plugin/src/it/projects/sha256_wrapper/test.properties b/maven-wrapper-plugin/src/it/projects/sha256_wrapper/test.properties index 65d36cb7..64dd8552 100644 --- a/maven-wrapper-plugin/src/it/projects/sha256_wrapper/test.properties +++ b/maven-wrapper-plugin/src/it/projects/sha256_wrapper/test.properties @@ -15,4 +15,5 @@ # specific language governing permissions and limitations # under the License. +type=bin wrapperSha256Sum=7e0c63c6a99639e57cc64375d6717d72e301d8ab829fef2e145ee860317bc3cb \ No newline at end of file diff --git a/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java b/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java index b957f26b..9aeaa72e 100644 --- a/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java +++ b/maven-wrapper-plugin/src/main/java/org/apache/maven/plugins/wrapper/WrapperMojo.java @@ -88,18 +88,18 @@ public class WrapperMojo extends AbstractMojo { *
*
script
*
only mvnw scripts
- *
bin (default)
+ *
bin
*
precompiled and packaged code
*
source
*
Java source code, will be compiled on the fly
- *
only-script
+ *
only-script (default)
*
the new lite implementation of mvnw/mvnw.cmd scripts downloads the maven directly and skips maven-wrapper.jar - since 3.2.0
*
* Value will be used as classifier of the downloaded file * * @since 3.0.0 */ - @Parameter(defaultValue = "bin", property = "type") + @Parameter(defaultValue = "only-script", property = "type") private String distributionType; /** diff --git a/maven-wrapper-plugin/src/site/markdown/usage.md b/maven-wrapper-plugin/src/site/markdown/usage.md index fdf266ad..3c22bcac 100644 --- a/maven-wrapper-plugin/src/site/markdown/usage.md +++ b/maven-wrapper-plugin/src/site/markdown/usage.md @@ -34,13 +34,13 @@ Apache Maven Wrapper Distribution Types There are 4 types available: -- **only-script**: the lite implementation of `mvnw`/`mvnw.cmd` scripts will download the maven directly via wget or curl on *nix, or PowerShell on Windows, +- **only-script** _(default)_: the lite implementation of `mvnw`/`mvnw.cmd` scripts will download the maven directly via wget or curl on *nix, or PowerShell on Windows, then exec/call the original `mvn`/`mvn.cmd` scripts of the downloaded maven distribution. This type does not use `maven-wrapper.jar` nor `MavenWrapperDownloader.java`, only the wrapper scripts are required. - **script**: With this type the scripts will try to download the scripts via wget or curl in case of Unix based system, or use Powershell in case of Windows -- **bin** _(default)_: With this type the maven-wrapper jar is already available in the `.mvn/wrapper` folder, so you don't have to rely on wget/curl or Powershell +- **bin**: With this type the maven-wrapper jar is already available in the `.mvn/wrapper` folder, so you don't have to rely on wget/curl or Powershell The downside is that the project will contain a binary file in the source control management system. - **source**: Since Maven already requires Java to run, why not compile and run a classfile to download the maven-wrapper jar? diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index b3fb5044..50a52eec 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -78,7 +78,7 @@ In terms of Apache Maven versions itself, the wrapper should work with any Maven 3.x version and it defaults to the release used when setting up the wrapper. We do NOT plan to support the deprecated, EOL'ed Maven 2.x. -The `maven-wrapper.jar` (to download and install target Maven version required by `mvnw`) and the Maven Wrapper Plugin (to inject Wrapper into a project) use Java 7. +By default, the `only-script` type is installed (see below). ## Verbose Mode @@ -87,9 +87,9 @@ is activated by setting the `MVNW_VERBOSE` environment variable to `true`. By default it is off. -## Usage without Binary JAR +## Usage with or without Binary JAR -By default, the Maven Wrapper JAR archive is added to the using project as small +Using `type=bin`, the Maven Wrapper JAR archive is added to the using project as small binary file `.mvn/wrapper/maven-wrapper.jar`. It is used to bootstrap the download and invocation of Maven from the wrapper shell scripts. @@ -98,11 +98,10 @@ use the source distribution of the maven wrapper which adds a file `.mvn/wrapper/MavenWrapperDownloader.java` file instead: ```shell -# defaults to bin mvn wrapper:wrapper -Dtype=source ``` -You can also chose to opt out of all additional resources except the wrapper scripts: +You can also choose to opt out of all additional resources except the wrapper scripts: ```shell mvn wrapper:wrapper -Dtype=script @@ -112,6 +111,7 @@ Another type is the lite implementation of `mvnw`/`mvnw.cmd` scripts which downl via wget or curl on *nix, or PowerShell on Windows, then call the original `mvn`/`mvn.cmd` scripts of the downloaded maven distribution. This type does not use `maven-wrapper.jar` nor `MavenWrapperDownloader.java`, only the wrapper scripts are required. +This is the default type being installed, when no type parameter is specified. ```shell mvn wrapper:wrapper -Dtype=only-script