Commit 179e1558 authored by Phillip Webb's avatar Phillip Webb

Polish

parent 2433f721
...@@ -33,7 +33,7 @@ import org.springframework.core.type.AnnotationMetadata; ...@@ -33,7 +33,7 @@ import org.springframework.core.type.AnnotationMetadata;
* be registered via the inner {@link Registrar} class. * be registered via the inner {@link Registrar} class.
* *
* @author Dave Syer * @author Dave Syer
* @since 1.1.0 * @since 1.1.2
*/ */
class DataSourceInitializerPostProcessor implements BeanPostProcessor { class DataSourceInitializerPostProcessor implements BeanPostProcessor {
...@@ -78,6 +78,7 @@ class DataSourceInitializerPostProcessor implements BeanPostProcessor { ...@@ -78,6 +78,7 @@ class DataSourceInitializerPostProcessor implements BeanPostProcessor {
registry.registerBeanDefinition(BEAN_NAME, beanDefinition); registry.registerBeanDefinition(BEAN_NAME, beanDefinition);
} }
} }
} }
} }
...@@ -16,48 +16,49 @@ ...@@ -16,48 +16,49 @@
package org.springframework.boot.gradle; package org.springframework.boot.gradle;
import static org.junit.Assert.assertNotNull;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import org.gradle.tooling.ProjectConnection; import org.gradle.tooling.ProjectConnection;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.dependency.tools.ManagedDependencies; import org.springframework.boot.dependency.tools.ManagedDependencies;
import static org.junit.Assert.assertNotNull;
/** /**
* Tests for using the Gradle plugin's support for installing artifacts * Tests for using the Gradle plugin's support for installing artifacts
* *
* @author Dave Syer * @author Dave Syer
*/ */
public class ClassifierTests { public class ClassifierTests {
private ProjectConnection project; private ProjectConnection project;
private static final String BOOT_VERSION = ManagedDependencies.get().find( private static final String BOOT_VERSION = ManagedDependencies.get()
"spring-boot").getVersion(); .find("spring-boot").getVersion();
@Test @Test
public void classifierInBootTask() throws Exception { public void classifierInBootTask() throws Exception {
project = new ProjectCreator().createProject("classifier"); this.project = new ProjectCreator().createProject("classifier");
project.newBuild().forTasks("build").withArguments( this.project.newBuild().forTasks("build")
"-PbootVersion=" + BOOT_VERSION, "--stacktrace").run(); .withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
checkFilesExist("classifier"); checkFilesExist("classifier");
} }
@Test @Test
public void classifierInBootExtension() throws Exception { public void classifierInBootExtension() throws Exception {
project = new ProjectCreator().createProject("classifier-extension"); this.project = new ProjectCreator().createProject("classifier-extension");
project.newBuild().forTasks("build").withArguments( this.project.newBuild().forTasks("build")
"-PbootVersion=" + BOOT_VERSION, "--stacktrace", "--info").run(); .withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace", "--info")
.run();
} }
private void checkFilesExist(String name) throws Exception { 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()); assertNotNull(jar.getManifest());
jar.close(); 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()); assertNotNull(jar.getManifest());
jar.close(); jar.close();
} }
} }
...@@ -89,18 +89,17 @@ public class SampleWebSecureApplication extends WebMvcConfigurerAdapter { ...@@ -89,18 +89,17 @@ public class SampleWebSecureApplication extends WebMvcConfigurerAdapter {
} }
@Order(Ordered.HIGHEST_PRECEDENCE + 10) @Order(Ordered.HIGHEST_PRECEDENCE + 10)
protected static class AuthenticationSecurity extends GlobalAuthenticationConfigurerAdapter { protected static class AuthenticationSecurity extends
GlobalAuthenticationConfigurerAdapter {
@Autowired @Autowired
private DataSource dataSource; private DataSource dataSource;
@Override @Override
public void init(AuthenticationManagerBuilder auth) throws Exception { public void init(AuthenticationManagerBuilder auth) throws Exception {
// @formatter:off auth.jdbcAuthentication().dataSource(this.dataSource).withUser("admin")
auth.jdbcAuthentication().dataSource(dataSource).withUser("admin").password("admin") .password("admin").roles("ADMIN", "USER").and().withUser("user")
.roles("ADMIN", "USER").and().withUser("user").password("user") .password("user").roles("USER");
.roles("USER");
// @formatter:on
} }
} }
......
...@@ -58,15 +58,15 @@ public class SpringBootPluginExtension { ...@@ -58,15 +58,15 @@ public class SpringBootPluginExtension {
} }
/** /**
* The main class that should be run. Instead of setting this explicitly you can use 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 * '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 * value from the MANIFEST will be used, or if no manifest entry is the archive will be
* searched for a suitable class. * searched for a suitable class.
*/ */
String mainClass 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 * you can use the 'classifier' property of the 'bootRepackage' task. If not specified the archive
* will be replaced instead of renamed. * will be replaced instead of renamed.
*/ */
......
...@@ -61,7 +61,7 @@ public class RepackagePluginFeatures implements PluginFeatures { ...@@ -61,7 +61,7 @@ public class RepackagePluginFeatures implements PluginFeatures {
project.afterEvaluate(new Action<Project>() { project.afterEvaluate(new Action<Project>() {
@Override @Override
public void execute(Project project) { 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 { ...@@ -89,9 +89,9 @@ public class RepackagePluginFeatures implements PluginFeatures {
@Override @Override
public void execute(Jar archive) { public void execute(Jar archive) {
if ("".equals(archive.getClassifier())) { if ("".equals(archive.getClassifier())) {
setClassifier(task, archive); setClassifier(this.task, archive);
File file = archive.getArchivePath(); File file = archive.getArchivePath();
String classifier = task.getClassifier(); String classifier = this.task.getClassifier();
if (classifier != null) { if (classifier != null) {
String withClassifer = file.getName(); String withClassifer = file.getName();
withClassifer = StringUtils.stripFilenameExtension(withClassifer) withClassifer = StringUtils.stripFilenameExtension(withClassifer)
...@@ -99,8 +99,8 @@ public class RepackagePluginFeatures implements PluginFeatures { ...@@ -99,8 +99,8 @@ public class RepackagePluginFeatures implements PluginFeatures {
+ StringUtils.getFilenameExtension(withClassifer); + StringUtils.getFilenameExtension(withClassifer);
File out = new File(file.getParentFile(), withClassifer); File out = new File(file.getParentFile(), withClassifer);
file = out; file = out;
task.getOutputs().file(file); this.task.getOutputs().file(file);
task.setOutputFile(file); this.task.setOutputFile(file);
} }
} }
......
...@@ -120,8 +120,8 @@ public class RepackageTask extends DefaultTask { ...@@ -120,8 +120,8 @@ public class RepackageTask extends DefaultTask {
try { try {
FileCopyUtils.copy(file, out); FileCopyUtils.copy(file, out);
} }
catch (IOException e) { catch (IOException ex) {
throw new IllegalStateException(e.getMessage(), e); throw new IllegalStateException(ex.getMessage(), ex);
} }
file = out; file = out;
} }
......
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