Polish spring-boot-loader-tools

Issue: #53129653
pull/9/head
Phillip Webb 11 years ago
parent 826f42746a
commit 0db6799def

@ -16,6 +16,7 @@
package org.springframework.boot.loader.tools; package org.springframework.boot.loader.tools;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -25,6 +26,7 @@ import java.io.FilterInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.URL;
import java.util.Arrays; import java.util.Arrays;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashSet; import java.util.HashSet;
@ -45,7 +47,7 @@ import java.util.zip.ZipEntry;
*/ */
class JarWriter { class JarWriter {
private static final String NESTED_LOADER_JAR = "/META-INF/loader/spring-boot-loader.jar"; private static final String NESTED_LOADER_JAR = "META-INF/loader/spring-boot-loader.jar";
private static final int BUFFER_SIZE = 4096; private static final int BUFFER_SIZE = 4096;
@ -122,8 +124,9 @@ class JarWriter {
* @throws IOException * @throws IOException
*/ */
public void writeLoaderClasses() throws IOException { public void writeLoaderClasses() throws IOException {
JarInputStream inputStream = new JarInputStream(getClass().getResourceAsStream( URL loaderJar = getClass().getClassLoader().getResource(NESTED_LOADER_JAR);
NESTED_LOADER_JAR)); JarInputStream inputStream = new JarInputStream(new BufferedInputStream(
loaderJar.openStream()));
JarEntry entry; JarEntry entry;
while ((entry = inputStream.getNextJarEntry()) != null) { while ((entry = inputStream.getNextJarEntry()) != null) {
if (entry.getName().endsWith(".class")) { if (entry.getName().endsWith(".class")) {

@ -51,7 +51,7 @@ public class Repackager {
/** /**
* Sets the main class that should be run. If not specified the value from the * Sets the main class that should be run. If not specified the value from the
* MANIFEST will be used, or if no manifest entry is found a class the archive will be * MANIFEST will be used, or if no manifest entry is found the archive will be
* searched for a suitable class. * searched for a suitable class.
* @param mainClass the main class name * @param mainClass the main class name
*/ */

Loading…
Cancel
Save