use of org.springframework.boot.loader.tools.DefaultLaunchScript in project spring-boot by spring-projects.
the class BootZipCopyAction method writeLaunchScriptIfNecessary.
private void writeLaunchScriptIfNecessary(ZipArchiveOutputStream outputStream) {
if (this.launchScript == null) {
return;
}
try {
File file = this.launchScript.getScript();
Map<String, String> properties = this.launchScript.getProperties();
outputStream.writePreamble(new DefaultLaunchScript(file, properties).toByteArray());
this.output.setExecutable(true);
} catch (IOException ex) {
throw new GradleException("Failed to write launch script to " + this.output, ex);
}
}
use of org.springframework.boot.loader.tools.DefaultLaunchScript in project spring-boot by spring-projects.
the class AbstractBootArchiveTests method launchScriptCanBePrepended.
@Test
void launchScriptCanBePrepended() throws IOException {
this.task.getMainClass().set("com.example.Main");
this.task.launchScript();
executeTask();
Map<String, String> properties = new HashMap<>();
properties.put("initInfoProvides", this.task.getArchiveBaseName().get());
properties.put("initInfoShortDescription", this.project.getDescription());
properties.put("initInfoDescription", this.project.getDescription());
File archiveFile = this.task.getArchiveFile().get().getAsFile();
assertThat(Files.readAllBytes(archiveFile.toPath())).startsWith(new DefaultLaunchScript(null, properties).toByteArray());
try (ZipFile zipFile = new ZipFile(archiveFile)) {
assertThat(zipFile.getEntries().hasMoreElements()).isTrue();
}
try {
Set<PosixFilePermission> permissions = Files.getPosixFilePermissions(archiveFile.toPath());
assertThat(permissions).contains(PosixFilePermission.OWNER_EXECUTE);
} catch (UnsupportedOperationException ex) {
// Windows, presumably. Continue
}
}
Aggregations