takari / maven-wrapper

The easiest way to integrate Maven into your project!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add more debug statements

steghio opened this issue · comments

Hello,

maven wrapper command line scripts allow setting environment variable to have debug printed when the script runs.

However, the information being reported is very limited and not enough to actually debug the script. For example, the very important values for $BASE_DIR returned by function find_maven_basedir and the line(s) read from file $BASE_DIR/.mvn/wrapper/maven-wrapper.properties are NOT echoed.

A common debug case for this is a Git repo without line endings enforcement. If someone pushed a maven-wrapper.properties file from a Windows machine and the build happens on a Linux agent, the script will ignore the content of the file since this section:

while IFS="=" read key value; do
      case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
      esac
    done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"

would NOT correctly split the lines and values, therefore the jarUrl would use the default value, which is not expected.

Adding such debug information would allow spotting such stupid yet extremely common cases more quickly

Thank you and have a nice day

Please just send a PR that implements your minimal desired logging in both scripts.

Sure will do in the coming days thank you

Sorry I might have done something wrong when creating the PR it didn't link it to this issue. #150

Just as a side note, I think the Windows script might be broken already in master branch. I tried testing my version today and the version from master and this piece of code:

FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
    IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)

Does not read the property from the file, instead, it populates variable %%A with the path to the maven-wrapper.properties file.

I tried executing with both cmd.exe and powershell.exe and got the same result. The maven-wrapper.properties file I use has Windows line endings.

I have access to a Windows 7, that is where I tested. It looks like the quotes around the file name are causing the issue. Removing them:

FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
    IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)

fixes it

Can you confirm? If so, we could add it to this PR

commented

@steghio I confirm that the issue is already present in the master branch and removing the double quote make it work on Windows 10
but if the name of the directory storing the project contains spaces, the cmd script is unable to find to maven-wrapper.properties file 😢

I pushed a fix for that, please review.

Using ' type "%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties"' works in both cases

Cheers

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