Skip to content

gradlew.bat/mvnw.bat should NOT be executable#923

Merged
jameskleeh merged 2 commits intomicronaut-projects:3.0.xfrom
seregamorph:fix-gradlew-bat
Oct 8, 2021
Merged

gradlew.bat/mvnw.bat should NOT be executable#923
jameskleeh merged 2 commits intomicronaut-projects:3.0.xfrom
seregamorph:fix-gradlew-bat

Conversation

@seregamorph
Copy link
Contributor

@seregamorph seregamorph commented Oct 2, 2021

If the gradle project is generated, the root directory listing has these gradle-wrapper related files:

ls -la demo/gradlew*
-rwxr-xr-x@ 1 morph  staff  8070 Oct  2 21:47 demo/gradlew
-rwxr-xr-x@ 1 morph  staff  2763 Oct  2 21:47 demo/gradlew.bat

The problem is that the second one, the bat file should not be executable, because it is auto-suggested in the shell to be executed, it raises inconvenience and requires manual fixing (via chmod). You can ensure and just list e.g. root directory of micronaut-starter:

ls -la micronaut-starter/gradlew*
-rwxr-xr-x  1 morph  staff  8070 Oct  2 22:45 micronaut-starter/gradlew
-rw-r--r--  1 morph  staff  2763 Oct  2 22:45 micronaut-starter/gradlew.bat

The first file for *nix has the executable flag, the second file for Windows - does not.

This PR addresses the issue.

How to check: e.g. run Application in starter-web-netty module, then execute
curl "http://localhost:8080/create/DEFAULT/example?build=gradle" -o example.zip and unpack the archive.

The same for maven wrapper bat executable.

@CLAassistant
Copy link

CLAassistant commented Oct 2, 2021

CLA assistant check
All committers have signed the CLA.

generatorContext.addTemplate("gradleWrapperProperties", new URLTemplate(WRAPPER_PROPS, classLoader.getResource(WRAPPER_PROPS)));
generatorContext.addTemplate("gradleWrapper", new URLTemplate("gradlew", classLoader.getResource("gradle/gradlew"), true));
generatorContext.addTemplate("gradleWrapperBat", new URLTemplate("gradlew.bat", classLoader.getResource("gradle/gradlew.bat"), true));
generatorContext.addTemplate("gradleWrapperBat", new URLTemplate("gradlew.bat", classLoader.getResource("gradle/gradlew.bat"), false));
Copy link
Contributor Author

@seregamorph seregamorph Oct 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last argument that is changed to false - executable

@seregamorph seregamorph changed the title gradlew.bat should NOT be executable gradlew.bat/mvnw.bat should NOT be executable Oct 3, 2021
@jameskleeh
Copy link
Contributor

Does this not impact Windows users? They would now have to manually set the file to be executable, correct?

@seregamorph
Copy link
Contributor Author

seregamorph commented Oct 8, 2021

@jameskleeh no, it does not affect Windows users. Windows does not have executable flag in file system. java.io.File.setExecutable() is no-op for Windows machines.

They would now have to manually set the file to be executable

No, they will not notice anything

@jameskleeh
Copy link
Contributor

Thanks

@jameskleeh jameskleeh merged commit b785954 into micronaut-projects:3.0.x Oct 8, 2021
@seregamorph seregamorph deleted the fix-gradlew-bat branch December 22, 2021 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants