Polish contribution

Closes gh-6367
This commit is contained in:
Stephane Nicoll
2016-10-05 13:35:10 +02:00
parent d07f689446
commit 2d75cc79c0
9 changed files with 31 additions and 45 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
package org.springframework.boot.cli.command.archive;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -93,7 +94,7 @@ abstract class ArchiveCommand extends OptionParsingCommand {
private final String type;
protected final Layout layout;
private final Layout layout;
private OptionSpec<String> includeOption;
@@ -104,6 +105,10 @@ abstract class ArchiveCommand extends OptionParsingCommand {
this.layout = layout;
}
protected Layout getLayout() {
return this.layout;
}
@Override
protected void doOptions() {
this.includeOption = option("include",
@@ -284,8 +289,11 @@ abstract class ArchiveCommand extends OptionParsingCommand {
return libraries;
}
protected abstract void writeClasspathEntry(JarWriter writer,
MatchedResource entry) throws IOException;
protected void writeClasspathEntry(JarWriter writer,
MatchedResource entry) throws IOException {
writer.writeEntry(entry.getName(),
new FileInputStream(entry.getFile()));
}
protected abstract LibraryScope getLibraryScope(File file);

View File

@@ -17,11 +17,8 @@
package org.springframework.boot.cli.command.archive;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.springframework.boot.cli.command.Command;
import org.springframework.boot.loader.tools.JarWriter;
import org.springframework.boot.loader.tools.Layouts;
import org.springframework.boot.loader.tools.LibraryScope;
@@ -30,7 +27,6 @@ import org.springframework.boot.loader.tools.LibraryScope;
*
* @author Andy Wilkinson
* @author Phillip Webb
* @author Henri Kerola
*/
public class JarCommand extends ArchiveCommand {
@@ -50,13 +46,6 @@ public class JarCommand extends ArchiveCommand {
return LibraryScope.COMPILE;
}
@Override
protected void writeClasspathEntry(JarWriter writer,
ResourceMatcher.MatchedResource entry) throws IOException {
writer.writeEntry(entry.getName(),
new FileInputStream(entry.getFile()));
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,9 +66,10 @@ public class WarCommand extends ArchiveCommand {
@Override
protected void writeClasspathEntry(JarWriter writer,
ResourceMatcher.MatchedResource entry) throws IOException {
writer.writeEntry(this.layout.getClassesLocation() + entry.getName(),
writer.writeEntry(getLayout().getClassesLocation() + entry.getName(),
new FileInputStream(entry.getFile()));
}
}
}