Reformat code using Eclipse Mars

This commit is contained in:
Phillip Webb
2015-10-07 23:37:10 -07:00
parent e473364e4e
commit c9fb9916b8
408 changed files with 2831 additions and 2652 deletions

View File

@@ -64,15 +64,15 @@ public class FindMainClass extends Task {
"one of @mainClass or @classesRoot must be specified");
}
if (!this.classesRoot.exists()) {
throw new BuildException("@classesRoot " + this.classesRoot
+ " does not exist");
throw new BuildException(
"@classesRoot " + this.classesRoot + " does not exist");
}
try {
if (this.classesRoot.isDirectory()) {
return MainClassFinder.findSingleMainClass(this.classesRoot);
}
return MainClassFinder
.findSingleMainClass(new JarFile(this.classesRoot), "/");
return MainClassFinder.findSingleMainClass(new JarFile(this.classesRoot),
"/");
}
catch (IOException ex) {
throw new BuildException(ex);

View File

@@ -83,8 +83,8 @@ public class ConfigurationMetadataProperty implements Serializable {
* For consistency, the type of a primitive is specified using its wrapper
* counterpart, i.e. {@code boolean} becomes {@code java.lang.Boolean}. If the type
* holds generic information, these are provided as well, i.e. a {@code HashMap} of
* String to Integer would be defined as
* {@code java.util.HashMap<java.lang.String,java.lang.Integer>}.
* String to Integer would be defined as {@code java.util.HashMap
* <java.lang.String,java.lang.Integer>}.
* <p>
* Note that this class may be a complex type that gets converted from a String as
* values are bound.

View File

@@ -105,16 +105,17 @@ public final class ConfigurationMetadataRepositoryJsonBuilder {
return create(metadata);
}
catch (IOException ex) {
throw new IllegalArgumentException("Failed to read configuration "
+ "metadata", ex);
throw new IllegalArgumentException(
"Failed to read configuration " + "metadata", ex);
}
catch (JSONException ex) {
throw new IllegalArgumentException("Invalid configuration "
+ "metadata document", ex);
throw new IllegalArgumentException(
"Invalid configuration " + "metadata document", ex);
}
}
private SimpleConfigurationMetadataRepository create(RawConfigurationMetadata metadata) {
private SimpleConfigurationMetadataRepository create(
RawConfigurationMetadata metadata) {
SimpleConfigurationMetadataRepository repository = new SimpleConfigurationMetadataRepository();
repository.add(metadata.getSources());
for (ConfigurationMetadataItem item : metadata.getItems()) {
@@ -170,7 +171,8 @@ public final class ConfigurationMetadataRepositoryJsonBuilder {
* @param defaultCharset the default charset to use
* @return a new {@link ConfigurationMetadataRepositoryJsonBuilder} instance.
*/
public static ConfigurationMetadataRepositoryJsonBuilder create(Charset defaultCharset) {
public static ConfigurationMetadataRepositoryJsonBuilder create(
Charset defaultCharset) {
return new ConfigurationMetadataRepositoryJsonBuilder(defaultCharset);
}

View File

@@ -36,8 +36,8 @@ class DescriptionExtractor {
if (dot != -1) {
BreakIterator breakIterator = BreakIterator.getSentenceInstance(Locale.US);
breakIterator.setText(description);
String text = description.substring(breakIterator.first(),
breakIterator.next()).trim();
String text = description
.substring(breakIterator.first(), breakIterator.next()).trim();
return removeSpaceBetweenLine(text);
}
else {

View File

@@ -93,8 +93,8 @@ class JsonReader {
source.setType(json.optString("type", null));
String description = json.optString("description", null);
source.setDescription(description);
source.setShortDescription(this.descriptionExtractor
.getShortDescription(description));
source.setShortDescription(
this.descriptionExtractor.getShortDescription(description));
source.setSourceType(json.optString("sourceType", null));
source.setSourceMethod(json.optString("sourceMethod", null));
return source;
@@ -106,8 +106,8 @@ class JsonReader {
item.setType(json.optString("type", null));
String description = json.optString("description", null);
item.setDescription(description);
item.setShortDescription(this.descriptionExtractor
.getShortDescription(description));
item.setShortDescription(
this.descriptionExtractor.getShortDescription(description));
item.setDefaultValue(readItemValue(json.opt("defaultValue")));
item.setDeprecation(parseDeprecation(json));
item.setSourceType(json.optString("sourceType", null));
@@ -126,8 +126,8 @@ class JsonReader {
valueHint.setValue(readItemValue(value.get("value")));
String description = value.optString("description", null);
valueHint.setDescription(description);
valueHint.setShortDescription(this.descriptionExtractor
.getShortDescription(description));
valueHint.setShortDescription(
this.descriptionExtractor.getShortDescription(description));
hint.getValueHints().add(valueHint);
}
}
@@ -157,8 +157,8 @@ class JsonReader {
JSONObject deprecationJsonObject = object.getJSONObject("deprecation");
Deprecation deprecation = new Deprecation();
deprecation.setReason(deprecationJsonObject.optString("reason", null));
deprecation.setReplacement(deprecationJsonObject.optString("replacement",
null));
deprecation
.setReplacement(deprecationJsonObject.optString("replacement", null));
return deprecation;
}
return (object.optBoolean("deprecated") ? new Deprecation() : null);

View File

@@ -34,7 +34,8 @@ class RawConfigurationMetadata {
private final List<ConfigurationMetadataHint> hints;
RawConfigurationMetadata(List<ConfigurationMetadataSource> sources,
List<ConfigurationMetadataItem> items, List<ConfigurationMetadataHint> hints) {
List<ConfigurationMetadataItem> items,
List<ConfigurationMetadataHint> hints) {
this.sources = new ArrayList<ConfigurationMetadataSource>(sources);
this.items = new ArrayList<ConfigurationMetadataItem>(items);
this.hints = new ArrayList<ConfigurationMetadataHint>(hints);

View File

@@ -29,8 +29,8 @@ import java.util.Map;
* @since 1.3.0
*/
@SuppressWarnings("serial")
public class SimpleConfigurationMetadataRepository implements
ConfigurationMetadataRepository, Serializable {
public class SimpleConfigurationMetadataRepository
implements ConfigurationMetadataRepository, Serializable {
private final Map<String, ConfigurationMetadataGroup> allGroups = new HashMap<String, ConfigurationMetadataGroup>();

View File

@@ -74,7 +74,7 @@ public class ValueHint implements Serializable {
@Override
public String toString() {
return "ValueHint{" + "value=" + this.value + ", description='"
+ this.description + '\'' + '}';
return "ValueHint{" + "value=" + this.value + ", description='" + this.description
+ '\'' + '}';
}
}

View File

@@ -59,8 +59,8 @@ public class ValueProvider implements Serializable {
@Override
public String toString() {
return "ValueProvider{" + "name='" + this.name + ", parameters="
+ this.parameters + '}';
return "ValueProvider{" + "name='" + this.name + ", parameters=" + this.parameters
+ '}';
}
}

View File

@@ -61,8 +61,8 @@ public abstract class AbstractConfigurationMetadataTests {
}
protected InputStream getInputStreamFor(String name) throws IOException {
Resource r = new ClassPathResource("metadata/configuration-metadata-" + name
+ ".json");
Resource r = new ClassPathResource(
"metadata/configuration-metadata-" + name + ".json");
return r.getInputStream();
}

View File

@@ -31,8 +31,8 @@ import static org.junit.Assert.assertTrue;
*
* @author Stephane Nicoll
*/
public class ConfigurationMetadataRepositoryJsonBuilderTests extends
AbstractConfigurationMetadataTests {
public class ConfigurationMetadataRepositoryJsonBuilderTests
extends AbstractConfigurationMetadataTests {
@Test
public void nullResource() throws IOException {
@@ -48,8 +48,8 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends
.create(foo).build();
validateFoo(repo);
assertEquals(1, repo.getAllGroups().size());
contains(repo.getAllProperties(), "spring.foo.name",
"spring.foo.description", "spring.foo.counter");
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description",
"spring.foo.counter");
assertEquals(3, repo.getAllProperties().size());
}
finally {
@@ -67,9 +67,9 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends
validateFoo(repo);
validateBar(repo);
assertEquals(2, repo.getAllGroups().size());
contains(repo.getAllProperties(), "spring.foo.name",
"spring.foo.description", "spring.foo.counter", "spring.bar.name",
"spring.bar.description", "spring.bar.counter");
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description",
"spring.foo.counter", "spring.bar.name", "spring.bar.description",
"spring.bar.counter");
assertEquals(6, repo.getAllProperties().size());
}
finally {
@@ -88,9 +88,8 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends
validateFoo(repo);
assertEquals(2, repo.getAllGroups().size());
contains(repo.getAllProperties(), "spring.foo.name",
"spring.foo.description", "spring.foo.counter", "spring.root.name",
"spring.root2.name");
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description",
"spring.foo.counter", "spring.root.name", "spring.root2.name");
assertEquals(5, repo.getAllProperties().size());
}
finally {
@@ -114,9 +113,8 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends
contains(group.getProperties(), "spring.foo.name", "spring.foo.description",
"spring.foo.counter", "spring.foo.enabled", "spring.foo.type");
assertEquals(5, group.getProperties().size());
contains(repo.getAllProperties(), "spring.foo.name",
"spring.foo.description", "spring.foo.counter", "spring.foo.enabled",
"spring.foo.type");
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description",
"spring.foo.counter", "spring.foo.enabled", "spring.foo.type");
assertEquals(5, repo.getAllProperties().size());
}
finally {
@@ -159,12 +157,13 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends
ConfigurationMetadataSource source = group.getSources().get("org.acme.Foo");
contains(source.getProperties(), "spring.foo.name", "spring.foo.description");
assertEquals(2, source.getProperties().size());
ConfigurationMetadataSource source2 = group.getSources().get(
"org.springframework.boot.FooProperties");
ConfigurationMetadataSource source2 = group.getSources()
.get("org.springframework.boot.FooProperties");
contains(source2.getProperties(), "spring.foo.name", "spring.foo.counter");
assertEquals(2, source2.getProperties().size());
validatePropertyHints(repo.getAllProperties().get("spring.foo.name"), 0, 0);
validatePropertyHints(repo.getAllProperties().get("spring.foo.description"), 0, 0);
validatePropertyHints(repo.getAllProperties().get("spring.foo.description"), 0,
0);
validatePropertyHints(repo.getAllProperties().get("spring.foo.counter"), 1, 1);
}
@@ -175,12 +174,13 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends
ConfigurationMetadataSource source = group.getSources().get("org.acme.Bar");
contains(source.getProperties(), "spring.bar.name", "spring.bar.description");
assertEquals(2, source.getProperties().size());
ConfigurationMetadataSource source2 = group.getSources().get(
"org.springframework.boot.BarProperties");
ConfigurationMetadataSource source2 = group.getSources()
.get("org.springframework.boot.BarProperties");
contains(source2.getProperties(), "spring.bar.name", "spring.bar.counter");
assertEquals(2, source2.getProperties().size());
validatePropertyHints(repo.getAllProperties().get("spring.bar.name"), 0, 0);
validatePropertyHints(repo.getAllProperties().get("spring.bar.description"), 2, 2);
validatePropertyHints(repo.getAllProperties().get("spring.bar.description"), 2,
2);
validatePropertyHints(repo.getAllProperties().get("spring.bar.counter"), 0, 0);
}

View File

@@ -33,22 +33,22 @@ public class DescriptionExtractorTests {
@Test
public void extractShortDescription() {
String description = this.extractor.getShortDescription("My short "
+ "description. More stuff.");
String description = this.extractor
.getShortDescription("My short " + "description. More stuff.");
assertEquals("My short description.", description);
}
@Test
public void extractShortDescriptionNewLineBeforeDot() {
String description = this.extractor.getShortDescription("My short" + NEW_LINE
+ "description." + NEW_LINE + "More stuff.");
String description = this.extractor.getShortDescription(
"My short" + NEW_LINE + "description." + NEW_LINE + "More stuff.");
assertEquals("My short description.", description);
}
@Test
public void extractShortDescriptionNewLineBeforeDotWithSpaces() {
String description = this.extractor.getShortDescription("My short " + NEW_LINE
+ " description. " + NEW_LINE + "More stuff.");
String description = this.extractor.getShortDescription(
"My short " + NEW_LINE + " description. " + NEW_LINE + "More stuff.");
assertEquals("My short description.", description);
}
@@ -60,8 +60,8 @@ public class DescriptionExtractorTests {
@Test
public void extractShortDescriptionNoDotMultipleLines() {
String description = this.extractor.getShortDescription("My short description "
+ NEW_LINE + " More stuff");
String description = this.extractor
.getShortDescription("My short description " + NEW_LINE + " More stuff");
assertEquals("My short description", description);
}

View File

@@ -92,7 +92,8 @@ public class JsonReaderTests extends AbstractConfigurationMetadataTests {
ValueProvider valueProvider = hint.getValueProviders().get(0);
assertEquals("handle-as", valueProvider.getName());
assertEquals(1, valueProvider.getParameters().size());
assertEquals(Integer.class.getName(), valueProvider.getParameters().get("target"));
assertEquals(Integer.class.getName(),
valueProvider.getParameters().get("target"));
}
@Test
@@ -141,8 +142,8 @@ public class JsonReaderTests extends AbstractConfigurationMetadataTests {
ConfigurationMetadataItem item = items.get(0);
assertProperty(item, "server.port", "server.port", Integer.class, null);
assertTrue(item.isDeprecated());
assertEquals("Server namespace has moved to spring.server", item.getDeprecation()
.getReason());
assertEquals("Server namespace has moved to spring.server",
item.getDeprecation().getReason());
assertEquals("server.spring.port", item.getDeprecation().getReplacement());
ConfigurationMetadataItem item2 = items.get(1);

View File

@@ -169,13 +169,13 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
private void processExecutableElement(String prefix, ExecutableElement element) {
if (element.getModifiers().contains(Modifier.PUBLIC)
&& (TypeKind.VOID != element.getReturnType().getKind())) {
Element returns = this.processingEnv.getTypeUtils().asElement(
element.getReturnType());
Element returns = this.processingEnv.getTypeUtils()
.asElement(element.getReturnType());
if (returns instanceof TypeElement) {
this.metadataCollector.add(ItemMetadata.newGroup(prefix,
this.typeUtils.getType(returns),
this.typeUtils.getType(element.getEnclosingElement()),
element.toString()));
this.metadataCollector.add(
ItemMetadata.newGroup(prefix, this.typeUtils.getType(returns),
this.typeUtils.getType(element.getEnclosingElement()),
element.toString()));
processTypeElement(prefix, (TypeElement) returns);
}
}
@@ -207,8 +207,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
ExecutableElement setter = members.getPublicSetters().get(name);
VariableElement field = members.getFields().get(name);
TypeMirror returnType = getter.getReturnType();
Element returnTypeElement = this.processingEnv.getTypeUtils().asElement(
returnType);
Element returnTypeElement = this.processingEnv.getTypeUtils()
.asElement(returnType);
boolean isExcluded = this.typeExcludeFilter.isExcluded(returnType);
boolean isNested = isNested(returnTypeElement, field, element);
boolean isCollection = this.typeUtils.isCollectionOrMap(returnType);
@@ -249,8 +249,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
continue;
}
TypeMirror returnType = field.asType();
Element returnTypeElement = this.processingEnv.getTypeUtils().asElement(
returnType);
Element returnTypeElement = this.processingEnv.getTypeUtils()
.asElement(returnType);
boolean isExcluded = this.typeExcludeFilter.isExcluded(returnType);
boolean isNested = isNested(returnTypeElement, field, element);
boolean isCollection = this.typeUtils.isCollectionOrMap(returnType);
@@ -277,8 +277,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
private boolean hasLombokSetter(VariableElement field, TypeElement element) {
return !field.getModifiers().contains(Modifier.FINAL)
&& (hasAnnotation(field, LOMBOK_SETTER_ANNOTATION)
|| hasAnnotation(element, LOMBOK_SETTER_ANNOTATION) || hasAnnotation(
element, LOMBOK_DATA_ANNOTATION));
|| hasAnnotation(element, LOMBOK_SETTER_ANNOTATION)
|| hasAnnotation(element, LOMBOK_DATA_ANNOTATION));
}
private void processNestedTypes(String prefix, TypeElement element,
@@ -288,8 +288,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
String name = entry.getKey();
ExecutableElement getter = entry.getValue();
VariableElement field = members.getFields().get(name);
Element returnType = this.processingEnv.getTypeUtils().asElement(
getter.getReturnType());
Element returnType = this.processingEnv.getTypeUtils()
.asElement(getter.getReturnType());
AnnotationMirror annotation = getAnnotation(getter,
configurationPropertiesAnnotation());
boolean isNested = isNested(returnType, field, element);
@@ -350,8 +350,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
Map<String, Object> values = new LinkedHashMap<String, Object>();
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotation
.getElementValues().entrySet()) {
values.put(entry.getKey().getSimpleName().toString(), entry.getValue()
.getValue());
values.put(entry.getKey().getSimpleName().toString(),
entry.getValue().getValue());
}
return values;
}
@@ -371,7 +371,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
return null;
}
private ConfigurationMetadata mergeAdditionalMetadata(ConfigurationMetadata metadata) {
private ConfigurationMetadata mergeAdditionalMetadata(
ConfigurationMetadata metadata) {
try {
ConfigurationMetadata merged = new ConfigurationMetadata(metadata);
merged.merge(this.metadataStore.readAdditionalMetadata());

View File

@@ -89,7 +89,8 @@ public class MetadataStore {
catch (JSONException ex) {
throw new InvalidConfigurationMetadataException(
"Invalid additional meta-data in '" + METADATA_PATH + "': "
+ ex.getMessage(), Diagnostic.Kind.ERROR);
+ ex.getMessage(),
Diagnostic.Kind.ERROR);
}
finally {
in.close();

View File

@@ -31,14 +31,17 @@ class ExpressionTree extends ReflectionWrapper {
private final Class<?> literalTreeType = findClass("com.sun.source.tree.LiteralTree");
private final Method literalValueMethod = findMethod(this.literalTreeType, "getValue");
private final Method literalValueMethod = findMethod(this.literalTreeType,
"getValue");
private final Class<?> methodInvocationTreeType = findClass("com.sun.source.tree.MethodInvocationTree");
private final Class<?> methodInvocationTreeType = findClass(
"com.sun.source.tree.MethodInvocationTree");
private final Method methodInvocationArgumentsMethod = findMethod(
this.methodInvocationTreeType, "getArguments");
private final Class<?> newArrayTreeType = findClass("com.sun.source.tree.NewArrayTree");
private final Class<?> newArrayTreeType = findClass(
"com.sun.source.tree.NewArrayTree");
private final Method arrayValueMethod = findMethod(this.newArrayTreeType,
"getInitializers");

View File

@@ -179,7 +179,8 @@ public class ConfigurationMetadata {
return first + "-" + second;
}
private static <T extends Comparable<T>> List<T> flattenValues(MultiValueMap<?, T> map) {
private static <T extends Comparable<T>> List<T> flattenValues(
MultiValueMap<?, T> map) {
List<T> content = new ArrayList<T>();
for (List<T> values : map.values()) {
content.addAll(values);

View File

@@ -221,8 +221,8 @@ public class JsonMarshaller {
JSONObject deprecationJsonObject = object.getJSONObject("deprecation");
ItemDeprecation deprecation = new ItemDeprecation();
deprecation.setReason(deprecationJsonObject.optString("reason", null));
deprecation.setReplacement(deprecationJsonObject.optString("replacement",
null));
deprecation
.setReplacement(deprecationJsonObject.optString("replacement", null));
return deprecation;
}
return (object.optBoolean("deprecated") ? new ItemDeprecation() : null);

View File

@@ -103,14 +103,12 @@ public class ConfigurationMetadataAnnotationProcessorTests {
public void simpleProperties() throws Exception {
ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(metadata, containsGroup("simple").fromSource(SimpleProperties.class));
assertThat(
metadata,
assertThat(metadata,
containsProperty("simple.the-name", String.class)
.fromSource(SimpleProperties.class)
.withDescription("The name of this simple properties.")
.withDefaultValue(is("boot")).withDeprecation(null, null));
assertThat(
metadata,
assertThat(metadata,
containsProperty("simple.flag", Boolean.class)
.fromSource(SimpleProperties.class)
.withDescription("A simple flag.").withDeprecation(null, null));
@@ -124,10 +122,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
ConfigurationMetadata metadata = compile(SimplePrefixValueProperties.class);
assertThat(metadata,
containsGroup("simple").fromSource(SimplePrefixValueProperties.class));
assertThat(
metadata,
containsProperty("simple.name", String.class).fromSource(
SimplePrefixValueProperties.class));
assertThat(metadata, containsProperty("simple.name", String.class)
.fromSource(SimplePrefixValueProperties.class));
}
@Test
@@ -195,77 +191,57 @@ public class ConfigurationMetadataAnnotationProcessorTests {
assertThat(metadata, containsGroup("singledeprecated").fromSource(type));
assertThat(metadata, containsProperty("singledeprecated.new-name", String.class)
.fromSource(type));
assertThat(metadata, containsProperty("singledeprecated.name", String.class)
.fromSource(type).withDeprecation("renamed", "singledeprecated.new-name"));
assertThat(metadata,
containsProperty("singledeprecated.name", String.class).fromSource(type)
.withDeprecation("renamed", "singledeprecated.new-name"));
}
@Test
public void parseCollectionConfig() throws Exception {
ConfigurationMetadata metadata = compile(SimpleCollectionProperties.class);
// getter and setter
assertThat(
metadata,
containsProperty("collection.integers-to-names",
"java.util.Map<java.lang.Integer,java.lang.String>"));
assertThat(
metadata,
containsProperty("collection.longs",
"java.util.Collection<java.lang.Long>"));
assertThat(metadata, containsProperty("collection.integers-to-names",
"java.util.Map<java.lang.Integer,java.lang.String>"));
assertThat(metadata, containsProperty("collection.longs",
"java.util.Collection<java.lang.Long>"));
assertThat(metadata,
containsProperty("collection.floats", "java.util.List<java.lang.Float>"));
// getter only
assertThat(
metadata,
containsProperty("collection.names-to-integers",
"java.util.Map<java.lang.String,java.lang.Integer>"));
assertThat(
metadata,
containsProperty("collection.bytes",
"java.util.Collection<java.lang.Byte>"));
assertThat(
metadata,
containsProperty("collection.doubles", "java.util.List<java.lang.Double>"));
assertThat(metadata, containsProperty("collection.names-to-integers",
"java.util.Map<java.lang.String,java.lang.Integer>"));
assertThat(metadata, containsProperty("collection.bytes",
"java.util.Collection<java.lang.Byte>"));
assertThat(metadata, containsProperty("collection.doubles",
"java.util.List<java.lang.Double>"));
}
@Test
public void simpleMethodConfig() throws Exception {
ConfigurationMetadata metadata = compile(SimpleMethodConfig.class);
assertThat(metadata, containsGroup("foo").fromSource(SimpleMethodConfig.class));
assertThat(
metadata,
containsProperty("foo.name", String.class).fromSource(
SimpleMethodConfig.Foo.class));
assertThat(
metadata,
containsProperty("foo.flag", Boolean.class).fromSource(
SimpleMethodConfig.Foo.class));
assertThat(metadata, containsProperty("foo.name", String.class)
.fromSource(SimpleMethodConfig.Foo.class));
assertThat(metadata, containsProperty("foo.flag", Boolean.class)
.fromSource(SimpleMethodConfig.Foo.class));
}
@Test
public void invalidMethodConfig() throws Exception {
ConfigurationMetadata metadata = compile(InvalidMethodConfig.class);
assertThat(
metadata,
containsProperty("something.name", String.class).fromSource(
InvalidMethodConfig.class));
assertThat(metadata, containsProperty("something.name", String.class)
.fromSource(InvalidMethodConfig.class));
assertThat(metadata, not(containsProperty("invalid.name")));
}
@Test
public void methodAndClassConfig() throws Exception {
ConfigurationMetadata metadata = compile(MethodAndClassConfig.class);
assertThat(
metadata,
containsProperty("conflict.name", String.class).fromSource(
MethodAndClassConfig.Foo.class));
assertThat(
metadata,
containsProperty("conflict.flag", Boolean.class).fromSource(
MethodAndClassConfig.Foo.class));
assertThat(
metadata,
containsProperty("conflict.value", String.class).fromSource(
MethodAndClassConfig.class));
assertThat(metadata, containsProperty("conflict.name", String.class)
.fromSource(MethodAndClassConfig.Foo.class));
assertThat(metadata, containsProperty("conflict.flag", Boolean.class)
.fromSource(MethodAndClassConfig.Foo.class));
assertThat(metadata, containsProperty("conflict.value", String.class)
.fromSource(MethodAndClassConfig.class));
}
@Test
@@ -342,7 +318,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
@Test
public void lombokExplicitProperties() throws Exception {
ConfigurationMetadata metadata = compile(LombokExplicitProperties.class);
assertSimpleLombokProperties(metadata, LombokExplicitProperties.class, "explicit");
assertSimpleLombokProperties(metadata, LombokExplicitProperties.class,
"explicit");
}
@Test
@@ -352,9 +329,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
writeAdditionalMetadata(property);
ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(metadata, containsProperty("simple.comparator"));
assertThat(metadata,
containsProperty("foo", String.class)
.fromSource(AdditionalMetadata.class));
assertThat(metadata, containsProperty("foo", String.class)
.fromSource(AdditionalMetadata.class));
}
@Test
@@ -363,8 +339,7 @@ public class ConfigurationMetadataAnnotationProcessorTests {
null, null, true, null);
writeAdditionalMetadata(property);
ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(
metadata,
assertThat(metadata,
containsProperty("simple.flag", Boolean.class)
.fromSource(SimpleProperties.class)
.withDescription("A simple flag.").withDefaultValue(is(true)));
@@ -377,41 +352,38 @@ public class ConfigurationMetadataAnnotationProcessorTests {
null, null, "A nice comparator.", null, null);
writeAdditionalMetadata(property);
ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(
metadata,
assertThat(metadata,
containsProperty("simple.comparator", "java.util.Comparator<?>")
.fromSource(SimpleProperties.class).withDescription(
"A nice comparator."));
.fromSource(SimpleProperties.class)
.withDescription("A nice comparator."));
assertThat(metadata.getItems().size(), is(4));
}
@Test
public void mergeExistingPropertyDeprecation() throws Exception {
ItemMetadata property = ItemMetadata.newProperty("simple", "comparator", null,
null, null, null, null, new ItemDeprecation("Don't use this.",
"simple.complex-comparator"));
null, null, null, null,
new ItemDeprecation("Don't use this.", "simple.complex-comparator"));
writeAdditionalMetadata(property);
ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(
metadata,
assertThat(metadata,
containsProperty("simple.comparator", "java.util.Comparator<?>")
.fromSource(SimpleProperties.class).withDeprecation(
"Don't use this.", "simple.complex-comparator"));
.fromSource(SimpleProperties.class)
.withDeprecation("Don't use this.", "simple.complex-comparator"));
assertThat(metadata.getItems().size(), is(4));
}
@Test
public void mergeExistingPropertyDeprecationOverride() throws Exception {
ItemMetadata property = ItemMetadata.newProperty("singledeprecated", "name",
null, null, null, null, null, new ItemDeprecation("Don't use this.",
"single.name"));
ItemMetadata property = ItemMetadata.newProperty("singledeprecated", "name", null,
null, null, null, null,
new ItemDeprecation("Don't use this.", "single.name"));
writeAdditionalMetadata(property);
ConfigurationMetadata metadata = compile(DeprecatedSingleProperty.class);
assertThat(
metadata,
assertThat(metadata,
containsProperty("singledeprecated.name", String.class.getName())
.fromSource(DeprecatedSingleProperty.class).withDeprecation(
"Don't use this.", "single.name"));
.fromSource(DeprecatedSingleProperty.class)
.withDeprecation("Don't use this.", "single.name"));
assertThat(metadata.getItems().size(), is(3));
}
@@ -427,27 +399,25 @@ public class ConfigurationMetadataAnnotationProcessorTests {
@Test
public void mergingOfSimpleHint() throws Exception {
writeAdditionalHints(ItemHint.newHint("simple.the-name", new ItemHint.ValueHint(
"boot", "Bla bla"), new ItemHint.ValueHint("spring", null)));
writeAdditionalHints(ItemHint.newHint("simple.the-name",
new ItemHint.ValueHint("boot", "Bla bla"),
new ItemHint.ValueHint("spring", null)));
ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(
metadata,
assertThat(metadata,
containsProperty("simple.the-name", String.class)
.fromSource(SimpleProperties.class)
.withDescription("The name of this simple properties.")
.withDefaultValue(is("boot")).withDeprecation(null, null));
assertThat(metadata,
containsHint("simple.the-name").withValue(0, "boot", "Bla bla")
.withValue(1, "spring", null));
assertThat(metadata, containsHint("simple.the-name")
.withValue(0, "boot", "Bla bla").withValue(1, "spring", null));
}
@Test
public void mergingOfHintWithNonCanonicalName() throws Exception {
writeAdditionalHints(ItemHint.newHint("simple.theName", new ItemHint.ValueHint(
"boot", "Bla bla")));
writeAdditionalHints(ItemHint.newHint("simple.theName",
new ItemHint.ValueHint("boot", "Bla bla")));
ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(
metadata,
assertThat(metadata,
containsProperty("simple.the-name", String.class)
.fromSource(SimpleProperties.class)
.withDescription("The name of this simple properties.")
@@ -459,28 +429,27 @@ public class ConfigurationMetadataAnnotationProcessorTests {
@Test
public void mergingOfHintWithProvider() throws Exception {
writeAdditionalHints(new ItemHint("simple.theName",
Collections.<ItemHint.ValueHint>emptyList(), Arrays.asList(
new ItemHint.ValueProvider("first", Collections
.<String, Object>singletonMap("target", "org.foo")),
Collections.<ItemHint.ValueHint>emptyList(),
Arrays.asList(
new ItemHint.ValueProvider("first",
Collections.<String, Object>singletonMap("target",
"org.foo")),
new ItemHint.ValueProvider("second", null))));
ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(
metadata,
assertThat(metadata,
containsProperty("simple.the-name", String.class)
.fromSource(SimpleProperties.class)
.withDescription("The name of this simple properties.")
.withDefaultValue(is("boot")).withDeprecation(null, null));
assertThat(metadata,
containsHint("simple.the-name")
.withProvider("first", "target", "org.foo")
.withProvider("second"));
assertThat(metadata, containsHint("simple.the-name")
.withProvider("first", "target", "org.foo").withProvider("second"));
}
@Test
public void mergingOfAdditionalDeprecation() throws Exception {
writePropertyDeprecation(ItemMetadata.newProperty("simple", "wrongName",
"java.lang.String", null, null, null, null, new ItemDeprecation(
"Lame name.", "simple.the-name")));
"java.lang.String", null, null, null, null,
new ItemDeprecation("Lame name.", "simple.the-name")));
ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(metadata, containsProperty("simple.wrong-name", String.class)
.withDeprecation("Lame name.", "simple.the-name"));
@@ -545,9 +514,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
containsProperty("foo.counter").fromSource(FooProperties.class));
assertThat(metadata,
containsProperty("bar.counter").fromSource(BarProperties.class));
assertThat(metadata,
not(containsProperty("bar.counter")
.fromSource(RenamedBarProperties.class)));
assertThat(metadata, not(
containsProperty("bar.counter").fromSource(RenamedBarProperties.class)));
project.delete(BarProperties.class);
project.add(RenamedBarProperties.class);
@@ -564,9 +532,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
Class<?> source, String prefix) {
assertThat(metadata, containsGroup(prefix).fromSource(source));
assertThat(metadata, not(containsProperty(prefix + ".id")));
assertThat(metadata,
containsProperty(prefix + ".name", String.class).fromSource(source)
.withDescription("Name description."));
assertThat(metadata, containsProperty(prefix + ".name", String.class)
.fromSource(source).withDescription("Name description."));
assertThat(metadata, containsProperty(prefix + ".description"));
assertThat(metadata, containsProperty(prefix + ".counter"));
assertThat(metadata, containsProperty(prefix + ".number").fromSource(source)
@@ -634,7 +601,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
return additionalMetadataFile;
}
private void writeMetadata(File metadataFile, JSONObject metadata) throws IOException {
private void writeMetadata(File metadataFile, JSONObject metadata)
throws IOException {
FileWriter writer = new FileWriter(metadataFile);
try {
metadata.write(writer);

View File

@@ -136,12 +136,12 @@ public final class ConfigurationMetadataMatchers {
ConfigurationMetadata metadata = (ConfigurationMetadata) item;
ItemMetadata property = getFirstItemWithName(metadata, this.name);
if (property == null) {
description.appendText("missing "
+ this.itemType.toString().toLowerCase() + " " + this.name);
description.appendText("missing " + this.itemType.toString().toLowerCase()
+ " " + this.name);
}
else {
description.appendText(
"was " + this.itemType.toString().toLowerCase() + " ")
description
.appendText("was " + this.itemType.toString().toLowerCase() + " ")
.appendValue(property);
}
}
@@ -274,7 +274,8 @@ public final class ConfigurationMetadataMatchers {
}
}
public ContainsHintMatcher withValue(int index, Object value, String description) {
public ContainsHintMatcher withValue(int index, Object value,
String description) {
List<ValueHintMatcher> values = new ArrayList<ValueHintMatcher>(this.values);
values.add(new ValueHintMatcher(index, value, description));
return new ContainsHintMatcher(this.name, values, this.providers);
@@ -288,7 +289,8 @@ public final class ConfigurationMetadataMatchers {
return new ContainsHintMatcher(this.name, this.values, providers);
}
public ContainsHintMatcher withProvider(String provider, String key, Object value) {
public ContainsHintMatcher withProvider(String provider, String key,
Object value) {
return withProvider(this.providers.size(), provider,
Collections.singletonMap(key, value));
}
@@ -297,7 +299,8 @@ public final class ConfigurationMetadataMatchers {
return withProvider(this.providers.size(), provider, null);
}
private ItemHint getFirstHintWithName(ConfigurationMetadata metadata, String name) {
private ItemHint getFirstHintWithName(ConfigurationMetadata metadata,
String name) {
for (ItemHint hint : metadata.getHints()) {
if (name.equals(hint.getName())) {
return hint;
@@ -357,7 +360,8 @@ public final class ConfigurationMetadataMatchers {
private final String name;
private final Map<String, Object> parameters;
public ValueProviderMatcher(int index, String name, Map<String, Object> parameters) {
public ValueProviderMatcher(int index, String name,
Map<String, Object> parameters) {
this.index = index;
this.name = name;
this.parameters = parameters;

View File

@@ -45,12 +45,12 @@ public class JsonMarshallerTests {
metadata.add(ItemMetadata.newProperty("a", "b", StringBuffer.class.getName(),
InputStream.class.getName(), "sourceMethod", "desc", "x",
new ItemDeprecation("Deprecation comment", "b.c.d")));
metadata.add(ItemMetadata.newProperty("b.c.d", null, null, null, null, null,
null, null));
metadata.add(ItemMetadata.newProperty("c", null, null, null, null, null, 123,
null));
metadata.add(ItemMetadata.newProperty("d", null, null, null, null, null, true,
metadata.add(ItemMetadata.newProperty("b.c.d", null, null, null, null, null, null,
null));
metadata.add(
ItemMetadata.newProperty("c", null, null, null, null, null, 123, null));
metadata.add(
ItemMetadata.newProperty("d", null, null, null, null, null, true, null));
metadata.add(ItemMetadata.newProperty("e", null, null, null, null, null,
new String[] { "y", "n" }, null));
metadata.add(ItemMetadata.newProperty("f", null, null, null, null, null,
@@ -59,14 +59,17 @@ public class JsonMarshallerTests {
metadata.add(ItemHint.newHint("a.b"));
metadata.add(ItemHint.newHint("c", new ItemHint.ValueHint(123, "hey"),
new ItemHint.ValueHint(456, null)));
metadata.add(new ItemHint("d", null, Arrays.asList(new ItemHint.ValueProvider(
"first", Collections.<String, Object>singletonMap("target", "foo")),
metadata.add(new ItemHint("d", null,
Arrays.asList(
new ItemHint.ValueProvider("first",
Collections.<String, Object>singletonMap("target",
"foo")),
new ItemHint.ValueProvider("second", null))));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
JsonMarshaller marshaller = new JsonMarshaller();
marshaller.write(metadata, outputStream);
ConfigurationMetadata read = marshaller.read(new ByteArrayInputStream(
outputStream.toByteArray()));
ConfigurationMetadata read = marshaller
.read(new ByteArrayInputStream(outputStream.toByteArray()));
assertThat(read,
containsProperty("a.b", StringBuffer.class).fromSource(InputStream.class)
.withDescription("desc").withDefaultValue(is("x"))
@@ -76,8 +79,8 @@ public class JsonMarshallerTests {
assertThat(read, containsProperty("d").withDefaultValue(is(true)));
assertThat(read,
containsProperty("e").withDefaultValue(is(new String[] { "y", "n" })));
assertThat(read,
containsProperty("f").withDefaultValue(is(new boolean[] { true, false })));
assertThat(read, containsProperty("f")
.withDefaultValue(is(new boolean[] { true, false })));
assertThat(read, containsGroup("d"));
assertThat(read, containsHint("a.b"));
assertThat(read,

View File

@@ -76,8 +76,8 @@ public class JarWriter {
* @throws IOException if the file cannot be opened
* @throws FileNotFoundException if the file cannot be found
*/
public JarWriter(File file, LaunchScript launchScript) throws FileNotFoundException,
IOException {
public JarWriter(File file, LaunchScript launchScript)
throws FileNotFoundException, IOException {
FileOutputStream fileOutputStream = new FileOutputStream(file);
if (launchScript != null) {
fileOutputStream.write(launchScript.toByteArray());

View File

@@ -118,8 +118,8 @@ public class Repackager {
* @throws IOException if the file cannot be repackaged
* @since 1.3.0
*/
public void repackage(File destination, Libraries libraries, LaunchScript launchScript)
throws IOException {
public void repackage(File destination, Libraries libraries,
LaunchScript launchScript) throws IOException {
if (destination == null || destination.isDirectory()) {
throw new IllegalArgumentException("Invalid destination");
}

View File

@@ -55,7 +55,8 @@ public class RunProcess {
return run(waitForProcess, Arrays.asList(args));
}
protected int run(boolean waitForProcess, Collection<String> args) throws IOException {
protected int run(boolean waitForProcess, Collection<String> args)
throws IOException {
ProcessBuilder builder = new ProcessBuilder(this.command);
builder.command().addAll(args);
builder.redirectErrorStream(true);

View File

@@ -62,6 +62,7 @@ public class RepackagerTests {
private static final long JAN_1_1980;
private static final long JAN_1_1985;
static {
Calendar calendar = Calendar.getInstance();
calendar.set(1980, 0, 1, 0, 0, 0);
@@ -303,8 +304,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));
}
});
@@ -368,9 +369,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
@@ -431,7 +431,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();

View File

@@ -325,7 +325,8 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD
* @return a {@link JarFile} for the entry
* @throws IOException if the nested jar file cannot be read
*/
public synchronized JarFile getNestedJarFile(final ZipEntry entry) throws IOException {
public synchronized JarFile getNestedJarFile(final ZipEntry entry)
throws IOException {
return getNestedJarFile(getContainedEntry(entry).getSource());
}

View File

@@ -90,7 +90,8 @@ public class ExecutableArchiveLauncherTests {
assertArrayEquals(urls, ((URLClassLoader) classLoader).getURLs());
}
private void doWithTccl(ClassLoader classLoader, Callable<?> action) throws Exception {
private void doWithTccl(ClassLoader classLoader, Callable<?> action)
throws Exception {
ClassLoader old = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(classLoader);
@@ -101,8 +102,8 @@ public class ExecutableArchiveLauncherTests {
}
}
private static final class UnitTestExecutableArchiveLauncher extends
ExecutableArchiveLauncher {
private static final class UnitTestExecutableArchiveLauncher
extends ExecutableArchiveLauncher {
UnitTestExecutableArchiveLauncher(JavaAgentDetector javaAgentDetector) {
super(javaAgentDetector);

View File

@@ -144,7 +144,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
* @return {@code true} if the application process should be forked
*/
protected boolean isFork() {
return (Boolean.TRUE.equals(this.fork) || (this.fork == null && (hasAgent() || hasJvmArgs())));
return (Boolean.TRUE.equals(this.fork)
|| (this.fork == null && (hasAgent() || hasJvmArgs())));
}
private boolean hasAgent() {
@@ -171,7 +172,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
}
CodeSource source = loaded.getProtectionDomain().getCodeSource();
if (source != null) {
this.agent = new File[] { new File(source.getLocation().getFile()) };
this.agent = new File[] {
new File(source.getLocation().getFile()) };
}
}
}
@@ -184,8 +186,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
}
}
private void run(String startClassName) throws MojoExecutionException,
MojoFailureException {
private void run(String startClassName)
throws MojoExecutionException, MojoFailureException {
findAgent();
if (isFork()) {
doRunWithForkedJvm(startClassName);
@@ -195,16 +197,15 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
getLog().warn("Fork mode disabled, ignoring agent");
}
if (hasJvmArgs()) {
getLog().warn(
"Fork mode disabled, ignoring JVM argument(s) ["
+ this.jvmArguments + "]");
getLog().warn("Fork mode disabled, ignoring JVM argument(s) ["
+ this.jvmArguments + "]");
}
runWithMavenJvm(startClassName, resolveApplicationArguments().asArray());
}
}
private void doRunWithForkedJvm(String startClassName) throws MojoExecutionException,
MojoFailureException {
private void doRunWithForkedJvm(String startClassName)
throws MojoExecutionException, MojoFailureException {
List<String> args = new ArrayList<String>();
addAgents(args);
addJvmArgs(args);
@@ -277,8 +278,9 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
try {
StringBuilder classpath = new StringBuilder();
for (URL ele : getClassPathUrls()) {
classpath = classpath.append((classpath.length() > 0 ? File.pathSeparator
: "") + new File(ele.toURI()));
classpath = classpath
.append((classpath.length() > 0 ? File.pathSeparator : "")
+ new File(ele.toURI()));
}
getLog().debug("Classpath for forked process: " + classpath);
args.add("-cp");
@@ -346,11 +348,12 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
urls.add(this.classesDirectory.toURI().toURL());
}
private void addDependencies(List<URL> urls) throws MalformedURLException,
MojoExecutionException {
private void addDependencies(List<URL> urls)
throws MalformedURLException, MojoExecutionException {
FilterArtifacts filters = this.useTestClasspath ? getFilters()
: getFilters(new TestArtifactFilter());
Set<Artifact> artifacts = filterDependencies(this.project.getArtifacts(), filters);
Set<Artifact> artifacts = filterDependencies(this.project.getArtifacts(),
filters);
for (Artifact artifact : artifacts) {
if (artifact.getFile() != null) {
urls.add(artifact.getFile().toURI().toURL());
@@ -400,7 +403,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
}
}
public synchronized void rethrowUncaughtException() throws MojoExecutionException {
public synchronized void rethrowUncaughtException()
throws MojoExecutionException {
if (this.exception != null) {
throw new MojoExecutionException("An exception occured while running. "
+ this.exception.getMessage(), this.exception);
@@ -437,7 +441,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
catch (NoSuchMethodException ex) {
Exception wrappedEx = new Exception(
"The specified mainClass doesn't contain a "
+ "main method with appropriate signature.", ex);
+ "main method with appropriate signature.",
ex);
thread.getThreadGroup().uncaughtException(thread, wrappedEx);
}
catch (Exception ex) {

View File

@@ -176,10 +176,9 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
finally {
long duration = System.currentTimeMillis() - startTime;
if (duration > FIND_WARNING_TIMEOUT) {
getLog().warn(
"Searching for the main-class is taking some time, "
+ "consider using the mainClass configuration "
+ "parameter");
getLog().warn("Searching for the main-class is taking some time, "
+ "consider using the mainClass configuration "
+ "parameter");
}
}
}
@@ -203,9 +202,8 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
throw new MojoExecutionException(ex.getMessage(), ex);
}
if (this.classifier != null) {
getLog().info(
"Attaching archive: " + target + ", with classifier: "
+ this.classifier);
getLog().info("Attaching archive: " + target + ", with classifier: "
+ this.classifier);
this.projectHelper.attachArtifact(this.project, this.project.getPackaging(),
this.classifier, target);
}

View File

@@ -52,8 +52,8 @@ public class RunMojo extends AbstractRunMojo {
protected void runWithMavenJvm(String startClassName, String... arguments)
throws MojoExecutionException {
IsolatedThreadGroup threadGroup = new IsolatedThreadGroup(startClassName);
Thread launchThread = new Thread(threadGroup, new LaunchRunner(startClassName,
arguments), "main");
Thread launchThread = new Thread(threadGroup,
new LaunchRunner(startClassName, arguments), "main");
launchThread.setContextClassLoader(new URLClassLoader(getClassPathUrls()));
launchThread.start();
join(threadGroup);

View File

@@ -66,8 +66,8 @@ class SpringApplicationAdminClient {
return false; // Instance not available yet
}
catch (AttributeNotFoundException ex) {
throw new IllegalStateException(
"Unexpected: attribute 'Ready' not available", ex);
throw new IllegalStateException("Unexpected: attribute 'Ready' not available",
ex);
}
catch (ReflectionException ex) {
throw new MojoExecutionException("Failed to retrieve Ready attribute",
@@ -87,8 +87,8 @@ class SpringApplicationAdminClient {
* @throws IOException if an I/O error occurs
* @throws InstanceNotFoundException if the lifecycle mbean cannot be found
*/
public void stop() throws MojoExecutionException, IOException,
InstanceNotFoundException {
public void stop()
throws MojoExecutionException, IOException, InstanceNotFoundException {
try {
this.connection.invoke(this.objectName, "shutdown", null, null);
}

View File

@@ -86,8 +86,8 @@ public class StartMojo extends AbstractRunMojo {
private final Object lock = new Object();
@Override
protected void runWithForkedJvm(List<String> args) throws MojoExecutionException,
MojoFailureException {
protected void runWithForkedJvm(List<String> args)
throws MojoExecutionException, MojoFailureException {
RunProcess runProcess = runProcess(args);
try {
waitForSpringApplication();
@@ -118,8 +118,8 @@ public class StartMojo extends AbstractRunMojo {
RunArguments applicationArguments = super.resolveApplicationArguments();
applicationArguments.getArgs().addLast(ENABLE_MBEAN_PROPERTY);
if (isFork()) {
applicationArguments.getArgs().addLast(
JMX_NAME_PROPERTY_PREFIX + this.jmxName);
applicationArguments.getArgs()
.addLast(JMX_NAME_PROPERTY_PREFIX + this.jmxName);
}
return applicationArguments;
}
@@ -142,8 +142,8 @@ public class StartMojo extends AbstractRunMojo {
protected void runWithMavenJvm(String startClassName, String... arguments)
throws MojoExecutionException {
IsolatedThreadGroup threadGroup = new IsolatedThreadGroup(startClassName);
Thread launchThread = new Thread(threadGroup, new LaunchRunner(startClassName,
arguments), startClassName + ".main()");
Thread launchThread = new Thread(threadGroup,
new LaunchRunner(startClassName, arguments), startClassName + ".main()");
launchThread.setContextClassLoader(new URLClassLoader(getClassPathUrls()));
launchThread.start();
waitForSpringApplication(this.wait, this.maxAttempts);
@@ -176,8 +176,8 @@ public class StartMojo extends AbstractRunMojo {
+ (wait * maxAttempts) + "ms");
}
private void waitForSpringApplication() throws MojoFailureException,
MojoExecutionException {
private void waitForSpringApplication()
throws MojoFailureException, MojoExecutionException {
try {
if (Boolean.TRUE.equals(isFork())) {
waitForForkedSpringApplication();
@@ -196,8 +196,8 @@ public class StartMojo extends AbstractRunMojo {
}
}
private void waitForForkedSpringApplication() throws IOException,
MojoFailureException, MojoExecutionException {
private void waitForForkedSpringApplication()
throws IOException, MojoFailureException, MojoExecutionException {
try {
getLog().debug("Connecting to local MBeanServer at port " + this.jmxPort);
JMXConnector connector = execute(this.wait, this.maxAttempts,
@@ -220,8 +220,8 @@ public class StartMojo extends AbstractRunMojo {
throw ex;
}
catch (Exception ex) {
throw new MojoExecutionException("Failed to connect to MBean server at port "
+ this.jmxPort, ex);
throw new MojoExecutionException(
"Failed to connect to MBean server at port " + this.jmxPort, ex);
}
}
@@ -309,8 +309,8 @@ public class StartMojo extends AbstractRunMojo {
}
private boolean hasCauseWithType(Throwable t, Class<? extends Exception> type) {
return type.isAssignableFrom(t.getClass()) || t.getCause() != null
&& hasCauseWithType(t.getCause(), type);
return type.isAssignableFrom(t.getClass())
|| t.getCause() != null && hasCauseWithType(t.getCause(), type);
}
}

View File

@@ -79,8 +79,8 @@ public class StopMojo extends AbstractMojo {
}
}
private void stopForkedProcess() throws IOException, MojoFailureException,
MojoExecutionException {
private void stopForkedProcess()
throws IOException, MojoFailureException, MojoExecutionException {
JMXConnector connector = SpringApplicationAdminClient.connect(this.jmxPort);
try {
MBeanServerConnection connection = connector.getMBeanServerConnection();
@@ -95,15 +95,16 @@ public class StopMojo extends AbstractMojo {
doStop(ManagementFactory.getPlatformMBeanServer());
}
private void doStop(MBeanServerConnection connection) throws IOException,
MojoExecutionException {
private void doStop(MBeanServerConnection connection)
throws IOException, MojoExecutionException {
try {
new SpringApplicationAdminClient(connection, this.jmxName).stop();
}
catch (InstanceNotFoundException ex) {
throw new MojoExecutionException(
"Spring application lifecycle JMX bean not found (fork is " + ""
+ this.fork + "). Could not stop application gracefully", ex);
+ this.fork + "). Could not stop application gracefully",
ex);
}
}

View File

@@ -72,8 +72,8 @@ public class DependencyFilterMojoTests {
return a;
}
private static final class TestableDependencyFilterMojo extends
AbstractDependencyFilterMojo {
private static final class TestableDependencyFilterMojo
extends AbstractDependencyFilterMojo {
private TestableDependencyFilterMojo(List<Exclude> excludes,
String excludeGroupIds, String excludeArtifactIds) {

View File

@@ -165,14 +165,15 @@ public final class Verify {
verify(true);
}
public void verify(boolean executable, String... scriptContents) throws Exception {
public void verify(boolean executable, String... scriptContents)
throws Exception {
assertTrue("Archive missing", this.file.exists());
assertTrue("Archive not a file", this.file.isFile());
if (scriptContents.length > 0 && executable) {
String contents = new String(FileCopyUtils.copyToByteArray(this.file));
contents = contents.substring(0, contents.indexOf(new String(new byte[] {
0x50, 0x4b, 0x03, 0x04 })));
contents = contents.substring(0, contents
.indexOf(new String(new byte[] { 0x50, 0x4b, 0x03, 0x04 })));
for (String content : scriptContents) {
assertThat(contents, containsString(content));
}
@@ -180,10 +181,8 @@ public final class Verify {
if (!executable) {
String contents = new String(FileCopyUtils.copyToByteArray(this.file));
assertTrue(
"Is executable",
contents.startsWith(new String(new byte[] { 0x50, 0x4b, 0x03,
0x04 })));
assertTrue("Is executable", contents
.startsWith(new String(new byte[] { 0x50, 0x4b, 0x03, 0x04 })));
}
ZipFile zipFile = new ZipFile(this.file);