diff --git a/initializr-web/src/main/java/io/spring/initializr/web/controller/ProjectGenerationController.java b/initializr-web/src/main/java/io/spring/initializr/web/controller/ProjectGenerationController.java index 39afcbdcd1..d3e5fc106d 100644 --- a/initializr-web/src/main/java/io/spring/initializr/web/controller/ProjectGenerationController.java +++ b/initializr-web/src/main/java/io/spring/initializr/web/controller/ProjectGenerationController.java @@ -29,9 +29,6 @@ import java.util.function.Function; import java.util.stream.Stream; -import io.spring.initializr.generator.buildsystem.BuildSystem; -import io.spring.initializr.generator.buildsystem.maven.MavenBuildSystem; -import io.spring.initializr.generator.project.ProjectDescription; import io.spring.initializr.metadata.InitializrMetadata; import io.spring.initializr.metadata.InitializrMetadataProvider; import io.spring.initializr.web.project.InvalidProjectRequestException; @@ -158,7 +155,6 @@ private Path createArchive(ProjectGenerationResult resu BiFunction archiveEntry, BiConsumer setMode) throws IOException { Path archive = this.projectGenerationInvoker.createDistributionFile(result.getRootDirectory(), "." + fileExtension); - String wrapperScript = getWrapperScript(result.getProjectDescription()); try (ArchiveOutputStream output = archiveOutputStream.apply(Files.newOutputStream(archive))) { Stream files = Files.walk(result.getRootDirectory()); try (files) { @@ -166,7 +162,7 @@ private Path createArchive(ProjectGenerationResult resu try { String entryName = getEntryName(result.getRootDirectory(), path); T entry = archiveEntry.apply(path.toFile(), entryName); - setMode.accept(entry, getUnixMode(wrapperScript, entryName, path)); + setMode.accept(entry, getUnixMode(path)); output.putArchiveEntry(entry); if (!Files.isDirectory(path)) { Files.copy(path, output); @@ -190,11 +186,11 @@ private String getEntryName(Path root, Path path) { return entryName; } - private int getUnixMode(String wrapperScript, String entryName, Path path) { + private int getUnixMode(Path path) { if (Files.isDirectory(path)) { return UnixStat.DIR_FLAG | UnixStat.DEFAULT_DIR_PERM; } - return UnixStat.FILE_FLAG | (entryName.equals(wrapperScript) ? 0755 : UnixStat.DEFAULT_FILE_PERM); + return UnixStat.FILE_FLAG | (Files.isExecutable(path) ? 0755 : UnixStat.DEFAULT_FILE_PERM); } private String generateFileName(String artifactId, String extension) { @@ -203,12 +199,6 @@ private String generateFileName(String artifactId, String extension) { return URLEncoder.encode(candidate, StandardCharsets.UTF_8) + "." + extension; } - private static String getWrapperScript(ProjectDescription description) { - BuildSystem buildSystem = description.getBuildSystem(); - String script = buildSystem.id().equals(MavenBuildSystem.ID) ? "mvnw" : "gradlew"; - return (description.getBaseDirectory() != null) ? description.getBaseDirectory() + "/" + script : script; - } - private ResponseEntity upload(Path archive, Path dir, String fileName, String contentType) throws IOException { byte[] bytes = Files.readAllBytes(archive);