Skip to content

Commit 6d90188

Browse files
committed
Fix Maven/Gradle wrapper executable flag
Spring Initalizr now bundles a wrapper script for the build system. While that wrapper has the necessary execute flag in the zip archive, that flag is lost as the zip abstraction does not honor those. The init command now makes sure to restore the execute flag on `mvnw` and `gradlew` if necessary. Unfortunately, this can't be tested as the Windows build would fail to assert that the executable flag has been propertly set. Closes gh-4392
1 parent 96ca3e0 commit 6d90188

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2014 the original author or authors.
2+
* Copyright 2012-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -106,6 +106,8 @@ private void extractProject(ProjectGenerationResponse entity, String output,
106106
new ByteArrayInputStream(entity.getContent()));
107107
try {
108108
extractFromStream(zipStream, overwrite, outputFolder);
109+
fixExecutableFlag(outputFolder, "mvnw");
110+
fixExecutableFlag(outputFolder, "gradlew");
109111
Log.info("Project extracted to '" + outputFolder.getAbsolutePath() + "'");
110112
}
111113
finally {
@@ -154,4 +156,11 @@ private void writeProject(ProjectGenerationResponse entity, String output,
154156
Log.info("Content saved to '" + output + "'");
155157
}
156158

159+
private void fixExecutableFlag(File dir, String fileName) {
160+
File f = new File(dir, fileName);
161+
if (f.exists()) {
162+
f.setExecutable(true, false);
163+
}
164+
}
165+
157166
}

0 commit comments

Comments
 (0)