List of usage examples for org.springframework.boot.loader.tools Repackager repackage
public void repackage(File destination, Libraries libraries, LaunchScript launchScript) throws IOException
From source file:org.springframework.boot.loader.tools.RepackagerTests.java
@Test public void addLauncherScript() throws Exception { this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class); File source = this.testJarFile.getFile(); File dest = this.temporaryFolder.newFile("dest.jar"); Repackager repackager = new Repackager(source); LaunchScript script = new MockLauncherScript("ABC"); repackager.repackage(dest, NO_LIBRARIES, script); byte[] bytes = FileCopyUtils.copyToByteArray(dest); assertThat(new String(bytes)).startsWith("ABC"); assertThat(hasLauncherClasses(source)).isFalse(); assertThat(hasLauncherClasses(dest)).isTrue(); try {//from w ww . j a va2s .c o m assertThat(Files.getPosixFilePermissions(dest.toPath())).contains(PosixFilePermission.OWNER_EXECUTE); } catch (UnsupportedOperationException ex) { // Probably running the test on Windows } }