Polish
This commit is contained in:
parent
2433f721bc
commit
179e1558f6
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class RepackagePluginFeatures implements PluginFeatures {
|
|||
project.afterEvaluate(new Action<Project>() {
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue