Reformat code use Eclipse Mars
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) {
|
||||
|
||||
@@ -142,8 +142,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")) {
|
||||
@@ -267,8 +267,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();
|
||||
|
||||
@@ -116,6 +116,7 @@ public 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/");
|
||||
|
||||
@@ -113,7 +113,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>();
|
||||
@@ -230,7 +231,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>();
|
||||
|
||||
@@ -120,8 +120,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);
|
||||
}
|
||||
@@ -146,8 +146,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();
|
||||
@@ -196,12 +196,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);
|
||||
}
|
||||
@@ -248,8 +248,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");
|
||||
}
|
||||
@@ -270,8 +270,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 + "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,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;
|
||||
|
||||
@@ -125,8 +125,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"));
|
||||
|
||||
}
|
||||
|
||||
@@ -288,8 +288,8 @@ public class RepackagerTests {
|
||||
@Override
|
||||
public void doWithLibraries(LibraryCallback callback) throws IOException {
|
||||
callback.library(new Library(libJarFile, LibraryScope.COMPILE));
|
||||
callback.library(new Library(libJarFileToUnpack, LibraryScope.COMPILE,
|
||||
true));
|
||||
callback.library(
|
||||
new Library(libJarFileToUnpack, LibraryScope.COMPILE, true));
|
||||
callback.library(new Library(libNonJarFile, LibraryScope.COMPILE));
|
||||
}
|
||||
});
|
||||
@@ -351,9 +351,8 @@ public class RepackagerTests {
|
||||
Repackager repackager = new Repackager(file);
|
||||
repackager.repackage(NO_LIBRARIES);
|
||||
Manifest actualManifest = getManifest(file);
|
||||
assertThat(
|
||||
actualManifest.getMainAttributes().containsKey(
|
||||
new Attributes.Name("Spring-Boot-Version")), equalTo(true));
|
||||
assertThat(actualManifest.getMainAttributes()
|
||||
.containsKey(new Attributes.Name("Spring-Boot-Version")), equalTo(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -394,7 +393,8 @@ public class RepackagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unpackLibrariesTakePrecedenceOverExistingSourceEntries() throws Exception {
|
||||
public void unpackLibrariesTakePrecedenceOverExistingSourceEntries()
|
||||
throws Exception {
|
||||
TestJarFile nested = new TestJarFile(this.temporaryFolder);
|
||||
nested.addClass("a/b/C.class", ClassWithoutMainMethod.class);
|
||||
final File nestedFile = nested.getFile();
|
||||
|
||||
Reference in New Issue
Block a user