List of usage examples for org.springframework.boot.loader.tools Repackager Repackager
public Repackager(File source)
From source file:org.eclipse.cft.server.standalone.ui.internal.application.JarArchivingUIHandler.java
protected void bootRepackage(final IPackageFragmentRoot[] roots, File packagedFile) throws CoreException { Repackager bootRepackager = new Repackager(packagedFile); try {//from ww w . j a v a 2 s . c o m bootRepackager.repackage(new Libraries() { public void doWithLibraries(LibraryCallback callBack) throws IOException { for (IPackageFragmentRoot root : roots) { if (root.isArchive()) { File rootFile = new File(root.getPath().toOSString()); if (rootFile.exists()) { callBack.library(new Library(rootFile, LibraryScope.COMPILE)); } } } } }); } catch (IOException e) { errorHandler.handleApplicationDeploymentFailure( NLS.bind(Messages.JavaCloudFoundryArchiver_ERROR_REPACKAGE_SPRING, e.getMessage())); } }
From source file:org.springframework.boot.loader.tools.RepackagerTests.java
@Test public void nullSource() { this.thrown.expect(IllegalArgumentException.class); new Repackager(null); }
From source file:org.springframework.boot.loader.tools.RepackagerTests.java
@Test public void missingSource() { this.thrown.expect(IllegalArgumentException.class); new Repackager(new File("missing")); }
From source file:org.springframework.boot.loader.tools.RepackagerTests.java
@Test public void directorySource() { this.thrown.expect(IllegalArgumentException.class); new Repackager(this.temporaryFolder.getRoot()); }
From source file:org.springframework.boot.loader.tools.RepackagerTests.java
@Test public void specificMainClass() throws Exception { this.testJarFile.addClass("a/b/C.class", ClassWithoutMainMethod.class); File file = this.testJarFile.getFile(); Repackager repackager = new Repackager(file); repackager.setMainClass("a.b.C"); repackager.repackage(NO_LIBRARIES);// w ww .j a v a2 s . c o m Manifest actualManifest = getManifest(file); assertThat(actualManifest.getMainAttributes().getValue("Main-Class")) .isEqualTo("org.springframework.boot.loader.JarLauncher"); assertThat(actualManifest.getMainAttributes().getValue("Start-Class")).isEqualTo("a.b.C"); assertThat(hasLauncherClasses(file)).isTrue(); }
From source file:org.springframework.boot.loader.tools.RepackagerTests.java
@Test public void mainClassFromManifest() throws Exception { this.testJarFile.addClass("a/b/C.class", ClassWithoutMainMethod.class); Manifest manifest = new Manifest(); manifest.getMainAttributes().putValue("Manifest-Version", "1.0"); manifest.getMainAttributes().putValue("Main-Class", "a.b.C"); this.testJarFile.addManifest(manifest); File file = this.testJarFile.getFile(); Repackager repackager = new Repackager(file); repackager.repackage(NO_LIBRARIES);//from ww w .j av a 2 s. c om Manifest actualManifest = getManifest(file); assertThat(actualManifest.getMainAttributes().getValue("Main-Class")) .isEqualTo("org.springframework.boot.loader.JarLauncher"); assertThat(actualManifest.getMainAttributes().getValue("Start-Class")).isEqualTo("a.b.C"); assertThat(hasLauncherClasses(file)).isTrue(); }
From source file:org.springframework.boot.loader.tools.RepackagerTests.java
@Test public void mainClassFound() throws Exception { this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class); File file = this.testJarFile.getFile(); Repackager repackager = new Repackager(file); repackager.repackage(NO_LIBRARIES);//from www. j ava 2 s. c o m Manifest actualManifest = getManifest(file); assertThat(actualManifest.getMainAttributes().getValue("Main-Class")) .isEqualTo("org.springframework.boot.loader.JarLauncher"); assertThat(actualManifest.getMainAttributes().getValue("Start-Class")).isEqualTo("a.b.C"); assertThat(hasLauncherClasses(file)).isTrue(); }
From source file:org.springframework.boot.loader.tools.RepackagerTests.java
@Test public void jarIsOnlyRepackagedOnce() throws Exception { this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class); File file = this.testJarFile.getFile(); Repackager repackager = new Repackager(file); repackager.repackage(NO_LIBRARIES);/*from ww w .j a v a 2s . com*/ repackager.repackage(NO_LIBRARIES); Manifest actualManifest = getManifest(file); assertThat(actualManifest.getMainAttributes().getValue("Main-Class")) .isEqualTo("org.springframework.boot.loader.JarLauncher"); assertThat(actualManifest.getMainAttributes().getValue("Start-Class")).isEqualTo("a.b.C"); assertThat(hasLauncherClasses(file)).isTrue(); }
From source file:org.springframework.boot.loader.tools.RepackagerTests.java
@Test public void multipleMainClassFound() throws Exception { this.testJarFile.addClass("a/b/C.class", ClassWithMainMethod.class); this.testJarFile.addClass("a/b/D.class", ClassWithMainMethod.class); File file = this.testJarFile.getFile(); Repackager repackager = new Repackager(file); this.thrown.expect(IllegalStateException.class); this.thrown.expectMessage( "Unable to find a single main class " + "from the following candidates [a.b.C, a.b.D]"); repackager.repackage(NO_LIBRARIES);/*from w w w. jav a2s.c o m*/ }
From source file:org.springframework.boot.loader.tools.RepackagerTests.java
@Test public void noMainClass() throws Exception { this.testJarFile.addClass("a/b/C.class", ClassWithoutMainMethod.class); this.thrown.expect(IllegalStateException.class); this.thrown.expectMessage("Unable to find main class"); new Repackager(this.testJarFile.getFile()).repackage(NO_LIBRARIES); }