From 179e1558f64cac16de102f079216392877d4ced6 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 18 Jun 2014 12:48:42 -0700 Subject: [PATCH] Polish --- .../DataSourceInitializerPostProcessor.java | 3 +- .../boot/gradle/ClassifierTests.java | 29 ++++++++++--------- .../ui/secure/SampleWebSecureApplication.java | 11 ++++--- .../gradle/SpringBootPluginExtension.groovy | 6 ++-- .../repackage/RepackagePluginFeatures.java | 10 +++---- .../boot/gradle/repackage/RepackageTask.java | 4 +-- 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerPostProcessor.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerPostProcessor.java index b63526d333b..903febe14cb 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerPostProcessor.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerPostProcessor.java @@ -33,7 +33,7 @@ import org.springframework.core.type.AnnotationMetadata; * be registered via the inner {@link Registrar} class. * * @author Dave Syer - * @since 1.1.0 + * @since 1.1.2 */ class DataSourceInitializerPostProcessor implements BeanPostProcessor { @@ -78,6 +78,7 @@ class DataSourceInitializerPostProcessor implements BeanPostProcessor { registry.registerBeanDefinition(BEAN_NAME, beanDefinition); } } + } } diff --git a/spring-boot-integration-tests/src/test/java/org/springframework/boot/gradle/ClassifierTests.java b/spring-boot-integration-tests/src/test/java/org/springframework/boot/gradle/ClassifierTests.java index 390ec7e3ea8..eb0cd279209 100644 --- a/spring-boot-integration-tests/src/test/java/org/springframework/boot/gradle/ClassifierTests.java +++ b/spring-boot-integration-tests/src/test/java/org/springframework/boot/gradle/ClassifierTests.java @@ -16,48 +16,49 @@ package org.springframework.boot.gradle; -import static org.junit.Assert.assertNotNull; - import java.util.jar.JarFile; import org.gradle.tooling.ProjectConnection; import org.junit.Test; import org.springframework.boot.dependency.tools.ManagedDependencies; +import static org.junit.Assert.assertNotNull; + /** * Tests for using the Gradle plugin's support for installing artifacts - * + * * @author Dave Syer */ public class ClassifierTests { private ProjectConnection project; - private static final String BOOT_VERSION = ManagedDependencies.get().find( - "spring-boot").getVersion(); + private static final String BOOT_VERSION = ManagedDependencies.get() + .find("spring-boot").getVersion(); @Test public void classifierInBootTask() throws Exception { - project = new ProjectCreator().createProject("classifier"); - project.newBuild().forTasks("build").withArguments( - "-PbootVersion=" + BOOT_VERSION, "--stacktrace").run(); + this.project = new ProjectCreator().createProject("classifier"); + this.project.newBuild().forTasks("build") + .withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run(); checkFilesExist("classifier"); } @Test public void classifierInBootExtension() throws Exception { - project = new ProjectCreator().createProject("classifier-extension"); - project.newBuild().forTasks("build").withArguments( - "-PbootVersion=" + BOOT_VERSION, "--stacktrace", "--info").run(); + this.project = new ProjectCreator().createProject("classifier-extension"); + this.project.newBuild().forTasks("build") + .withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace", "--info") + .run(); } private void checkFilesExist(String name) throws Exception { - JarFile jar = new JarFile("target/" + name + "/build/libs/" + name + ".jar"); + JarFile jar = new JarFile("target/" + name + "/build/libs/" + name + ".jar"); assertNotNull(jar.getManifest()); jar.close(); - jar = new JarFile("target/" + name + "/build/libs/" + name + "-exec.jar"); + jar = new JarFile("target/" + name + "/build/libs/" + name + "-exec.jar"); assertNotNull(jar.getManifest()); jar.close(); } - + } diff --git a/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/ui/secure/SampleWebSecureApplication.java b/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/ui/secure/SampleWebSecureApplication.java index 1076ef229c9..cec652a47db 100644 --- a/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/ui/secure/SampleWebSecureApplication.java +++ b/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/ui/secure/SampleWebSecureApplication.java @@ -89,18 +89,17 @@ public class SampleWebSecureApplication extends WebMvcConfigurerAdapter { } @Order(Ordered.HIGHEST_PRECEDENCE + 10) - protected static class AuthenticationSecurity extends GlobalAuthenticationConfigurerAdapter { + protected static class AuthenticationSecurity extends + GlobalAuthenticationConfigurerAdapter { @Autowired private DataSource dataSource; @Override public void init(AuthenticationManagerBuilder auth) throws Exception { - // @formatter:off - auth.jdbcAuthentication().dataSource(dataSource).withUser("admin").password("admin") - .roles("ADMIN", "USER").and().withUser("user").password("user") - .roles("USER"); - // @formatter:on + auth.jdbcAuthentication().dataSource(this.dataSource).withUser("admin") + .password("admin").roles("ADMIN", "USER").and().withUser("user") + .password("user").roles("USER"); } } diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPluginExtension.groovy b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPluginExtension.groovy index 05632221833..1aa5c0df0ec 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPluginExtension.groovy +++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPluginExtension.groovy @@ -58,15 +58,15 @@ public class SpringBootPluginExtension { } /** - * The main class that should be run. Instead of setting this explicitly you can use the - * 'mainClassName' of the project or the 'main' of the 'run' task. If not specified the + * The main class that should be run. Instead of setting this explicitly you can use the + * 'mainClassName' of the project or the 'main' of the 'run' task. If not specified the * value from the MANIFEST will be used, or if no manifest entry is the archive will be * searched for a suitable class. */ String mainClass /** - * The classifier (file name part before the extension). Instead of setting this explicitly + * The classifier (file name part before the extension). Instead of setting this explicitly * you can use the 'classifier' property of the 'bootRepackage' task. If not specified the archive * will be replaced instead of renamed. */ diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/repackage/RepackagePluginFeatures.java b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/repackage/RepackagePluginFeatures.java index 0a9c33a5897..404fa2f4ac6 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/repackage/RepackagePluginFeatures.java +++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/repackage/RepackagePluginFeatures.java @@ -61,7 +61,7 @@ public class RepackagePluginFeatures implements PluginFeatures { project.afterEvaluate(new Action() { @Override public void execute(Project project) { - project.getTasks().withType(Jar.class, new OutputAction(task)); + project.getTasks().withType(Jar.class, new OutputAction(task)); } }); } @@ -89,9 +89,9 @@ public class RepackagePluginFeatures implements PluginFeatures { @Override public void execute(Jar archive) { if ("".equals(archive.getClassifier())) { - setClassifier(task, archive); + setClassifier(this.task, archive); File file = archive.getArchivePath(); - String classifier = task.getClassifier(); + String classifier = this.task.getClassifier(); if (classifier != null) { String withClassifer = file.getName(); withClassifer = StringUtils.stripFilenameExtension(withClassifer) @@ -99,8 +99,8 @@ public class RepackagePluginFeatures implements PluginFeatures { + StringUtils.getFilenameExtension(withClassifer); File out = new File(file.getParentFile(), withClassifer); file = out; - task.getOutputs().file(file); - task.setOutputFile(file); + this.task.getOutputs().file(file); + this.task.setOutputFile(file); } } diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/repackage/RepackageTask.java b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/repackage/RepackageTask.java index 47b21fa6347..c5a85ef3740 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/repackage/RepackageTask.java +++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/repackage/RepackageTask.java @@ -120,8 +120,8 @@ public class RepackageTask extends DefaultTask { try { FileCopyUtils.copy(file, out); } - catch (IOException e) { - throw new IllegalStateException(e.getMessage(), e); + catch (IOException ex) { + throw new IllegalStateException(ex.getMessage(), ex); } file = out; }