takari / maven-wrapper

The easiest way to integrate Maven into your project!
Apache License 2.0
1.59k stars 234 forks source link

Feature/149 #150

Closed steghio closed 4 years ago

steghio commented 5 years ago

Update Maven wrapper script to provide additional debug information. Specifically:

Test on Ubuntu 18.04, sample output with MVNW_VERBOSE=false:

grog@scummbar:~/IdeaProjects/maven-wrapper$ ./mvnw clean
--2019-09-24 19:18:46--  https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar
Resolving repo.maven.apache.org (repo.maven.apache.org)... 151.101.112.215
Connecting to repo.maven.apache.org (repo.maven.apache.org)|151.101.112.215|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50710 (50K) [application/java-archive]
Saving to: ‘/home/grog/IdeaProjects/maven-wrapper/.mvn/wrapper/maven-wrapper.jar’

For the following two samples I modified file maven-wrapper.properties to include two additional lines with random values.

Sample output with MVNW_VERBOSE=true:

grog@scummbar:~/IdeaProjects/maven-wrapper$ ./mvnw clean
BASE_DIR is: /home/grog/IdeaProjects/maven-wrapper
Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ...
Reading properties from /home/grog/IdeaProjects/maven-wrapper/.mvn/wrapper/maven-wrapper.properties
If the next lines look weird, check your line endings in your maven-wrapper.properties file
Got property: {asd} value: {lol}
Got property: {kk} value: {ll}
Got property: {distributionUrl} value: {https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip}
Got property: {wrapperUrl} value: {https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar}
Downloading from: https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar
Found wget ... using wget
--2019-09-24 19:19:44--  https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar
Resolving repo.maven.apache.org (repo.maven.apache.org)... 151.101.112.215
Connecting to repo.maven.apache.org (repo.maven.apache.org)|151.101.112.215|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50710 (50K) [application/java-archive]
Saving to: ‘/home/grog/IdeaProjects/maven-wrapper/.mvn/wrapper/maven-wrapper.jar’

sample output with MVNW_VERBOSE=true AND with a maven-wrapper.properties file that uses Windows line endings

grog@scummbar:~/IdeaProjects/maven-wrapper$ ./mvnw clean
BASE_DIR is: /home/grog/IdeaProjects/maven-wrapper
Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ...
Reading properties from /home/grog/IdeaProjects/maven-wrapper/.mvn/wrapper/maven-wrapper.properties
If the next lines look weird, check your line endings in your maven-wrapper.properties file
}ot property: {asd} value: {lol
}ot property: {kk} value: {ll
}ot property: {distributionUrl} value: {https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip
}ot property: {wrapperUrl} value: {https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar
Downloading from: https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar
Found wget ... using wget
--2019-09-24 19:44:46--  https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar%0D

I think there is now enough information to understand the line ending issue more easily than by simply spotting the subtle %0D from the URL

I modified the Windows script to do exactly the same, but do not have a Windows environment on which to test unfortunately.

Please let me know if you require changes

Thank you and have a nice day

steghio commented 5 years ago

Linked issue is https://github.com/takari/maven-wrapper/issues/149

redfish4ktc commented 5 years ago

Tested on Windows 10 Pro with Powershell 5.1.18362.145 (same behaviour with Windows Command Prompt) ❌ properties are not displayed, the name of the maven-wrapper.properties is used as key instead. Notice that this issue already exists in the master branch (see comments in #149)

maven-wrapper pr_150 $ $env:MVNW_VERBOSE='true'
maven-wrapper pr_150 $ .\mvnw clean
MAVEN_PROJECTBASEDIR is: F:\maven-wrapper
Reading properties from F:\maven-wrapper\.mvn\wrapper\maven-wrapper.properties
If the next lines look weird, check your line endings in your maven-wrapper.properties file
Got property: (F:\maven-wrapper\.mvn\wrapper\maven-wrapper.properties) value: ()
Found "F:\maven-wrapper\.mvn\wrapper\maven-wrapper.jar"
Takari Maven Wrapper 0.2.3
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< io.takari:maven-wrapper >-----------------------
[INFO] Building Maven Wrapper 0.5.6-SNAPSHOT
.....
steghio commented 5 years ago

Yes it still me for both :)

Fixed it by using ' type "%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties"' and tested on Windows 7 with a folder that has a space in the path name as well as one that does not have it. Sample output:

xxx\ideaworkspace\sad lol\ilm-shared-static-resources>mvnw.cmd clean
MAVEN_PROJECTBASEDIR is: xxx\ideaworkspace\sad lol\ilm-shared-static-resources
Reading properties from xxx\ideaworkspace\sad lol\ilm-shared-static-resources\.mvn\wrapper\maven-wrapper.properties
If the next lines look weird, check your line endings in your maven-wrapper.properties file
Got property: (wrapperUrl) value: (xxx/public/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar)
Got property: (distributionUrl) value: (xxx/public/org/apache/maven/apache-maven/3.6.2/apache-maven-3.6.2-bin.zip)
Couldn't find "xxx\ideaworkspace\sad lol\ilm-shared-static-resources\.mvn\wrapper\maven-wrapper.jar", downloading it ...

and

xxx\ideaworkspace\ilm-shared-static-resources>mvnw.cmd clean
MAVEN_PROJECTBASEDIR is: xxx\ideaworkspace\ilm-shared-static-resources
Reading properties from xxx\ideaworkspace\ilm-shared-static-resources\.mvn\wrapper\maven-wrapper.properties
If the next lines look weird, check your line endings in your maven-wrapper.properties file
Got property: (wrapperUrl) value: (xxx/public/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar)
Got property: (distributionUrl) value: (xxx/public/org/apache/maven/apache-maven/3.6.2/apache-maven-3.6.2-bin.zip)
Couldn't find "xxx\ideaworkspace\ilm-shared-static-resources\.mvn\wrapper\maven-wrapper.jar", downloading it ...

The xxx is me censoring some stuff I cannot share from my workplace

steghio commented 5 years ago

Hello,

is the PR good or do you require additional changes?

Thank you and have a nice day

mosabua commented 5 years ago

Looks good. You will have to wait a while until I get around to looking at it and merging and cutting a release.

tbouffard commented 5 years ago

I confirm that this now works for both Powershell and Windows Prompt when running with folder name with or without spaces 👍

mosabua commented 4 years ago

This project is essentially frozen for development and new efforts are ongoing in the Apache Maven project itself. We therefore close this PR. Please find more information at https://github.com/takari/maven-wrapper#ongoing-migration-to-apache-maven and participate in the development there.