Commit 80544268 authored by Phillip Webb's avatar Phillip Webb

Format source code

parent fa88c481
...@@ -30,7 +30,8 @@ import org.springframework.context.annotation.ImportResource; ...@@ -30,7 +30,8 @@ import org.springframework.context.annotation.ImportResource;
public class SampleParentContextApplication { public class SampleParentContextApplication {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
new SpringApplicationBuilder(Parent.class).child(SampleParentContextApplication.class).run(args); new SpringApplicationBuilder(Parent.class).child(
SampleParentContextApplication.class).run(args);
} }
@EnableAutoConfiguration @EnableAutoConfiguration
......
...@@ -33,6 +33,7 @@ import org.springframework.util.StreamUtils; ...@@ -33,6 +33,7 @@ import org.springframework.util.StreamUtils;
import sample.parent.SampleParentContextApplication; import sample.parent.SampleParentContextApplication;
import sample.parent.producer.ProducerApplication; import sample.parent.producer.ProducerApplication;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
/** /**
......
...@@ -31,8 +31,8 @@ import org.springframework.boot.dependency.tools.ManagedDependencies; ...@@ -31,8 +31,8 @@ import org.springframework.boot.dependency.tools.ManagedDependencies;
import org.springframework.boot.dependency.tools.PropertiesFileDependencies; import org.springframework.boot.dependency.tools.PropertiesFileDependencies;
/** /**
* Utility to provide access to {@link ManagedDependencies} with support for version * Utility to provide access to {@link ManagedDependencies} with support for version file
* file overrides. * overrides.
* *
* @author Phillip Webb * @author Phillip Webb
*/ */
......
...@@ -123,7 +123,8 @@ class ProjectLibraries implements Libraries { ...@@ -123,7 +123,8 @@ class ProjectLibraries implements Libraries {
LibraryCallback callback) throws IOException { LibraryCallback callback) throws IOException {
if (artifacts != null) { if (artifacts != null) {
for (ResolvedArtifact artifact : artifacts) { for (ResolvedArtifact artifact : artifacts) {
callback.library(new Library(artifact.getFile(), scope, isUnpackRequired(artifact))); callback.library(new Library(artifact.getFile(), scope,
isUnpackRequired(artifact)));
} }
} }
} }
......
...@@ -55,8 +55,9 @@ public class RepackagePluginFeatures implements PluginFeatures { ...@@ -55,8 +55,9 @@ public class RepackagePluginFeatures implements PluginFeatures {
+ "archives so that they can be executed from the command " + "archives so that they can be executed from the command "
+ "line using 'java -jar'"); + "line using 'java -jar'");
task.setGroup(BasePlugin.BUILD_GROUP); task.setGroup(BasePlugin.BUILD_GROUP);
task.dependsOn(project.getConfigurations().getByName( task.dependsOn(project.getConfigurations()
Dependency.ARCHIVES_CONFIGURATION).getAllArtifacts().getBuildDependencies()); .getByName(Dependency.ARCHIVES_CONFIGURATION).getAllArtifacts()
.getBuildDependencies());
registerOutput(project, task); registerOutput(project, task);
ensureTaskRunsOnAssembly(project, task); ensureTaskRunsOnAssembly(project, task);
} }
...@@ -68,7 +69,7 @@ public class RepackagePluginFeatures implements PluginFeatures { ...@@ -68,7 +69,7 @@ public class RepackagePluginFeatures implements PluginFeatures {
project.getTasks().withType(Jar.class, project.getTasks().withType(Jar.class,
new RegisterInputsOutputsAction(task)); new RegisterInputsOutputsAction(task));
Object withJar = task.getWithJarTask(); Object withJar = task.getWithJarTask();
if (withJar!=null) { if (withJar != null) {
task.dependsOn(withJar); task.dependsOn(withJar);
} }
} }
...@@ -83,8 +84,8 @@ public class RepackagePluginFeatures implements PluginFeatures { ...@@ -83,8 +84,8 @@ public class RepackagePluginFeatures implements PluginFeatures {
* Register BootRepackage so that we can use task {@code foo(type: BootRepackage)}. * Register BootRepackage so that we can use task {@code foo(type: BootRepackage)}.
*/ */
private void registerRepackageTaskProperty(Project project) { private void registerRepackageTaskProperty(Project project) {
project.getExtensions().getExtraProperties().set("BootRepackage", project.getExtensions().getExtraProperties()
RepackageTask.class); .set("BootRepackage", RepackageTask.class);
} }
/** /**
...@@ -135,6 +136,7 @@ public class RepackagePluginFeatures implements PluginFeatures { ...@@ -135,6 +136,7 @@ public class RepackagePluginFeatures implements PluginFeatures {
private void addLibraryDependencies(final RepackageTask task) { private void addLibraryDependencies(final RepackageTask task) {
try { try {
task.getLibraries().doWithLibraries(new LibraryCallback() { task.getLibraries().doWithLibraries(new LibraryCallback() {
@Override
public void library(Library library) throws IOException { public void library(Library library) throws IOException {
task.getInputs().file(library.getFile()); task.getInputs().file(library.getFile());
} }
......
...@@ -97,7 +97,8 @@ public class RepackageTask extends DefaultTask { ...@@ -97,7 +97,8 @@ public class RepackageTask extends DefaultTask {
} }
if (this.customConfiguration != null) { if (this.customConfiguration != null) {
libraries.setCustomConfigurationName(this.customConfiguration); libraries.setCustomConfigurationName(this.customConfiguration);
} else if (extension.getCustomConfiguration() != null) { }
else if (extension.getCustomConfiguration() != null) {
libraries.setCustomConfigurationName(extension.getCustomConfiguration()); libraries.setCustomConfigurationName(extension.getCustomConfiguration());
} }
return libraries; return libraries;
...@@ -180,11 +181,13 @@ public class RepackageTask extends DefaultTask { ...@@ -180,11 +181,13 @@ public class RepackageTask extends DefaultTask {
String mainClass = (String) getProject().property("mainClassName"); String mainClass = (String) getProject().property("mainClassName");
if (RepackageTask.this.mainClass != null) { if (RepackageTask.this.mainClass != null) {
mainClass = RepackageTask.this.mainClass; mainClass = RepackageTask.this.mainClass;
} else if (this.extension.getMainClass() != null) { }
else if (this.extension.getMainClass() != null) {
mainClass = this.extension.getMainClass(); mainClass = this.extension.getMainClass();
} else if (getProject().getTasks().getByName("run").hasProperty("main")) { }
mainClass = (String) getProject().getTasks().getByName("run").property( else if (getProject().getTasks().getByName("run").hasProperty("main")) {
"main"); mainClass = (String) getProject().getTasks().getByName("run")
.property("main");
} }
getLogger().info("Setting mainClass: " + mainClass); getLogger().info("Setting mainClass: " + mainClass);
repackager.setMainClass(mainClass); repackager.setMainClass(mainClass);
...@@ -205,7 +208,8 @@ public class RepackageTask extends DefaultTask { ...@@ -205,7 +208,8 @@ public class RepackageTask extends DefaultTask {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
try { try {
return super.findMainMethod(source); return super.findMainMethod(source);
} finally { }
finally {
long duration = System.currentTimeMillis() - startTime; long duration = System.currentTimeMillis() - startTime;
if (duration > FIND_WARNING_TIMEOUT) { if (duration > FIND_WARNING_TIMEOUT) {
getLogger().warn( getLogger().warn(
......
...@@ -38,8 +38,8 @@ public class BootRunTask extends JavaExec { ...@@ -38,8 +38,8 @@ public class BootRunTask extends JavaExec {
@Override @Override
public void exec() { public void exec() {
SourceSet mainSourceSet = SourceSets.findMainSourceSet(getProject()); SourceSet mainSourceSet = SourceSets.findMainSourceSet(getProject());
final File outputDir = (mainSourceSet == null ? null final File outputDir = (mainSourceSet == null ? null : mainSourceSet.getOutput()
: mainSourceSet.getOutput().getResourcesDir()); .getResourcesDir());
final Set<File> resources = new LinkedHashSet<File>(); final Set<File> resources = new LinkedHashSet<File>();
if (mainSourceSet != null) { if (mainSourceSet != null) {
resources.addAll(mainSourceSet.getResources().getSrcDirs()); resources.addAll(mainSourceSet.getResources().getSrcDirs());
......
package org.springframework.boot.gradle.run; package org.springframework.boot.gradle.run;
import java.io.IOException; import java.io.IOException;
...@@ -41,8 +40,8 @@ public class FindMainClassTask extends DefaultTask { ...@@ -41,8 +40,8 @@ public class FindMainClassTask extends DefaultTask {
mainClass = bootExtension.getMainClass(); mainClass = bootExtension.getMainClass();
} }
ApplicationPluginConvention application = (ApplicationPluginConvention) project.getConvention().getPlugins().get( ApplicationPluginConvention application = (ApplicationPluginConvention) project
"application"); .getConvention().getPlugins().get("application");
// Try the Application extension setting // Try the Application extension setting
if (mainClass == null && application.getMainClassName() != null) { if (mainClass == null && application.getMainClassName() != null) {
mainClass = application.getMainClassName(); mainClass = application.getMainClassName();
...@@ -61,9 +60,11 @@ public class FindMainClassTask extends DefaultTask { ...@@ -61,9 +60,11 @@ public class FindMainClassTask extends DefaultTask {
"Looking for main in: " "Looking for main in: "
+ mainSourceSet.getOutput().getClassesDir()); + mainSourceSet.getOutput().getClassesDir());
try { try {
mainClass = MainClassFinder.findSingleMainClass(mainSourceSet.getOutput().getClassesDir()); mainClass = MainClassFinder.findSingleMainClass(mainSourceSet
.getOutput().getClassesDir());
project.getLogger().info("Computed main class: " + mainClass); project.getLogger().info("Computed main class: " + mainClass);
} catch (IOException ex) { }
catch (IOException ex) {
throw new IllegalStateException("Cannot find main class", ex); throw new IllegalStateException("Cannot find main class", ex);
} }
} }
......
...@@ -48,7 +48,7 @@ public class RunPluginFeatures implements PluginFeatures { ...@@ -48,7 +48,7 @@ public class RunPluginFeatures implements PluginFeatures {
project.getTasks().all(new Action<Task>() { project.getTasks().all(new Action<Task>() {
@Override @Override
public void execute(Task task) { public void execute(Task task) {
if(task instanceof JavaExec || task instanceof CreateStartScripts) { if (task instanceof JavaExec || task instanceof CreateStartScripts) {
task.dependsOn(FIND_MAIN_CLASS_TASK_NAME); task.dependsOn(FIND_MAIN_CLASS_TASK_NAME);
} }
} }
......
...@@ -42,7 +42,7 @@ class SourceSets { ...@@ -42,7 +42,7 @@ class SourceSets {
private static Iterable<SourceSet> getJavaSourceSets(Project project) { private static Iterable<SourceSet> getJavaSourceSets(Project project) {
JavaPluginConvention plugin = project.getConvention().getPlugin( JavaPluginConvention plugin = project.getConvention().getPlugin(
JavaPluginConvention.class); JavaPluginConvention.class);
if(plugin == null) { if (plugin == null) {
return Collections.emptyList(); return Collections.emptyList();
} }
return plugin.getSourceSets(); return plugin.getSourceSets();
......
...@@ -53,8 +53,8 @@ public abstract class YamlProcessor { ...@@ -53,8 +53,8 @@ public abstract class YamlProcessor {
/** /**
* A map of document matchers allowing callers to selectively use only some of the * A map of document matchers allowing callers to selectively use only some of the
* documents in a YAML resource. In YAML documents are separated by * documents in a YAML resource. In YAML documents are separated by <code>---</code>
* <code>---<code> lines, and each document is converted to properties before the match is made. E.g. * lines, and each document is converted to properties before the match is made. E.g.
* *
* <pre class="code"> * <pre class="code">
* environment: dev * environment: dev
...@@ -66,7 +66,8 @@ public abstract class YamlProcessor { ...@@ -66,7 +66,8 @@ public abstract class YamlProcessor {
* name: My Cool App * name: My Cool App
* </pre> * </pre>
* *
* when mapped with <code>documentMatchers = YamlProcessor.mapMatcher({"environment": "prod"})</code> * when mapped with
* <code>documentMatchers = YamlProcessor.mapMatcher({"environment": "prod"})</code>
* would end up as * would end up as
* *
* <pre class="code"> * <pre class="code">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment