Skip to content

Commit

Permalink
[MWRAPPER-125] Make only-script the default (#127)
Browse files Browse the repository at this point in the history
This makes only-script the default.

---

https://issues.apache.org/jira/browse/MWRAPPER-125
  • Loading branch information
cstamas authored Apr 17, 2024
1 parent 8e416f3 commit 9525271
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 15 deletions.
3 changes: 1 addition & 2 deletions maven-wrapper-plugin/src/it/projects/default/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 ')
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
# under the License.

alwaysUnpack=true
type=bin
distributionSha256Sum=7e0c63c6a99639e57cc64375d6717d72e301d8ab829fef2e145ee860317bc3cb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
# specific language governing permissions and limitations
# under the License.

type=bin
wrapperSha256Sum=7e0c63c6a99639e57cc64375d6717d72e301d8ab829fef2e145ee860317bc3cb
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,18 @@ public class WrapperMojo extends AbstractMojo {
* <dl>
* <dt>script</dt>
* <dd>only mvnw scripts</dd>
* <dt>bin (default)</dt>
* <dt>bin</dt>
* <dd>precompiled and packaged code</dd>
* <dt>source</dt>
* <dd>Java source code, will be compiled on the fly</dd>
* <dt>only-script</dt>
* <dt>only-script (default)</dt>
* <dd>the new lite implementation of mvnw/mvnw.cmd scripts downloads the maven directly and skips maven-wrapper.jar - since 3.2.0</dd>
* </dl>
* 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;

/**
Expand Down
4 changes: 2 additions & 2 deletions maven-wrapper-plugin/src/site/markdown/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
10 changes: 5 additions & 5 deletions src/site/markdown/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.

Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9525271

Please sign in to comment.