Upgrade to spring-javaformat 0.0.11

This commit is contained in:
Andy Wilkinson
2019-06-07 09:44:58 +01:00
parent d548c5ed31
commit 8f1be4cded
1940 changed files with 16814 additions and 28498 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,8 +49,8 @@ public class BootRunResourceTests {
@Test
public void resourcesDirectlyFromSource() {
project.newBuild().forTasks("clean", "bootRun")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PaddResources=true")
.setStandardOutput(System.out).run();
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PaddResources=true").setStandardOutput(System.out)
.run();
assertThat(this.output.toString()).contains("src/main/resources/test.txt");
}
@@ -58,8 +58,8 @@ public class BootRunResourceTests {
@Test
public void resourcesFromBuildOutput() {
project.newBuild().forTasks("clean", "bootRun")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PaddResources=false")
.setStandardOutput(System.out).run();
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PaddResources=false").setStandardOutput(System.out)
.run();
assertThat(this.output.toString()).contains("build/resources/main/test.txt");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,8 +37,7 @@ public class ClassifierTests {
@Test
public void classifierInBootTask() throws Exception {
this.project = new ProjectCreator().createProject("classifier");
this.project.newBuild().forTasks("build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
this.project.newBuild().forTasks("build").withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
checkFilesExist("classifier");
}
@@ -46,8 +45,7 @@ public class ClassifierTests {
public void classifierInBootExtension() throws Exception {
this.project = new ProjectCreator().createProject("classifier-extension");
this.project.newBuild().forTasks("build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace", "--info")
.run();
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace", "--info").run();
}
private void checkFilesExist(String name) throws Exception {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,8 +39,7 @@ public class DeprecatedPluginTests {
@Test
public void deprecatedIdWorks() throws Exception {
this.project = new ProjectCreator().createProject("deprecated-plugin");
this.project.newBuild().forTasks("build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
this.project.newBuild().forTasks("build").withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,10 +51,8 @@ public class FlatdirTests {
if (!this.libs.exists()) {
this.libs.mkdirs();
}
FileCopyUtils.copy(new File("src/test/resources/foo.jar"),
new File(this.libs, "foo-1.0.0.jar"));
this.project.newBuild().forTasks("build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
FileCopyUtils.copy(new File("src/test/resources/foo.jar"), new File(this.libs, "foo-1.0.0.jar"));
this.project.newBuild().forTasks("build").withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,8 +48,7 @@ public class FullyExecutableJarTests {
@Test
public void jarIsNotExecutableByDefault() throws IOException {
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION).run();
project.newBuild().forTasks("clean", "build").withArguments("-PbootVersion=" + BOOT_VERSION).run();
File buildLibs = new File("target/executable-jar/build/libs");
File executableJar = new File(buildLibs, "executable-jar.jar");
assertThat(isFullyExecutable(executableJar)).isFalse();
@@ -57,8 +56,8 @@ public class FullyExecutableJarTests {
@Test
public void madeExecutableViaExtension() throws IOException {
project.newBuild().forTasks("clean", "build").withArguments(
"-PbootVersion=" + BOOT_VERSION, "-PextensionExecutable=true").run();
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PextensionExecutable=true").run();
File buildLibs = new File("target/executable-jar/build/libs");
File executableJar = new File(buildLibs, "executable-jar.jar");
assertThat(isFullyExecutable(executableJar)).isTrue();
@@ -67,8 +66,7 @@ public class FullyExecutableJarTests {
@Test
public void madeExecutableViaTask() throws IOException {
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PtaskExecutable=true")
.run();
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PtaskExecutable=true").run();
File buildLibs = new File("target/executable-jar/build/libs");
File executableJar = new File(buildLibs, "executable-jar.jar");
assertThat(isFullyExecutable(executableJar)).isTrue();
@@ -77,8 +75,7 @@ public class FullyExecutableJarTests {
@Test
public void taskTakesPrecedenceForMakingJarExecutable() throws IOException {
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION,
"-PextensionExecutable=false", "-PtaskExecutable=true")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PextensionExecutable=false", "-PtaskExecutable=true")
.run();
File buildLibs = new File("target/executable-jar/build/libs");
File executableJar = new File(buildLibs, "executable-jar.jar");
@@ -88,8 +85,7 @@ public class FullyExecutableJarTests {
@Test
public void scriptPropertiesFromTask() throws IOException {
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PtaskProperties=true")
.run();
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PtaskProperties=true").run();
File buildLibs = new File("target/executable-jar/build/libs");
File executableJar = new File(buildLibs, "executable-jar.jar");
assertThat(isFullyExecutable(executableJar)).isTrue();
@@ -98,8 +94,8 @@ public class FullyExecutableJarTests {
@Test
public void scriptPropertiesFromExtension() throws IOException {
project.newBuild().forTasks("clean", "build").withArguments(
"-PbootVersion=" + BOOT_VERSION, "-PextensionProperties=true").run();
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PextensionProperties=true").run();
File buildLibs = new File("target/executable-jar/build/libs");
File executableJar = new File(buildLibs, "executable-jar.jar");
assertThat(isFullyExecutable(executableJar)).isTrue();
@@ -109,8 +105,7 @@ public class FullyExecutableJarTests {
@Test
public void taskTakesPrecedenceForScriptProperties() throws IOException {
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION,
"-PextensionProperties=true", "-PtaskProperties=true")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PextensionProperties=true", "-PtaskProperties=true")
.run();
File buildLibs = new File("target/executable-jar/build/libs");
File executableJar = new File(buildLibs, "executable-jar.jar");
@@ -121,8 +116,7 @@ public class FullyExecutableJarTests {
@Test
public void customScriptFromTask() throws IOException {
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PtaskScript=true")
.run();
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PtaskScript=true").run();
File buildLibs = new File("target/executable-jar/build/libs");
File executableJar = new File(buildLibs, "executable-jar.jar");
assertThat(containsLine("Custom task script", executableJar)).isTrue();
@@ -131,8 +125,7 @@ public class FullyExecutableJarTests {
@Test
public void customScriptFromExtension() throws IOException {
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PextensionScript=true")
.run();
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PextensionScript=true").run();
File buildLibs = new File("target/executable-jar/build/libs");
File executableJar = new File(buildLibs, "executable-jar.jar");
assertThat(containsLine("Custom extension script", executableJar)).isTrue();
@@ -141,9 +134,7 @@ public class FullyExecutableJarTests {
@Test
public void taskTakesPrecedenceForCustomScript() throws IOException {
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PextensionScript=true",
"-PtaskScript=true")
.run();
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PextensionScript=true", "-PtaskScript=true").run();
File buildLibs = new File("target/executable-jar/build/libs");
File executableJar = new File(buildLibs, "executable-jar.jar");
assertThat(containsLine("Custom task script", executableJar)).isTrue();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,8 +33,8 @@ public class InstallTests {
@Test
public void cleanInstall() throws Exception {
this.project = new ProjectCreator().createProject("installer");
this.project.newBuild().forTasks("install")
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
this.project.newBuild().forTasks("install").withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace")
.run();
}
@Test
@@ -42,8 +42,8 @@ public class InstallTests {
this.project = new ProjectCreator().createProject("install-app");
// "install" from the application plugin was renamed "installApp" in Gradle
// 1.0
this.project.newBuild().forTasks("installApp")
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
this.project.newBuild().forTasks("installApp").withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace")
.run();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,16 +44,14 @@ public class MainClassTests {
@Test
public void mainFromBootRun() {
project.newBuild().forTasks("build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PbootRunMain=true")
.run();
project.newBuild().forTasks("build").withArguments("-PbootVersion=" + BOOT_VERSION, "-PbootRunMain=true").run();
}
@Test
public void nonJavaExecRunTaskIsIgnored() {
try {
project.newBuild().forTasks("build").withArguments(
"-PbootVersion=" + BOOT_VERSION, "-PnonJavaExecRun=true").run();
project.newBuild().forTasks("build").withArguments("-PbootVersion=" + BOOT_VERSION, "-PnonJavaExecRun=true")
.run();
}
catch (BuildException ex) {
Throwable rootCause = getRootCause(ex);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,16 +49,12 @@ public class MixedVersionRepackagingTests {
@Test
public void singleVersionIsIncludedInJar() throws IOException {
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true",
"-PexcludeDevtools=false")
.run();
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true", "-PexcludeDevtools=false").run();
File buildLibs = new File("target/mixed-version-repackaging/build/libs");
File repackageFile = new File(buildLibs, "mixed-version-repackaging.jar");
assertThat(repackageFile.exists()).isTrue();
assertThat(new JarFile(repackageFile))
.has(entryNamed("BOOT-INF/lib/guava-18.0.jar"));
assertThat(new JarFile(repackageFile))
.has(not(entryNamed("BOOT-INF/lib/guava-16.0.jar")));
assertThat(new JarFile(repackageFile)).has(entryNamed("BOOT-INF/lib/guava-18.0.jar"));
assertThat(new JarFile(repackageFile)).has(not(entryNamed("BOOT-INF/lib/guava-16.0.jar")));
}
private Condition<JarFile> entryNamed(String name) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,41 +35,30 @@ public class MultiProjectRepackagingTests {
@Test
public void repackageWithTransitiveFileDependency() throws Exception {
ProjectConnection project = new ProjectCreator()
.createProject("multi-project-transitive-file-dependency");
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION).run();
File buildLibs = new File(
"target/multi-project-transitive-file-dependency/main/build/libs");
ProjectConnection project = new ProjectCreator().createProject("multi-project-transitive-file-dependency");
project.newBuild().forTasks("clean", "build").withArguments("-PbootVersion=" + BOOT_VERSION).run();
File buildLibs = new File("target/multi-project-transitive-file-dependency/main/build/libs");
JarFile jarFile = new JarFile(new File(buildLibs, "main.jar"));
assertThat(jarFile.getEntry("BOOT-INF/lib/commons-logging-1.1.3.jar"))
.isNotNull();
assertThat(jarFile.getEntry("BOOT-INF/lib/commons-logging-1.1.3.jar")).isNotNull();
assertThat(jarFile.getEntry("BOOT-INF/lib/foo.jar")).isNotNull();
jarFile.close();
}
@Test
public void repackageWithCommonFileDependency() throws Exception {
ProjectConnection project = new ProjectCreator()
.createProject("multi-project-common-file-dependency");
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION).run();
File buildLibs = new File(
"target/multi-project-common-file-dependency/build/libs");
JarFile jarFile = new JarFile(
new File(buildLibs, "multi-project-common-file-dependency.jar"));
ProjectConnection project = new ProjectCreator().createProject("multi-project-common-file-dependency");
project.newBuild().forTasks("clean", "build").withArguments("-PbootVersion=" + BOOT_VERSION).run();
File buildLibs = new File("target/multi-project-common-file-dependency/build/libs");
JarFile jarFile = new JarFile(new File(buildLibs, "multi-project-common-file-dependency.jar"));
assertThat(jarFile.getEntry("BOOT-INF/lib/foo.jar")).isNotNull();
jarFile.close();
}
@Test
public void repackageWithRuntimeProjectDependency() throws Exception {
ProjectConnection project = new ProjectCreator()
.createProject("multi-project-runtime-project-dependency");
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION).run();
File buildLibs = new File(
"target/multi-project-runtime-project-dependency/projectA/build/libs");
ProjectConnection project = new ProjectCreator().createProject("multi-project-runtime-project-dependency");
project.newBuild().forTasks("clean", "build").withArguments("-PbootVersion=" + BOOT_VERSION).run();
File buildLibs = new File("target/multi-project-runtime-project-dependency/projectA/build/libs");
JarFile jarFile = new JarFile(new File(buildLibs, "projectA.jar"));
assertThat(jarFile.getEntry("BOOT-INF/lib/projectB.jar")).isNotNull();
jarFile.close();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,8 +37,7 @@ public class NoJarTests {
@Test
public void nojar() throws Exception {
this.project = new ProjectCreator().createProject("nojar");
this.project.newBuild().forTasks("build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
this.project.newBuild().forTasks("build").withArguments("-PbootVersion=" + BOOT_VERSION, "--stacktrace").run();
assertThat(new File("target/nojar/build/libs")).doesNotExist();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,12 +48,10 @@ public class ProjectCreator {
File gradleScript = new File(projectDirectory, "build.gradle");
if (new File("src/test/resources", name).isDirectory()) {
FileSystemUtils.copyRecursively(new File("src/test/resources", name),
projectDirectory);
FileSystemUtils.copyRecursively(new File("src/test/resources", name), projectDirectory);
}
else {
FileCopyUtils.copy(new File("src/test/resources/" + name + ".gradle"),
gradleScript);
FileCopyUtils.copy(new File("src/test/resources/" + name + ".gradle"), gradleScript);
}
GradleConnector gradleConnector = GradleConnector.newConnector();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,53 +47,43 @@ public class RepackagingTests {
@Test
public void repackagingEnabled() throws IOException {
createBuildForTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true").run();
createBuildForTasks("clean", "build").withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true").run();
File buildLibs = new File("target/repackage/build/libs");
File repackageFile = new File(buildLibs, "repackage.jar");
assertThat(repackageFile.exists()).isTrue();
assertThat(new File(buildLibs, "repackage.jar.original").exists()).isTrue();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists())
.isFalse();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists()).isFalse();
}
@Test
public void repackagingDisabled() {
createBuildForTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=false")
.run();
createBuildForTasks("clean", "build").withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=false").run();
File buildLibs = new File("target/repackage/build/libs");
assertThat(new File(buildLibs, "repackage.jar").exists()).isTrue();
assertThat(new File(buildLibs, "repackage.jar.original").exists()).isFalse();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists())
.isFalse();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists()).isFalse();
}
@Test
public void repackagingDisabledWithCustomRepackagedJar() {
createBuildForTasks("clean", "build", "customRepackagedJar")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=false")
.run();
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=false").run();
File buildLibs = new File("target/repackage/build/libs");
assertThat(new File(buildLibs, "repackage.jar").exists()).isTrue();
assertThat(new File(buildLibs, "repackage.jar.original").exists()).isFalse();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists())
.isFalse();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists()).isFalse();
assertThat(new File(buildLibs, "custom.jar").exists()).isTrue();
assertThat(new File(buildLibs, "custom.jar.original").exists()).isTrue();
}
@Test
public void repackagingDisabledWithCustomRepackagedJarUsingStringJarTaskReference() {
project.newBuild()
.forTasks("clean", "build", "customRepackagedJarWithStringReference")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=false")
.run();
project.newBuild().forTasks("clean", "build", "customRepackagedJarWithStringReference")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=false").run();
File buildLibs = new File("target/repackage/build/libs");
assertThat(new File(buildLibs, "repackage.jar").exists()).isTrue();
assertThat(new File(buildLibs, "repackage.jar.original").exists()).isFalse();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists())
.isFalse();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists()).isFalse();
assertThat(new File(buildLibs, "custom.jar").exists()).isTrue();
assertThat(new File(buildLibs, "custom.jar.original").exists()).isTrue();
}
@@ -105,32 +95,27 @@ public class RepackagingTests {
File buildLibs = new File("target/repackage/build/libs");
assertThat(new File(buildLibs, "repackage.jar").exists()).isTrue();
assertThat(new File(buildLibs, "repackage.jar.original").exists()).isTrue();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists())
.isFalse();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists()).isFalse();
assertThat(new File(buildLibs, "custom.jar").exists()).isTrue();
assertThat(new File(buildLibs, "custom.jar.original").exists()).isTrue();
}
@Test
public void repackagingEnableWithCustomRepackagedJarUsingStringJarTaskReference() {
project.newBuild()
.forTasks("clean", "build", "customRepackagedJarWithStringReference")
project.newBuild().forTasks("clean", "build", "customRepackagedJarWithStringReference")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true").run();
File buildLibs = new File("target/repackage/build/libs");
assertThat(new File(buildLibs, "repackage.jar").exists()).isTrue();
assertThat(new File(buildLibs, "repackage.jar.original").exists()).isTrue();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists())
.isFalse();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists()).isFalse();
assertThat(new File(buildLibs, "custom.jar").exists()).isTrue();
assertThat(new File(buildLibs, "custom.jar.original").exists()).isTrue();
}
@Test
public void repackageWithFileDependency() throws Exception {
FileCopyUtils.copy(new File("src/test/resources/foo.jar"),
new File("target/repackage/foo.jar"));
createBuildForTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true").run();
FileCopyUtils.copy(new File("src/test/resources/foo.jar"), new File("target/repackage/foo.jar"));
createBuildForTasks("clean", "build").withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true").run();
File buildLibs = new File("target/repackage/build/libs");
JarFile jarFile = new JarFile(new File(buildLibs, "repackage.jar"));
assertThat(jarFile.getEntry("BOOT-INF/lib/foo.jar")).isNotNull();
@@ -139,61 +124,51 @@ public class RepackagingTests {
@Test
public void devtoolsIsExcludedByDefault() throws IOException {
createBuildForTasks("clean", "bootRepackage")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true").run();
createBuildForTasks("clean", "bootRepackage").withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true")
.run();
File buildLibs = new File("target/repackage/build/libs");
File repackageFile = new File(buildLibs, "repackage.jar");
assertThat(repackageFile.exists()).isTrue();
assertThat(new File(buildLibs, "repackage.jar.original").exists()).isTrue();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists())
.isFalse();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists()).isFalse();
assertThat(isDevToolsJarIncluded(repackageFile)).isFalse();
}
@Test
public void devtoolsCanBeIncludedUsingTheExtension() throws IOException {
createBuildForTasks("clean", "bootRepackage")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true",
"-PexcludeDevtoolsOnExtension=false")
.run();
createBuildForTasks("clean", "bootRepackage").withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true",
"-PexcludeDevtoolsOnExtension=false").run();
File buildLibs = new File("target/repackage/build/libs");
File repackageFile = new File(buildLibs, "repackage.jar");
assertThat(repackageFile.exists()).isTrue();
assertThat(new File(buildLibs, "repackage.jar.original").exists()).isTrue();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists())
.isFalse();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists()).isFalse();
assertThat(isDevToolsJarIncluded(repackageFile)).isTrue();
}
@Test
public void devtoolsCanBeIncludedUsingBootRepackage() throws IOException {
createBuildForTasks("clean", "bootRepackage")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true",
"-PexcludeDevtoolsOnBootRepackage=false")
.run();
createBuildForTasks("clean", "bootRepackage").withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true",
"-PexcludeDevtoolsOnBootRepackage=false").run();
File buildLibs = new File("target/repackage/build/libs");
File repackageFile = new File(buildLibs, "repackage.jar");
assertThat(repackageFile.exists()).isTrue();
assertThat(new File(buildLibs, "repackage.jar.original").exists()).isTrue();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists())
.isFalse();
assertThat(new File(buildLibs, "repackage-sources.jar.original").exists()).isFalse();
assertThat(isDevToolsJarIncluded(repackageFile)).isTrue();
}
@Test
public void customRepackagingTaskWithOwnMainClassNameAnNoGlobalMainClassName() {
createBuildForTasks("clean", "customRepackagedJarWithOwnMainClass")
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true",
"-PnoMainClass=true")
.run();
.withArguments("-PbootVersion=" + BOOT_VERSION, "-Prepackage=true", "-PnoMainClass=true").run();
File buildLibs = new File("target/repackage/build/libs");
assertThat(new File(buildLibs, "custom.jar").exists()).isTrue();
assertThat(new File(buildLibs, "custom.jar.original").exists()).isTrue();
}
private BuildLauncher createBuildForTasks(String... taskNames) {
return project.newBuild().setStandardError(System.err)
.setStandardOutput(System.out).forTasks(taskNames);
return project.newBuild().setStandardError(System.err).setStandardOutput(System.out).forTasks(taskNames);
}
private boolean isDevToolsJarIncluded(File repackageFile) throws IOException {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,25 +40,20 @@ public class SpringLoadedTests {
private static final String SPRING_LOADED_VERSION = Versions.getSpringLoadedVersion();
@Test
public void defaultJvmArgsArePreservedWhenLoadedAgentIsConfigured()
throws IOException {
ProjectConnection project = new ProjectCreator()
.createProject("spring-loaded-jvm-args");
project.newBuild().forTasks("bootRun")
.withArguments("-PbootVersion=" + BOOT_VERSION,
"-PspringLoadedVersion=" + SPRING_LOADED_VERSION, "--stacktrace")
.run();
public void defaultJvmArgsArePreservedWhenLoadedAgentIsConfigured() throws IOException {
ProjectConnection project = new ProjectCreator().createProject("spring-loaded-jvm-args");
project.newBuild().forTasks("bootRun").withArguments("-PbootVersion=" + BOOT_VERSION,
"-PspringLoadedVersion=" + SPRING_LOADED_VERSION, "--stacktrace").run();
List<String> output = getOutput();
assertOutputContains("-DSOME_ARG=someValue", output);
assertOutputContains("-Xverify:none", output);
assertOutputMatches("-javaagent:.*springloaded-" + SPRING_LOADED_VERSION + ".jar",
output);
assertOutputMatches("-javaagent:.*springloaded-" + SPRING_LOADED_VERSION + ".jar", output);
}
private List<String> getOutput() throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(
new File("target/spring-loaded-jvm-args/build/output.txt")));
BufferedReader reader = new BufferedReader(
new FileReader(new File("target/spring-loaded-jvm-args/build/output.txt")));
try {
List<String> lines = new ArrayList<String>();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,20 +33,17 @@ public final class Versions {
}
public static String getBootVersion() {
return evaluateExpression(
"/*[local-name()='project']/*[local-name()='version']" + "/text()");
return evaluateExpression("/*[local-name()='project']/*[local-name()='version']" + "/text()");
}
public static String getSpringLoadedVersion() {
return evaluateExpression(
"/*[local-name()='project']/*[local-name()='properties']"
+ "/*[local-name()='spring-loaded.version']/text()");
return evaluateExpression("/*[local-name()='project']/*[local-name()='properties']"
+ "/*[local-name()='spring-loaded.version']/text()");
}
public static String getSpringVersion() {
return evaluateExpression(
"/*[local-name()='project']/*[local-name()='properties']"
+ "/*[local-name()='spring.version']/text()");
"/*[local-name()='project']/*[local-name()='properties']" + "/*[local-name()='spring.version']/text()");
}
private static String evaluateExpression(String expression) {
@@ -54,8 +51,7 @@ public final class Versions {
XPathFactory xPathFactory = XPathFactory.newInstance();
XPath xpath = xPathFactory.newXPath();
XPathExpression expr = xpath.compile(expression);
String version = expr.evaluate(
new InputSource(new FileReader("target/dependencies-pom.xml")));
String version = expr.evaluate(new InputSource(new FileReader("target/dependencies-pom.xml")));
return version;
}
catch (Exception ex) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2018 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,20 +45,16 @@ public class WarPackagingTests {
private static final String WEB_INF_LIB_PREFIX = "WEB-INF/lib/";
private static final Set<String> TOMCAT_EXPECTED_IN_WEB_INF_LIB_PROVIDED = new HashSet<String>(
Arrays.asList("spring-boot-starter-tomcat-", "tomcat-annotations",
"tomcat-embed-core-", "tomcat-embed-el-", "tomcat-embed-websocket-"));
Arrays.asList("spring-boot-starter-tomcat-", "tomcat-annotations", "tomcat-embed-core-", "tomcat-embed-el-",
"tomcat-embed-websocket-"));
private static final Set<String> JETTY_EXPECTED_IN_WEB_INF_LIB_PROVIDED = new HashSet<String>(
Arrays.asList("spring-boot-starter-jetty-", "jetty-continuation",
"jetty-util-", "javax.servlet-", "jetty-client", "jetty-io-",
"jetty-http-", "jetty-server-", "jetty-security-", "jetty-servlet-",
"jetty-servlets", "jetty-webapp-", "websocket-api",
"javax.annotation-api", "jetty-plus", "javax-websocket-server-impl-",
"apache-el", "asm-", "javax.websocket-api-", "asm-tree-",
"asm-analysis-", "asm-commons-", "websocket-common-",
"jetty-annotations-", "javax-websocket-client-impl-",
"websocket-client-", "websocket-server-", "jetty-xml-",
"websocket-servlet-"));
private static final Set<String> JETTY_EXPECTED_IN_WEB_INF_LIB_PROVIDED = new HashSet<String>(Arrays.asList(
"spring-boot-starter-jetty-", "jetty-continuation", "jetty-util-", "javax.servlet-", "jetty-client",
"jetty-io-", "jetty-http-", "jetty-server-", "jetty-security-", "jetty-servlet-", "jetty-servlets",
"jetty-webapp-", "websocket-api", "javax.annotation-api", "jetty-plus", "javax-websocket-server-impl-",
"apache-el", "asm-", "javax.websocket-api-", "asm-tree-", "asm-analysis-", "asm-commons-",
"websocket-common-", "jetty-annotations-", "javax-websocket-client-impl-", "websocket-client-",
"websocket-server-", "jetty-xml-", "websocket-servlet-"));
private static final String BOOT_VERSION = Versions.getBootVersion();
@@ -71,22 +67,18 @@ public class WarPackagingTests {
@Test
public void onlyTomcatIsPackagedInWebInfLibProvided() throws IOException {
checkWebInfEntriesForServletContainer("tomcat",
TOMCAT_EXPECTED_IN_WEB_INF_LIB_PROVIDED);
checkWebInfEntriesForServletContainer("tomcat", TOMCAT_EXPECTED_IN_WEB_INF_LIB_PROVIDED);
}
@Test
public void onlyJettyIsPackagedInWebInfLibProvided() throws IOException {
checkWebInfEntriesForServletContainer("jetty",
JETTY_EXPECTED_IN_WEB_INF_LIB_PROVIDED);
checkWebInfEntriesForServletContainer("jetty", JETTY_EXPECTED_IN_WEB_INF_LIB_PROVIDED);
}
private void checkWebInfEntriesForServletContainer(String servletContainer,
Set<String> expectedLibProvidedEntries) throws IOException {
private void checkWebInfEntriesForServletContainer(String servletContainer, Set<String> expectedLibProvidedEntries)
throws IOException {
project.newBuild().forTasks("clean", "build")
.withArguments("-PbootVersion=" + BOOT_VERSION,
"-PservletContainer=" + servletContainer)
.run();
.withArguments("-PbootVersion=" + BOOT_VERSION, "-PservletContainer=" + servletContainer).run();
JarFile war = new JarFile("target/war-packaging/build/libs/war-packaging.war");
@@ -102,8 +94,7 @@ public class WarPackagingTests {
}
}
private void checkWebInfLibProvidedEntries(JarFile war, Set<String> expectedEntries)
throws IOException {
private void checkWebInfLibProvidedEntries(JarFile war, Set<String> expectedEntries) throws IOException {
Set<String> entries = getWebInfLibProvidedEntries(war);
assertThat(entries).hasSameSizeAs(expectedEntries);
List<String> unexpectedLibProvidedEntries = new ArrayList<String>();
@@ -115,8 +106,7 @@ public class WarPackagingTests {
assertThat(unexpectedLibProvidedEntries.isEmpty());
}
private void checkWebInfLibEntries(JarFile war, Set<String> entriesOnlyInLibProvided)
throws IOException {
private void checkWebInfLibEntries(JarFile war, Set<String> entriesOnlyInLibProvided) throws IOException {
Set<String> entries = getWebInfLibEntries(war);
List<String> unexpectedLibEntries = new ArrayList<String>();
for (String entry : entries) {
@@ -152,16 +142,14 @@ public class WarPackagingTests {
}
private boolean isWebInfLibProvidedEntry(String name) {
return name.startsWith(WEB_INF_LIB_PROVIDED_PREFIX)
&& !name.equals(WEB_INF_LIB_PROVIDED_PREFIX);
return name.startsWith(WEB_INF_LIB_PROVIDED_PREFIX) && !name.equals(WEB_INF_LIB_PROVIDED_PREFIX);
}
private boolean isWebInfLibEntry(String name) {
return name.startsWith(WEB_INF_LIB_PREFIX) && !name.equals(WEB_INF_LIB_PREFIX);
}
private boolean isExpectedInWebInfLibProvided(String name,
Set<String> expectedEntries) {
private boolean isExpectedInWebInfLibProvided(String name, Set<String> expectedEntries) {
for (String expected : expectedEntries) {
if (name.startsWith(WEB_INF_LIB_PROVIDED_PREFIX + expected)) {
return true;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* * Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,8 +45,7 @@ public class StarterDependenciesIntegrationTests {
private static final String STARTER_NAME_PREFIX = "spring-boot-starter";
private static final List<String> EXCLUDED_STARTERS = Arrays
.asList("spring-boot-starter-parent");
private static final List<String> EXCLUDED_STARTERS = Arrays.asList("spring-boot-starter-parent");
private static ProjectConnection project;
@@ -62,8 +61,7 @@ public class StarterDependenciesIntegrationTests {
for (File file : new File("../../spring-boot-starters").listFiles()) {
if (file.isDirectory() && new File(file, "pom.xml").exists()) {
String name = file.getName();
if (name.startsWith(STARTER_NAME_PREFIX)
&& !EXCLUDED_STARTERS.contains(file.getName())) {
if (name.startsWith(STARTER_NAME_PREFIX) && !EXCLUDED_STARTERS.contains(file.getName())) {
starters.add(new String[] { file.getName() });
}
}
@@ -88,8 +86,8 @@ public class StarterDependenciesIntegrationTests {
}
public StarterDependenciesIntegrationTests(String starter) {
this.buildArguments = new String[] { "-Pstarter=" + starter,
"-PbootVersion=" + bootVersion, "-PspringVersion=" + springVersion };
this.buildArguments = new String[] { "-Pstarter=" + starter, "-PbootVersion=" + bootVersion,
"-PspringVersion=" + springVersion };
}
@Test