Merge branch '1.2.x'
This commit is contained in:
@@ -64,8 +64,8 @@ public abstract class FileUtils {
|
||||
*/
|
||||
public static String sha1Hash(File file) throws IOException {
|
||||
try {
|
||||
DigestInputStream inputStream = new DigestInputStream(new FileInputStream(
|
||||
file), MessageDigest.getInstance("SHA-1"));
|
||||
DigestInputStream inputStream = new DigestInputStream(
|
||||
new FileInputStream(file), MessageDigest.getInstance("SHA-1"));
|
||||
try {
|
||||
byte[] buffer = new byte[4098];
|
||||
while (inputStream.read(buffer) != -1) {
|
||||
|
||||
@@ -198,8 +198,8 @@ public class JarWriter {
|
||||
*/
|
||||
public void writeLoaderClasses() throws IOException {
|
||||
URL loaderJar = getClass().getClassLoader().getResource(NESTED_LOADER_JAR);
|
||||
JarInputStream inputStream = new JarInputStream(new BufferedInputStream(
|
||||
loaderJar.openStream()));
|
||||
JarInputStream inputStream = new JarInputStream(
|
||||
new BufferedInputStream(loaderJar.openStream()));
|
||||
JarEntry entry;
|
||||
while ((entry = inputStream.getNextJarEntry()) != null) {
|
||||
if (entry.getName().endsWith(".class")) {
|
||||
@@ -323,8 +323,8 @@ public class JarWriter {
|
||||
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
int read = (this.headerStream == null ? -1 : this.headerStream.read(b, off,
|
||||
len));
|
||||
int read = (this.headerStream == null ? -1
|
||||
: this.headerStream.read(b, off, len));
|
||||
if (read != -1) {
|
||||
this.headerStream = null;
|
||||
return read;
|
||||
|
||||
@@ -31,8 +31,8 @@ abstract class JvmUtils {
|
||||
/**
|
||||
* Various search locations for tools, including the odd Java 6 OSX jar.
|
||||
*/
|
||||
private static final String[] TOOLS_LOCATIONS = { "lib/tools.jar",
|
||||
"../lib/tools.jar", "../Classes/classes.jar" };
|
||||
private static final String[] TOOLS_LOCATIONS = { "lib/tools.jar", "../lib/tools.jar",
|
||||
"../Classes/classes.jar" };
|
||||
|
||||
public static ClassLoader getToolsClassLoader() {
|
||||
ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
|
||||
|
||||
@@ -119,6 +119,7 @@ public final class Layouts {
|
||||
public static class War implements Layout {
|
||||
|
||||
private static final Map<LibraryScope, String> SCOPE_DESTINATIONS;
|
||||
|
||||
static {
|
||||
Map<LibraryScope, String> map = new HashMap<LibraryScope, String>();
|
||||
map.put(LibraryScope.COMPILE, "WEB-INF/lib/");
|
||||
|
||||
@@ -114,7 +114,8 @@ public abstract class MainClassFinder {
|
||||
return null; // nothing to do
|
||||
}
|
||||
if (!rootFolder.isDirectory()) {
|
||||
throw new IllegalArgumentException("Invalid root folder '" + rootFolder + "'");
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid root folder '" + rootFolder + "'");
|
||||
}
|
||||
String prefix = rootFolder.getAbsolutePath() + "/";
|
||||
Deque<File> stack = new ArrayDeque<File>();
|
||||
@@ -232,7 +233,8 @@ public abstract class MainClassFinder {
|
||||
return name;
|
||||
}
|
||||
|
||||
private static List<JarEntry> getClassEntries(JarFile source, String classesLocation) {
|
||||
private static List<JarEntry> getClassEntries(JarFile source,
|
||||
String classesLocation) {
|
||||
classesLocation = (classesLocation != null ? classesLocation : "");
|
||||
Enumeration<JarEntry> sourceEntries = source.entries();
|
||||
List<JarEntry> classEntries = new ArrayList<JarEntry>();
|
||||
|
||||
@@ -132,8 +132,8 @@ public class Repackager {
|
||||
destination = destination.getAbsoluteFile();
|
||||
File workingSource = this.source;
|
||||
if (this.source.equals(destination)) {
|
||||
workingSource = new File(this.source.getParentFile(), this.source.getName()
|
||||
+ ".original");
|
||||
workingSource = new File(this.source.getParentFile(),
|
||||
this.source.getName() + ".original");
|
||||
workingSource.delete();
|
||||
renameFile(this.source, workingSource);
|
||||
}
|
||||
@@ -158,8 +158,8 @@ public class Repackager {
|
||||
JarFile jarFile = new JarFile(this.source);
|
||||
try {
|
||||
Manifest manifest = jarFile.getManifest();
|
||||
return (manifest != null && manifest.getMainAttributes().getValue(
|
||||
BOOT_VERSION_ATTRIBUTE) != null);
|
||||
return (manifest != null && manifest.getMainAttributes()
|
||||
.getValue(BOOT_VERSION_ATTRIBUTE) != null);
|
||||
}
|
||||
finally {
|
||||
jarFile.close();
|
||||
@@ -208,12 +208,12 @@ public class Repackager {
|
||||
private void writeNestedLibraries(List<Library> libraries, Set<String> alreadySeen,
|
||||
JarWriter writer) throws IOException {
|
||||
for (Library library : libraries) {
|
||||
String destination = Repackager.this.layout.getLibraryDestination(
|
||||
library.getName(), library.getScope());
|
||||
String destination = Repackager.this.layout
|
||||
.getLibraryDestination(library.getName(), library.getScope());
|
||||
if (destination != null) {
|
||||
if (!alreadySeen.add(destination + library.getName())) {
|
||||
throw new IllegalStateException("Duplicate library "
|
||||
+ library.getName());
|
||||
throw new IllegalStateException(
|
||||
"Duplicate library " + library.getName());
|
||||
}
|
||||
writer.writeNestedLibrary(destination, library);
|
||||
}
|
||||
@@ -260,8 +260,8 @@ public class Repackager {
|
||||
}
|
||||
String launcherClassName = this.layout.getLauncherClassName();
|
||||
if (launcherClassName != null) {
|
||||
manifest.getMainAttributes()
|
||||
.putValue(MAIN_CLASS_ATTRIBUTE, launcherClassName);
|
||||
manifest.getMainAttributes().putValue(MAIN_CLASS_ATTRIBUTE,
|
||||
launcherClassName);
|
||||
if (startClass == null) {
|
||||
throw new IllegalStateException("Unable to find main class");
|
||||
}
|
||||
@@ -282,8 +282,8 @@ public class Repackager {
|
||||
|
||||
private void renameFile(File file, File dest) {
|
||||
if (!file.renameTo(dest)) {
|
||||
throw new IllegalStateException("Unable to rename '" + file + "' to '" + dest
|
||||
+ "'");
|
||||
throw new IllegalStateException(
|
||||
"Unable to rename '" + file + "' to '" + dest + "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ import org.springframework.util.ReflectionUtils;
|
||||
*/
|
||||
public class RunProcess {
|
||||
|
||||
private static final Method INHERIT_IO_METHOD = ReflectionUtils.findMethod(
|
||||
ProcessBuilder.class, "inheritIO");
|
||||
private static final Method INHERIT_IO_METHOD = ReflectionUtils
|
||||
.findMethod(ProcessBuilder.class, "inheritIO");
|
||||
|
||||
private static final long JUST_ENDED_LIMIT = 500;
|
||||
|
||||
@@ -131,8 +131,8 @@ public class RunProcess {
|
||||
}
|
||||
|
||||
private void redirectOutput(Process process) {
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||
process.getInputStream()));
|
||||
final BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(process.getInputStream()));
|
||||
new Thread() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -91,8 +91,8 @@ public class MainClassFinderTests {
|
||||
public void findMainClassInJarSubLocation() throws Exception {
|
||||
this.testJarFile.addClass("a/B.class", ClassWithMainMethod.class);
|
||||
this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
|
||||
String actual = MainClassFinder
|
||||
.findMainClass(this.testJarFile.getJarFile(), "a/");
|
||||
String actual = MainClassFinder.findMainClass(this.testJarFile.getJarFile(),
|
||||
"a/");
|
||||
assertThat(actual, equalTo("B"));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user