Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Oct 8, 2021

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.

@@ -60,7 +60,7 @@ public void apply(GeneratorContext generatorContext) {
generatorContext.addTemplate("gradleWrapperJar", new BinaryTemplate(WRAPPER_JAR, classLoader.getResource(WRAPPER_JAR)));
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