Merge branch '2.0.x' into 2.1.x
Closes gh-17078
This commit is contained in:
@@ -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.
|
||||
@@ -32,8 +32,7 @@ public class BootRunApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int i = 1;
|
||||
for (String entry : ManagementFactory.getRuntimeMXBean().getClassPath()
|
||||
.split(File.pathSeparator)) {
|
||||
for (String entry : ManagementFactory.getRuntimeMXBean().getClassPath().split(File.pathSeparator)) {
|
||||
System.out.println(i++ + ". " + entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -40,8 +40,7 @@ public class GettingStartedDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void typicalPluginsAppliesExceptedPlugins() {
|
||||
this.gradleBuild.script("src/main/gradle/getting-started/typical-plugins")
|
||||
.build("verify");
|
||||
this.gradleBuild.script("src/main/gradle/getting-started/typical-plugins").build("verify");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -44,20 +44,16 @@ public class IntegratingWithActuatorDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void basicBuildInfo() throws IOException {
|
||||
this.gradleBuild
|
||||
.script("src/main/gradle/integrating-with-actuator/build-info-basic")
|
||||
.build("bootBuildInfo");
|
||||
assertThat(new File(this.gradleBuild.getProjectDir(),
|
||||
"build/resources/main/META-INF/build-info.properties")).isFile();
|
||||
this.gradleBuild.script("src/main/gradle/integrating-with-actuator/build-info-basic").build("bootBuildInfo");
|
||||
assertThat(new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties"))
|
||||
.isFile();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildInfoCustomValues() throws IOException {
|
||||
this.gradleBuild.script(
|
||||
"src/main/gradle/integrating-with-actuator/build-info-custom-values")
|
||||
this.gradleBuild.script("src/main/gradle/integrating-with-actuator/build-info-custom-values")
|
||||
.build("bootBuildInfo");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/resources/main/META-INF/build-info.properties");
|
||||
File file = new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties");
|
||||
assertThat(file).isFile();
|
||||
Properties properties = buildInfoProperties(file);
|
||||
assertThat(properties).containsEntry("build.artifact", "example-app");
|
||||
@@ -68,11 +64,9 @@ public class IntegratingWithActuatorDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void buildInfoAdditional() throws IOException {
|
||||
this.gradleBuild
|
||||
.script("src/main/gradle/integrating-with-actuator/build-info-additional")
|
||||
this.gradleBuild.script("src/main/gradle/integrating-with-actuator/build-info-additional")
|
||||
.build("bootBuildInfo");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/resources/main/META-INF/build-info.properties");
|
||||
File file = new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties");
|
||||
assertThat(file).isFile();
|
||||
Properties properties = buildInfoProperties(file);
|
||||
assertThat(properties).containsEntry("build.a", "alpha");
|
||||
|
||||
@@ -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.
|
||||
@@ -41,32 +41,26 @@ public class ManagingDependenciesDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void dependenciesExampleEvaluatesSuccessfully() {
|
||||
this.gradleBuild.script("src/main/gradle/managing-dependencies/dependencies")
|
||||
.build();
|
||||
this.gradleBuild.script("src/main/gradle/managing-dependencies/dependencies").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customManagedVersions() {
|
||||
assertThat(this.gradleBuild
|
||||
.script("src/main/gradle/managing-dependencies/custom-version")
|
||||
.build("slf4jVersion").getOutput()).contains("1.7.20");
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/managing-dependencies/custom-version").build("slf4jVersion")
|
||||
.getOutput()).contains("1.7.20");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dependencyManagementInIsolation() {
|
||||
assertThat(this.gradleBuild
|
||||
.script("src/main/gradle/managing-dependencies/configure-bom")
|
||||
.build("dependencyManagement").getOutput())
|
||||
.contains("org.springframework.boot:spring-boot-starter ");
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/managing-dependencies/configure-bom")
|
||||
.build("dependencyManagement").getOutput()).contains("org.springframework.boot:spring-boot-starter ");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dependencyManagementInIsolationWithPluginsBlock() {
|
||||
Assume.assumeTrue(this.gradleBuild.getDsl() == Dsl.KOTLIN);
|
||||
assertThat(this.gradleBuild.script(
|
||||
"src/main/gradle/managing-dependencies/configure-bom-with-plugins")
|
||||
.build("dependencyManagement").getOutput())
|
||||
.contains("org.springframework.boot:spring-boot-starter ");
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/managing-dependencies/configure-bom-with-plugins")
|
||||
.build("dependencyManagement").getOutput()).contains("org.springframework.boot:spring-boot-starter ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,14 +54,12 @@ public class PackagingDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void warContainerDependencyEvaluatesSuccessfully() {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/war-container-dependency")
|
||||
.build();
|
||||
this.gradleBuild.script("src/main/gradle/packaging/war-container-dependency").build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bootJarMainClass() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-main-class")
|
||||
.build("bootJar");
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-main-class").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
@@ -73,8 +71,7 @@ public class PackagingDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void bootJarManifestMainClass() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-manifest-main-class")
|
||||
.build("bootJar");
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-manifest-main-class").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
@@ -86,8 +83,7 @@ public class PackagingDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void applicationPluginMainClass() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/application-plugin-main-class")
|
||||
.build("bootJar");
|
||||
this.gradleBuild.script("src/main/gradle/packaging/application-plugin-main-class").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
@@ -99,8 +95,7 @@ public class PackagingDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void springBootDslMainClass() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/spring-boot-dsl-main-class")
|
||||
.build("bootJar");
|
||||
this.gradleBuild.script("src/main/gradle/packaging/spring-boot-dsl-main-class").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
@@ -112,23 +107,19 @@ public class PackagingDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void bootWarIncludeDevtools() throws IOException {
|
||||
jarFile(new File(this.gradleBuild.getProjectDir(),
|
||||
"spring-boot-devtools-1.2.3.RELEASE.jar"));
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-war-include-devtools")
|
||||
.build("bootWar");
|
||||
jarFile(new File(this.gradleBuild.getProjectDir(), "spring-boot-devtools-1.2.3.RELEASE.jar"));
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-war-include-devtools").build("bootWar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".war");
|
||||
assertThat(file).isFile();
|
||||
try (JarFile jar = new JarFile(file)) {
|
||||
assertThat(jar.getEntry("WEB-INF/lib/spring-boot-devtools-1.2.3.RELEASE.jar"))
|
||||
.isNotNull();
|
||||
assertThat(jar.getEntry("WEB-INF/lib/spring-boot-devtools-1.2.3.RELEASE.jar")).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bootJarRequiresUnpack() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-requires-unpack")
|
||||
.build("bootJar");
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-requires-unpack").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
@@ -141,36 +132,28 @@ public class PackagingDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void bootJarIncludeLaunchScript() throws IOException {
|
||||
this.gradleBuild
|
||||
.script("src/main/gradle/packaging/boot-jar-include-launch-script")
|
||||
.build("bootJar");
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-include-launch-script").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
assertThat(FileCopyUtils.copyToString(new FileReader(file)))
|
||||
.startsWith("#!/bin/bash");
|
||||
assertThat(FileCopyUtils.copyToString(new FileReader(file))).startsWith("#!/bin/bash");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bootJarLaunchScriptProperties() throws IOException {
|
||||
this.gradleBuild
|
||||
.script("src/main/gradle/packaging/boot-jar-launch-script-properties")
|
||||
.build("bootJar");
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-launch-script-properties").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
assertThat(FileCopyUtils.copyToString(new FileReader(file)))
|
||||
.contains("example-app.log");
|
||||
assertThat(FileCopyUtils.copyToString(new FileReader(file))).contains("example-app.log");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bootJarCustomLaunchScript() throws IOException {
|
||||
File customScriptFile = new File(this.gradleBuild.getProjectDir(),
|
||||
"src/custom.script");
|
||||
File customScriptFile = new File(this.gradleBuild.getProjectDir(), "src/custom.script");
|
||||
customScriptFile.getParentFile().mkdirs();
|
||||
FileCopyUtils.copy("custom", new FileWriter(customScriptFile));
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-custom-launch-script")
|
||||
.build("bootJar");
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-custom-launch-script").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
@@ -179,8 +162,7 @@ public class PackagingDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void bootWarPropertiesLauncher() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-war-properties-launcher")
|
||||
.build("bootWar");
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-war-properties-launcher").build("bootWar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".war");
|
||||
assertThat(file).isFile();
|
||||
@@ -192,8 +174,7 @@ public class PackagingDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void bootJarAndJar() {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-and-jar")
|
||||
.build("assemble");
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-and-jar").build("assemble");
|
||||
File jar = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(jar).isFile();
|
||||
|
||||
@@ -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.
|
||||
@@ -41,17 +41,14 @@ public class PublishingDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void mavenUpload() throws IOException {
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/publishing/maven")
|
||||
.build("deployerRepository").getOutput())
|
||||
.contains("https://repo.example.com");
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/publishing/maven").build("deployerRepository").getOutput())
|
||||
.contains("https://repo.example.com");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mavenPublish() throws IOException {
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/publishing/maven-publish")
|
||||
.build("publishingConfiguration").getOutput())
|
||||
.contains("MavenPublication")
|
||||
.contains("https://repo.example.com");
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/publishing/maven-publish").build("publishingConfiguration")
|
||||
.getOutput()).contains("MavenPublication").contains("https://repo.example.com");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -42,33 +42,26 @@ public class RunningDocumentationTests {
|
||||
|
||||
@Test
|
||||
public void bootRunMain() throws IOException {
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/running/boot-run-main")
|
||||
.build("configuredMainClass").getOutput())
|
||||
.contains("com.example.ExampleApplication");
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/running/boot-run-main").build("configuredMainClass")
|
||||
.getOutput()).contains("com.example.ExampleApplication");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applicationPluginMainClassName() {
|
||||
assertThat(this.gradleBuild
|
||||
.script("src/main/gradle/running/application-plugin-main-class-name")
|
||||
.build("configuredMainClass").getOutput())
|
||||
.contains("com.example.ExampleApplication");
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/running/application-plugin-main-class-name")
|
||||
.build("configuredMainClass").getOutput()).contains("com.example.ExampleApplication");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springBootDslMainClassName() throws IOException {
|
||||
assertThat(this.gradleBuild
|
||||
.script("src/main/gradle/running/spring-boot-dsl-main-class-name")
|
||||
.build("configuredMainClass").getOutput())
|
||||
.contains("com.example.ExampleApplication");
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/running/spring-boot-dsl-main-class-name")
|
||||
.build("configuredMainClass").getOutput()).contains("com.example.ExampleApplication");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bootRunSourceResources() throws IOException {
|
||||
assertThat(this.gradleBuild
|
||||
.script("src/main/gradle/running/boot-run-source-resources")
|
||||
.build("configuredClasspath").getOutput())
|
||||
.contains(new File("src/main/resources").getPath());
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/running/boot-run-source-resources")
|
||||
.build("configuredClasspath").getOutput()).contains(new File("src/main/resources").getPath());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -43,24 +43,21 @@ public class BuildInfoDslIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void basicJar() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace")
|
||||
.task(":bootBuildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties properties = buildInfoProperties();
|
||||
assertThat(properties).containsEntry("build.name",
|
||||
this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.artifact",
|
||||
this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.artifact", this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.group", "com.example");
|
||||
assertThat(properties).containsEntry("build.version", "1.0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jarWithCustomName() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace")
|
||||
.task(":bootBuildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties properties = buildInfoProperties();
|
||||
assertThat(properties).containsEntry("build.name",
|
||||
this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.artifact", "foo");
|
||||
assertThat(properties).containsEntry("build.group", "com.example");
|
||||
assertThat(properties).containsEntry("build.version", "1.0");
|
||||
@@ -68,24 +65,21 @@ public class BuildInfoDslIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void basicWar() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace")
|
||||
.task(":bootBuildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties properties = buildInfoProperties();
|
||||
assertThat(properties).containsEntry("build.name",
|
||||
this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.artifact",
|
||||
this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.artifact", this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.group", "com.example");
|
||||
assertThat(properties).containsEntry("build.version", "1.0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void warWithCustomName() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace")
|
||||
.task(":bootBuildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties properties = buildInfoProperties();
|
||||
assertThat(properties).containsEntry("build.name",
|
||||
this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.artifact", "foo");
|
||||
assertThat(properties).containsEntry("build.group", "com.example");
|
||||
assertThat(properties).containsEntry("build.version", "1.0");
|
||||
@@ -93,13 +87,11 @@ public class BuildInfoDslIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void additionalProperties() throws IOException {
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace")
|
||||
.task(":bootBuildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties properties = buildInfoProperties();
|
||||
assertThat(properties).containsEntry("build.name",
|
||||
this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.artifact",
|
||||
this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.artifact", this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(properties).containsEntry("build.group", "com.example");
|
||||
assertThat(properties).containsEntry("build.version", "1.0");
|
||||
assertThat(properties).containsEntry("build.a", "alpha");
|
||||
@@ -108,13 +100,12 @@ public class BuildInfoDslIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void classesDependency() throws IOException {
|
||||
assertThat(this.gradleBuild.build("classes", "--stacktrace")
|
||||
.task(":bootBuildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("classes", "--stacktrace").task(":bootBuildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
private Properties buildInfoProperties() {
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/resources/main/META-INF/build-info.properties");
|
||||
File file = new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties");
|
||||
assertThat(file).isFile();
|
||||
Properties properties = new Properties();
|
||||
try (FileReader reader = new FileReader(file)) {
|
||||
|
||||
@@ -38,9 +38,8 @@ import org.springframework.boot.gradle.testkit.GradleBuild;
|
||||
*/
|
||||
public final class GradleCompatibilitySuite extends Suite {
|
||||
|
||||
private static final List<String> GRADLE_VERSIONS = Arrays.asList("default", "4.5.1",
|
||||
"4.6", "4.7", "4.8.1", "4.9", "4.10.3", "5.0", "5.1.1", "5.2.1", "5.3.1",
|
||||
"5.4.1");
|
||||
private static final List<String> GRADLE_VERSIONS = Arrays.asList("default", "4.5.1", "4.6", "4.7", "4.8.1", "4.9",
|
||||
"4.10.3", "5.0", "5.1.1", "5.2.1", "5.3.1", "5.4.1");
|
||||
|
||||
public GradleCompatibilitySuite(Class<?> clazz) throws InitializationError {
|
||||
super(clazz, createRunners(clazz));
|
||||
@@ -54,13 +53,11 @@ public final class GradleCompatibilitySuite extends Suite {
|
||||
return runners;
|
||||
}
|
||||
|
||||
private static final class GradleCompatibilityClassRunner
|
||||
extends BlockJUnit4ClassRunner {
|
||||
private static final class GradleCompatibilityClassRunner extends BlockJUnit4ClassRunner {
|
||||
|
||||
private final String gradleVersion;
|
||||
|
||||
private GradleCompatibilityClassRunner(Class<?> klass, String gradleVersion)
|
||||
throws InitializationError {
|
||||
private GradleCompatibilityClassRunner(Class<?> klass, String gradleVersion) throws InitializationError {
|
||||
super(klass);
|
||||
this.gradleVersion = gradleVersion;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -54,8 +54,7 @@ public final class GradleMultiDslSuite extends Suite {
|
||||
|
||||
private final GradleBuild gradleBuild;
|
||||
|
||||
private GradleDslClassRunner(Class<?> klass, GradleBuild gradleBuild)
|
||||
throws InitializationError {
|
||||
private GradleDslClassRunner(Class<?> klass, GradleBuild gradleBuild) throws InitializationError {
|
||||
super(klass);
|
||||
this.gradleBuild = gradleBuild;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -51,120 +51,100 @@ public class ApplicationPluginActionIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void noBootDistributionWithoutApplicationPluginApplied() {
|
||||
assertThat(this.gradleBuild.build("distributionExists", "-PdistributionName=boot")
|
||||
.getOutput()).contains("boot exists = false");
|
||||
assertThat(this.gradleBuild.build("distributionExists", "-PdistributionName=boot").getOutput())
|
||||
.contains("boot exists = false");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applyingApplicationPluginCreatesBootDistribution() {
|
||||
assertThat(this.gradleBuild.build("distributionExists", "-PdistributionName=boot",
|
||||
"-PapplyApplicationPlugin").getOutput()).contains("boot exists = true");
|
||||
assertThat(this.gradleBuild.build("distributionExists", "-PdistributionName=boot", "-PapplyApplicationPlugin")
|
||||
.getOutput()).contains("boot exists = true");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noBootStartScriptsTaskWithoutApplicationPluginApplied() {
|
||||
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=bootStartScripts")
|
||||
.getOutput()).contains("bootStartScripts exists = false");
|
||||
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=bootStartScripts").getOutput())
|
||||
.contains("bootStartScripts exists = false");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applyingApplicationPluginCreatesBootStartScriptsTask() {
|
||||
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=bootStartScripts",
|
||||
"-PapplyApplicationPlugin").getOutput())
|
||||
.contains("bootStartScripts exists = true");
|
||||
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=bootStartScripts", "-PapplyApplicationPlugin")
|
||||
.getOutput()).contains("bootStartScripts exists = true");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createsBootStartScriptsTaskUsesApplicationPluginsDefaultJvmOpts() {
|
||||
assertThat(this.gradleBuild
|
||||
.build("startScriptsDefaultJvmOpts", "-PapplyApplicationPlugin")
|
||||
.getOutput()).contains(
|
||||
"bootStartScripts defaultJvmOpts = [-Dcom.example.a=alpha, -Dcom.example.b=bravo]");
|
||||
assertThat(this.gradleBuild.build("startScriptsDefaultJvmOpts", "-PapplyApplicationPlugin").getOutput())
|
||||
.contains("bootStartScripts defaultJvmOpts = [-Dcom.example.a=alpha, -Dcom.example.b=bravo]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zipDistributionForJarCanBeBuilt() throws IOException {
|
||||
assertThat(
|
||||
this.gradleBuild.build("bootDistZip").task(":bootDistZip").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("bootDistZip").task(":bootDistZip").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
String name = this.gradleBuild.getProjectDir().getName();
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/distributions/" + name + "-boot.zip");
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/" + name + "-boot.zip");
|
||||
assertThat(distribution).isFile();
|
||||
assertThat(zipEntryNames(distribution)).containsExactlyInAnyOrder(name + "-boot/",
|
||||
name + "-boot/lib/", name + "-boot/lib/" + name + ".jar",
|
||||
name + "-boot/bin/", name + "-boot/bin/" + name,
|
||||
assertThat(zipEntryNames(distribution)).containsExactlyInAnyOrder(name + "-boot/", name + "-boot/lib/",
|
||||
name + "-boot/lib/" + name + ".jar", name + "-boot/bin/", name + "-boot/bin/" + name,
|
||||
name + "-boot/bin/" + name + ".bat");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tarDistributionForJarCanBeBuilt() throws IOException {
|
||||
assertThat(
|
||||
this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
String name = this.gradleBuild.getProjectDir().getName();
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/distributions/" + name + "-boot.tar");
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/" + name + "-boot.tar");
|
||||
assertThat(distribution).isFile();
|
||||
assertThat(tarEntryNames(distribution)).containsExactlyInAnyOrder(name + "-boot/",
|
||||
name + "-boot/lib/", name + "-boot/lib/" + name + ".jar",
|
||||
name + "-boot/bin/", name + "-boot/bin/" + name,
|
||||
assertThat(tarEntryNames(distribution)).containsExactlyInAnyOrder(name + "-boot/", name + "-boot/lib/",
|
||||
name + "-boot/lib/" + name + ".jar", name + "-boot/bin/", name + "-boot/bin/" + name,
|
||||
name + "-boot/bin/" + name + ".bat");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zipDistributionForWarCanBeBuilt() throws IOException {
|
||||
assertThat(
|
||||
this.gradleBuild.build("bootDistZip").task(":bootDistZip").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("bootDistZip").task(":bootDistZip").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
String name = this.gradleBuild.getProjectDir().getName();
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/distributions/" + name + "-boot.zip");
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/" + name + "-boot.zip");
|
||||
assertThat(distribution).isFile();
|
||||
assertThat(zipEntryNames(distribution)).containsExactlyInAnyOrder(name + "-boot/",
|
||||
name + "-boot/lib/", name + "-boot/lib/" + name + ".war",
|
||||
name + "-boot/bin/", name + "-boot/bin/" + name,
|
||||
assertThat(zipEntryNames(distribution)).containsExactlyInAnyOrder(name + "-boot/", name + "-boot/lib/",
|
||||
name + "-boot/lib/" + name + ".war", name + "-boot/bin/", name + "-boot/bin/" + name,
|
||||
name + "-boot/bin/" + name + ".bat");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void tarDistributionForWarCanBeBuilt() throws IOException {
|
||||
assertThat(
|
||||
this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
String name = this.gradleBuild.getProjectDir().getName();
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/distributions/" + name + "-boot.tar");
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/" + name + "-boot.tar");
|
||||
assertThat(distribution).isFile();
|
||||
assertThat(tarEntryNames(distribution)).containsExactlyInAnyOrder(name + "-boot/",
|
||||
name + "-boot/lib/", name + "-boot/lib/" + name + ".war",
|
||||
name + "-boot/bin/", name + "-boot/bin/" + name,
|
||||
assertThat(tarEntryNames(distribution)).containsExactlyInAnyOrder(name + "-boot/", name + "-boot/lib/",
|
||||
name + "-boot/lib/" + name + ".war", name + "-boot/bin/", name + "-boot/bin/" + name,
|
||||
name + "-boot/bin/" + name + ".bat");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applicationNameCanBeUsedToCustomizeDistributionName() throws IOException {
|
||||
assertThat(
|
||||
this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/distributions/custom-boot.tar");
|
||||
assertThat(this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/custom-boot.tar");
|
||||
assertThat(distribution).isFile();
|
||||
String name = this.gradleBuild.getProjectDir().getName();
|
||||
assertThat(tarEntryNames(distribution)).containsExactlyInAnyOrder("custom-boot/",
|
||||
"custom-boot/lib/", "custom-boot/lib/" + name + ".jar",
|
||||
"custom-boot/bin/", "custom-boot/bin/custom",
|
||||
assertThat(tarEntryNames(distribution)).containsExactlyInAnyOrder("custom-boot/", "custom-boot/lib/",
|
||||
"custom-boot/lib/" + name + ".jar", "custom-boot/bin/", "custom-boot/bin/custom",
|
||||
"custom-boot/bin/custom.bat");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scriptsHaveCorrectPermissions() throws IOException {
|
||||
assertThat(
|
||||
this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
String name = this.gradleBuild.getProjectDir().getName();
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/distributions/" + name + "-boot.tar");
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(), "build/distributions/" + name + "-boot.tar");
|
||||
assertThat(distribution).isFile();
|
||||
tarEntries(distribution, (entry) -> {
|
||||
int filePermissions = entry.getMode() & 0777;
|
||||
@@ -190,8 +170,7 @@ public class ApplicationPluginActionIntegrationTests {
|
||||
|
||||
private List<String> tarEntryNames(File distribution) throws IOException {
|
||||
List<String> entryNames = new ArrayList<>();
|
||||
try (TarArchiveInputStream input = new TarArchiveInputStream(
|
||||
new FileInputStream(distribution))) {
|
||||
try (TarArchiveInputStream input = new TarArchiveInputStream(new FileInputStream(distribution))) {
|
||||
TarArchiveEntry entry;
|
||||
while ((entry = input.getNextTarEntry()) != null) {
|
||||
entryNames.add(entry.getName());
|
||||
@@ -200,10 +179,8 @@ public class ApplicationPluginActionIntegrationTests {
|
||||
return entryNames;
|
||||
}
|
||||
|
||||
private void tarEntries(File distribution, Consumer<TarArchiveEntry> consumer)
|
||||
throws IOException {
|
||||
try (TarArchiveInputStream input = new TarArchiveInputStream(
|
||||
new FileInputStream(distribution))) {
|
||||
private void tarEntries(File distribution, Consumer<TarArchiveEntry> consumer) throws IOException {
|
||||
try (TarArchiveInputStream input = new TarArchiveInputStream(new FileInputStream(distribution))) {
|
||||
TarArchiveEntry entry;
|
||||
while ((entry = input.getNextTarEntry()) != null) {
|
||||
consumer.accept(entry);
|
||||
|
||||
@@ -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,35 +45,28 @@ public class DependencyManagementPluginActionIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void noDependencyManagementIsAppliedByDefault() {
|
||||
assertThat(this.gradleBuild.build("doesNotHaveDependencyManagement")
|
||||
.task(":doesNotHaveDependencyManagement").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("doesNotHaveDependencyManagement").task(":doesNotHaveDependencyManagement")
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bomIsImportedWhenDependencyManagementPluginIsApplied() {
|
||||
assertThat(this.gradleBuild
|
||||
.build("hasDependencyManagement", "-PapplyDependencyManagementPlugin")
|
||||
.task(":hasDependencyManagement").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("hasDependencyManagement", "-PapplyDependencyManagementPlugin")
|
||||
.task(":hasDependencyManagement").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void helpfulErrorWhenVersionlessDependencyFailsToResolve() throws IOException {
|
||||
File examplePackage = new File(this.gradleBuild.getProjectDir(),
|
||||
"src/main/java/com/example");
|
||||
File examplePackage = new File(this.gradleBuild.getProjectDir(), "src/main/java/com/example");
|
||||
examplePackage.mkdirs();
|
||||
FileSystemUtils.copyRecursively(new File("src/test/java/com/example"),
|
||||
examplePackage);
|
||||
FileSystemUtils.copyRecursively(new File("src/test/java/com/example"), examplePackage);
|
||||
BuildResult result = this.gradleBuild.buildAndFail("compileJava");
|
||||
assertThat(result.task(":compileJava").getOutcome())
|
||||
.isEqualTo(TaskOutcome.FAILED);
|
||||
assertThat(result.task(":compileJava").getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
String output = result.getOutput();
|
||||
assertThat(output).contains("During the build, one or more dependencies that "
|
||||
+ "were declared without a version failed to resolve:");
|
||||
assertThat(output).contains("org.springframework.boot:spring-boot-starter-web:");
|
||||
assertThat(output).contains("Did you forget to apply the "
|
||||
+ "io.spring.dependency-management plugin to the "
|
||||
assertThat(output).contains("Did you forget to apply the " + "io.spring.dependency-management plugin to the "
|
||||
+ this.gradleBuild.getProjectDir().getName() + " project?");
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -51,9 +51,8 @@ public class JavaPluginActionIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void applyingJavaPluginCreatesBootJarTask() {
|
||||
assertThat(this.gradleBuild
|
||||
.build("taskExists", "-PtaskName=bootJar", "-PapplyJavaPlugin")
|
||||
.getOutput()).contains("bootJar exists = true");
|
||||
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=bootJar", "-PapplyJavaPlugin").getOutput())
|
||||
.contains("bootJar exists = true");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -64,16 +63,14 @@ public class JavaPluginActionIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void applyingJavaPluginCreatesBootRunTask() {
|
||||
assertThat(this.gradleBuild
|
||||
.build("taskExists", "-PtaskName=bootRun", "-PapplyJavaPlugin")
|
||||
.getOutput()).contains("bootRun exists = true");
|
||||
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=bootRun", "-PapplyJavaPlugin").getOutput())
|
||||
.contains("bootRun exists = true");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void javaCompileTasksUseUtf8Encoding() {
|
||||
assertThat(this.gradleBuild.build("javaCompileEncoding", "-PapplyJavaPlugin")
|
||||
.getOutput()).contains("compileJava = UTF-8")
|
||||
.contains("compileTestJava = UTF-8");
|
||||
assertThat(this.gradleBuild.build("javaCompileEncoding", "-PapplyJavaPlugin").getOutput())
|
||||
.contains("compileJava = UTF-8").contains("compileTestJava = UTF-8");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,8 +105,7 @@ public class JavaPluginActionIntegrationTests {
|
||||
public void errorMessageIsHelpfulWhenMainClassCannotBeResolved() {
|
||||
BuildResult result = this.gradleBuild.buildAndFail("build", "-PapplyJavaPlugin");
|
||||
assertThat(result.task(":bootJar").getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
assertThat(result.getOutput()).contains(
|
||||
"Main class name has not been configured and it could not be resolved");
|
||||
assertThat(result.getOutput()).contains("Main class name has not been configured and it could not be resolved");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,42 +116,33 @@ public class JavaPluginActionIntegrationTests {
|
||||
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
|
||||
assertThat(buildLibs.listFiles()).containsExactlyInAnyOrder(
|
||||
new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".jar"),
|
||||
new File(buildLibs,
|
||||
this.gradleBuild.getProjectDir().getName() + "-boot.jar"));
|
||||
new File(buildLibs, this.gradleBuild.getProjectDir().getName() + "-boot.jar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void additionalMetadataLocationsConfiguredWhenProcessorIsPresent()
|
||||
throws IOException {
|
||||
public void additionalMetadataLocationsConfiguredWhenProcessorIsPresent() throws IOException {
|
||||
createMinimalMainSource();
|
||||
File libs = new File(this.gradleBuild.getProjectDir(), "libs");
|
||||
libs.mkdirs();
|
||||
new JarOutputStream(new FileOutputStream(
|
||||
new File(libs, "spring-boot-configuration-processor-1.2.3.jar"))).close();
|
||||
new JarOutputStream(new FileOutputStream(new File(libs, "spring-boot-configuration-processor-1.2.3.jar")))
|
||||
.close();
|
||||
BuildResult result = this.gradleBuild.build("compileJava");
|
||||
assertThat(result.task(":compileJava").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains(
|
||||
"compileJava compiler args: [-parameters, -Aorg.springframework.boot."
|
||||
+ "configurationprocessor.additionalMetadataLocations="
|
||||
+ new File(this.gradleBuild.getProjectDir(), "src/main/resources")
|
||||
.getCanonicalPath());
|
||||
assertThat(result.task(":compileJava").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("compileJava compiler args: [-parameters, -Aorg.springframework.boot."
|
||||
+ "configurationprocessor.additionalMetadataLocations="
|
||||
+ new File(this.gradleBuild.getProjectDir(), "src/main/resources").getCanonicalPath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void additionalMetadataLocationsNotConfiguredWhenProcessorIsAbsent()
|
||||
throws IOException {
|
||||
public void additionalMetadataLocationsNotConfiguredWhenProcessorIsAbsent() throws IOException {
|
||||
createMinimalMainSource();
|
||||
BuildResult result = this.gradleBuild.build("compileJava");
|
||||
assertThat(result.task(":compileJava").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput())
|
||||
.contains("compileJava compiler args: [-parameters]");
|
||||
assertThat(result.task(":compileJava").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("compileJava compiler args: [-parameters]");
|
||||
}
|
||||
|
||||
private void createMinimalMainSource() throws IOException {
|
||||
File examplePackage = new File(this.gradleBuild.getProjectDir(),
|
||||
"src/main/java/com/example");
|
||||
File examplePackage = new File(this.gradleBuild.getProjectDir(), "src/main/java/com/example");
|
||||
examplePackage.mkdirs();
|
||||
new File(examplePackage, "Application.java").createNewFile();
|
||||
}
|
||||
|
||||
@@ -38,29 +38,26 @@ public class KotlinPluginActionIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void noKotlinVersionPropertyWithoutKotlinPlugin() {
|
||||
assertThat(this.gradleBuild.build("kotlinVersion").getOutput())
|
||||
.contains("Kotlin version: none");
|
||||
assertThat(this.gradleBuild.build("kotlinVersion").getOutput()).contains("Kotlin version: none");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void kotlinVersionPropertyIsSet() {
|
||||
String output = this.gradleBuild.build("kotlinVersion", "dependencies",
|
||||
"--configuration", "compileClasspath").getOutput();
|
||||
String output = this.gradleBuild.build("kotlinVersion", "dependencies", "--configuration", "compileClasspath")
|
||||
.getOutput();
|
||||
assertThat(output).containsPattern("Kotlin version: [0-9]\\.[0-9]\\.[0-9]+");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void kotlinCompileTasksUseJavaParametersFlagByDefault() {
|
||||
assertThat(this.gradleBuild.build("kotlinCompileTasksJavaParameters").getOutput())
|
||||
.contains("compileKotlin java parameters: true")
|
||||
.contains("compileTestKotlin java parameters: true");
|
||||
.contains("compileKotlin java parameters: true").contains("compileTestKotlin java parameters: true");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void kotlinCompileTasksCanOverrideDefaultJavaParametersFlag() {
|
||||
assertThat(this.gradleBuild.build("kotlinCompileTasksJavaParameters").getOutput())
|
||||
.contains("compileKotlin java parameters: false")
|
||||
.contains("compileTestKotlin java parameters: false");
|
||||
.contains("compileKotlin java parameters: false").contains("compileTestKotlin java parameters: false");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -41,36 +41,33 @@ public class MainClassConventionTests {
|
||||
|
||||
@Before
|
||||
public void createConvention() throws IOException {
|
||||
this.project = ProjectBuilder.builder().withProjectDir(this.temp.newFolder())
|
||||
.build();
|
||||
this.project = ProjectBuilder.builder().withProjectDir(this.temp.newFolder()).build();
|
||||
this.convention = new MainClassConvention(this.project, () -> null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mainClassNameProjectPropertyIsUsed() throws Exception {
|
||||
this.project.getExtensions().getByType(ExtraPropertiesExtension.class)
|
||||
.set("mainClassName", "com.example.MainClass");
|
||||
this.project.getExtensions().getByType(ExtraPropertiesExtension.class).set("mainClassName",
|
||||
"com.example.MainClass");
|
||||
assertThat(this.convention.call()).isEqualTo("com.example.MainClass");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springBootExtensionMainClassNameIsUsed() throws Exception {
|
||||
SpringBootExtension extension = this.project.getExtensions().create("springBoot",
|
||||
SpringBootExtension.class, this.project);
|
||||
SpringBootExtension extension = this.project.getExtensions().create("springBoot", SpringBootExtension.class,
|
||||
this.project);
|
||||
extension.setMainClassName("com.example.MainClass");
|
||||
assertThat(this.convention.call()).isEqualTo("com.example.MainClass");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springBootExtensionMainClassNameIsUsedInPreferenceToMainClassNameProjectProperty()
|
||||
throws Exception {
|
||||
this.project.getExtensions().getByType(ExtraPropertiesExtension.class)
|
||||
.set("mainClassName", "com.example.ProjectPropertyMainClass");
|
||||
SpringBootExtension extension = this.project.getExtensions().create("springBoot",
|
||||
SpringBootExtension.class, this.project);
|
||||
public void springBootExtensionMainClassNameIsUsedInPreferenceToMainClassNameProjectProperty() throws Exception {
|
||||
this.project.getExtensions().getByType(ExtraPropertiesExtension.class).set("mainClassName",
|
||||
"com.example.ProjectPropertyMainClass");
|
||||
SpringBootExtension extension = this.project.getExtensions().create("springBoot", SpringBootExtension.class,
|
||||
this.project);
|
||||
extension.setMainClassName("com.example.SpringBootExtensionMainClass");
|
||||
assertThat(this.convention.call())
|
||||
.isEqualTo("com.example.SpringBootExtensionMainClass");
|
||||
assertThat(this.convention.call()).isEqualTo("com.example.SpringBootExtensionMainClass");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -38,8 +38,7 @@ public class MavenPluginActionIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void clearsConf2ScopeMappingsOfUploadBootArchivesTask() {
|
||||
assertThat(this.gradleBuild.build("conf2ScopeMappings").getOutput())
|
||||
.contains("Conf2ScopeMappings = 0");
|
||||
assertThat(this.gradleBuild.build("conf2ScopeMappings").getOutput()).contains("Conf2ScopeMappings = 0");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -40,8 +40,8 @@ public class SpringBootPluginIntegrationTests {
|
||||
@Test
|
||||
public void failFastWithVersionOfGradleLowerThanRequired() {
|
||||
BuildResult result = this.gradleBuild.gradleVersion("4.3").buildAndFail();
|
||||
assertThat(result.getOutput()).contains("Spring Boot plugin requires Gradle 4.4"
|
||||
+ " or later. The current version is Gradle 4.3");
|
||||
assertThat(result.getOutput())
|
||||
.contains("Spring Boot plugin requires Gradle 4.4" + " or later. The current version is Gradle 4.3");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -55,19 +55,17 @@ public class SpringBootPluginIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unresolvedDependenciesAreAnalyzedWhenDependencyResolutionFails()
|
||||
throws IOException {
|
||||
public void unresolvedDependenciesAreAnalyzedWhenDependencyResolutionFails() throws IOException {
|
||||
createMinimalMainSource();
|
||||
BuildResult result = this.gradleBuild.buildAndFail("compileJava");
|
||||
assertThat(result.getOutput()).contains(
|
||||
"During the build, one or more dependencies that were declared without a"
|
||||
assertThat(result.getOutput())
|
||||
.contains("During the build, one or more dependencies that were declared without a"
|
||||
+ " version failed to resolve:")
|
||||
.contains(" org.springframework.boot:spring-boot-starter:");
|
||||
}
|
||||
|
||||
private void createMinimalMainSource() throws IOException {
|
||||
File examplePackage = new File(this.gradleBuild.getProjectDir(),
|
||||
"src/main/java/com/example");
|
||||
File examplePackage = new File(this.gradleBuild.getProjectDir(), "src/main/java/com/example");
|
||||
examplePackage.mkdirs();
|
||||
new File(examplePackage, "Application.java").createNewFile();
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -48,9 +48,8 @@ public class WarPluginActionIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void applyingWarPluginCreatesBootWarTask() {
|
||||
assertThat(this.gradleBuild
|
||||
.build("taskExists", "-PtaskName=bootWar", "-PapplyWarPlugin")
|
||||
.getOutput()).contains("bootWar exists = true");
|
||||
assertThat(this.gradleBuild.build("taskExists", "-PtaskName=bootWar", "-PapplyWarPlugin").getOutput())
|
||||
.contains("bootWar exists = true");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,16 +67,14 @@ public class WarPluginActionIntegrationTests {
|
||||
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
|
||||
assertThat(buildLibs.listFiles()).containsExactlyInAnyOrder(
|
||||
new File(buildLibs, this.gradleBuild.getProjectDir().getName() + ".war"),
|
||||
new File(buildLibs,
|
||||
this.gradleBuild.getProjectDir().getName() + "-boot.war"));
|
||||
new File(buildLibs, this.gradleBuild.getProjectDir().getName() + "-boot.war"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void errorMessageIsHelpfulWhenMainClassCannotBeResolved() {
|
||||
BuildResult result = this.gradleBuild.buildAndFail("build", "-PapplyWarPlugin");
|
||||
assertThat(result.task(":bootWar").getOutcome()).isEqualTo(TaskOutcome.FAILED);
|
||||
assertThat(result.getOutput()).contains(
|
||||
"Main class name has not been configured and it could not be resolved");
|
||||
assertThat(result.getOutput()).contains("Main class name has not been configured and it could not be resolved");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,21 +45,18 @@ public class BuildInfoIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void defaultValues() {
|
||||
assertThat(this.gradleBuild.build("buildInfo").task(":buildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("buildInfo").task(":buildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties buildInfoProperties = buildInfoProperties();
|
||||
assertThat(buildInfoProperties).containsKey("build.time");
|
||||
assertThat(buildInfoProperties).containsEntry("build.artifact", "unspecified");
|
||||
assertThat(buildInfoProperties).containsEntry("build.group", "");
|
||||
assertThat(buildInfoProperties).containsEntry("build.name",
|
||||
this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(buildInfoProperties).containsEntry("build.name", this.gradleBuild.getProjectDir().getName());
|
||||
assertThat(buildInfoProperties).containsEntry("build.version", "unspecified");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicExecution() {
|
||||
assertThat(this.gradleBuild.build("buildInfo").task(":buildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("buildInfo").task(":buildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
Properties buildInfoProperties = buildInfoProperties();
|
||||
assertThat(buildInfoProperties).containsKey("build.time");
|
||||
assertThat(buildInfoProperties).containsEntry("build.artifact", "foo");
|
||||
@@ -71,32 +68,28 @@ public class BuildInfoIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void notUpToDateWhenExecutedTwiceAsTimeChanges() {
|
||||
assertThat(this.gradleBuild.build("buildInfo").task(":buildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("buildInfo").task(":buildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("buildInfo").task(":buildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("buildInfo").task(":buildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void upToDateWhenExecutedTwiceWithFixedTime() {
|
||||
assertThat(this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo")
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo")
|
||||
.getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
assertThat(this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notUpToDateWhenExecutedTwiceWithFixedTimeAndChangedProjectVersion() {
|
||||
assertThat(this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo")
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildResult result = this.gradleBuild.build("buildInfo", "-PnullTime",
|
||||
"-PprojectVersion=0.2.0");
|
||||
assertThat(this.gradleBuild.build("buildInfo", "-PnullTime").task(":buildInfo").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
BuildResult result = this.gradleBuild.build("buildInfo", "-PnullTime", "-PprojectVersion=0.2.0");
|
||||
assertThat(result.task(":buildInfo").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
private Properties buildInfoProperties() {
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/build-info.properties");
|
||||
File file = new File(this.gradleBuild.getProjectDir(), "build/build-info.properties");
|
||||
assertThat(file).isFile();
|
||||
Properties properties = new Properties();
|
||||
try (FileReader reader = new FileReader(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.
|
||||
@@ -112,8 +112,7 @@ public class BuildInfoTests {
|
||||
Instant now = Instant.now();
|
||||
BuildInfo task = createTask(createProject("test"));
|
||||
task.getProperties().setTime(now);
|
||||
assertThat(buildInfoProperties(task)).containsEntry("build.time",
|
||||
DateTimeFormatter.ISO_INSTANT.format(now));
|
||||
assertThat(buildInfoProperties(task)).containsEntry("build.time", DateTimeFormatter.ISO_INSTANT.format(now));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -128,8 +127,7 @@ public class BuildInfoTests {
|
||||
private Project createProject(String projectName) {
|
||||
try {
|
||||
File projectDir = this.temp.newFolder(projectName);
|
||||
return ProjectBuilder.builder().withProjectDir(projectDir)
|
||||
.withName(projectName).build();
|
||||
return ProjectBuilder.builder().withProjectDir(projectDir).withName(projectName).build();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
@@ -142,8 +140,7 @@ public class BuildInfoTests {
|
||||
|
||||
private Properties buildInfoProperties(BuildInfo task) {
|
||||
task.generateBuildProperties();
|
||||
return buildInfoProperties(
|
||||
new File(task.getDestinationDir(), "build-info.properties"));
|
||||
return buildInfoProperties(new File(task.getDestinationDir(), "build-info.properties"));
|
||||
}
|
||||
|
||||
private Properties buildInfoProperties(File 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.
|
||||
@@ -51,80 +51,72 @@ public abstract class AbstractBootArchiveIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicBuild() throws InvalidRunnerConfigurationException,
|
||||
UnexpectedBuildFailure, IOException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
public void basicBuild() throws InvalidRunnerConfigurationException, UnexpectedBuildFailure, IOException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reproducibleArchive() throws InvalidRunnerConfigurationException,
|
||||
UnexpectedBuildFailure, IOException, InterruptedException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
File jar = new File(this.gradleBuild.getProjectDir(), "build/libs")
|
||||
.listFiles()[0];
|
||||
public void reproducibleArchive()
|
||||
throws InvalidRunnerConfigurationException, UnexpectedBuildFailure, IOException, InterruptedException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
File jar = new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0];
|
||||
String firstHash = FileUtils.sha1Hash(jar);
|
||||
Thread.sleep(1500);
|
||||
assertThat(this.gradleBuild.build("clean", this.taskName)
|
||||
.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("clean", this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
String secondHash = FileUtils.sha1Hash(jar);
|
||||
assertThat(firstHash).isEqualTo(secondHash);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void upToDateWhenBuiltTwice() throws InvalidRunnerConfigurationException,
|
||||
UnexpectedBuildFailure, IOException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
public void upToDateWhenBuiltTwice()
|
||||
throws InvalidRunnerConfigurationException, UnexpectedBuildFailure, IOException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void upToDateWhenBuiltTwiceWithLaunchScriptIncluded()
|
||||
throws InvalidRunnerConfigurationException, UnexpectedBuildFailure,
|
||||
IOException {
|
||||
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName)
|
||||
.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName)
|
||||
.task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
throws InvalidRunnerConfigurationException, UnexpectedBuildFailure, IOException {
|
||||
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName).task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName).task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notUpToDateWhenLaunchScriptWasNotIncludedAndThenIsIncluded() {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName)
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName).task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName)
|
||||
.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notUpToDateWhenLaunchScriptWasIncludedAndThenIsNotIncluded() {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName)
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName).task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName)
|
||||
.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void notUpToDateWhenLaunchScriptPropertyChanges() {
|
||||
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true",
|
||||
"-PlaunchScriptProperty=foo", this.taskName).task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true",
|
||||
"-PlaunchScriptProperty=bar", this.taskName).task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", "-PlaunchScriptProperty=foo", this.taskName)
|
||||
.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", "-PlaunchScriptProperty=bar", this.taskName)
|
||||
.task(":" + this.taskName).getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applicationPluginMainClassNameIsUsed() throws IOException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(
|
||||
new File(this.gradleBuild.getProjectDir(), "build/libs")
|
||||
.listFiles()[0])) {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class"))
|
||||
.isEqualTo("com.example.CustomMain");
|
||||
}
|
||||
@@ -132,11 +124,9 @@ public abstract class AbstractBootArchiveIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void springBootExtensionMainClassNameIsUsed() throws IOException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(
|
||||
new File(this.gradleBuild.getProjectDir(), "build/libs")
|
||||
.listFiles()[0])) {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (JarFile jarFile = new JarFile(new File(this.gradleBuild.getProjectDir(), "build/libs").listFiles()[0])) {
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class"))
|
||||
.isEqualTo("com.example.CustomMain");
|
||||
}
|
||||
@@ -144,8 +134,8 @@ public abstract class AbstractBootArchiveIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void duplicatesAreHandledGracefully() throws IOException {
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName)
|
||||
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,8 +73,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
|
||||
private T task;
|
||||
|
||||
protected AbstractBootArchiveTests(Class<T> taskClass, String launcherClass,
|
||||
String libPath, String classesPath) {
|
||||
protected AbstractBootArchiveTests(Class<T> taskClass, String launcherClass, String libPath, String classesPath) {
|
||||
this.taskClass = taskClass;
|
||||
this.launcherClass = launcherClass;
|
||||
this.libPath = libPath;
|
||||
@@ -84,12 +83,9 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
@Before
|
||||
public void createTask() {
|
||||
try {
|
||||
this.project = ProjectBuilder.builder().withProjectDir(this.temp.newFolder())
|
||||
.build();
|
||||
this.project
|
||||
.setDescription("Test project for " + this.taskClass.getSimpleName());
|
||||
this.task = configure(
|
||||
this.project.getTasks().create("testArchive", this.taskClass));
|
||||
this.project = ProjectBuilder.builder().withProjectDir(this.temp.newFolder()).build();
|
||||
this.project.setDescription("Test project for " + this.taskClass.getSimpleName());
|
||||
this.task = configure(this.project.getTasks().create("testArchive", this.taskClass));
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
@@ -102,17 +98,12 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.execute();
|
||||
assertThat(this.task.getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class"))
|
||||
.isEqualTo(this.launcherClass);
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class"))
|
||||
.isEqualTo("com.example.Main");
|
||||
assertThat(jarFile.getManifest().getMainAttributes()
|
||||
.getValue("Spring-Boot-Classes")).isEqualTo(this.classesPath);
|
||||
assertThat(
|
||||
jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Lib"))
|
||||
.isEqualTo(this.libPath);
|
||||
assertThat(jarFile.getManifest().getMainAttributes()
|
||||
.getValue("Spring-Boot-Version")).isNotNull();
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class")).isEqualTo(this.launcherClass);
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class")).isEqualTo("com.example.Main");
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Classes"))
|
||||
.isEqualTo(this.classesPath);
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Lib")).isEqualTo(this.libPath);
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Version")).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,16 +122,13 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
public void classpathFoldersArePackagedBeneathClassesPath() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
File classpathFolder = this.temp.newFolder();
|
||||
File applicationClass = new File(classpathFolder,
|
||||
"com/example/Application.class");
|
||||
File applicationClass = new File(classpathFolder, "com/example/Application.class");
|
||||
applicationClass.getParentFile().mkdirs();
|
||||
applicationClass.createNewFile();
|
||||
this.task.classpath(classpathFolder);
|
||||
this.task.execute();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(
|
||||
jarFile.getEntry(this.classesPath + "com/example/Application.class"))
|
||||
.isNotNull();
|
||||
assertThat(jarFile.getEntry(this.classesPath + "com/example/Application.class")).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,20 +139,16 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
File moduleInfoClass = new File(classpathFolder, "module-info.class");
|
||||
moduleInfoClass.getParentFile().mkdirs();
|
||||
moduleInfoClass.createNewFile();
|
||||
File applicationClass = new File(classpathFolder,
|
||||
"com/example/Application.class");
|
||||
File applicationClass = new File(classpathFolder, "com/example/Application.class");
|
||||
applicationClass.getParentFile().mkdirs();
|
||||
applicationClass.createNewFile();
|
||||
this.task.classpath(classpathFolder);
|
||||
this.task.execute();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(
|
||||
jarFile.getEntry(this.classesPath + "com/example/Application.class"))
|
||||
.isNotNull();
|
||||
assertThat(jarFile.getEntry(this.classesPath + "com/example/Application.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry("com/example/Application.class")).isNull();
|
||||
assertThat(jarFile.getEntry("module-info.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry(this.classesPath + "/module-info.class"))
|
||||
.isNull();
|
||||
assertThat(jarFile.getEntry(this.classesPath + "/module-info.class")).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,24 +191,18 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.execute();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(jarFile.getEntry(
|
||||
"org/springframework/boot/loader/LaunchedURLClassLoader.class"))
|
||||
.isNotNull();
|
||||
assertThat(jarFile.getEntry("org/springframework/boot/loader/LaunchedURLClassLoader.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry("org/springframework/boot/loader/")).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loaderIsWrittenToTheRootOfTheJarWhenUsingThePropertiesLauncher()
|
||||
throws IOException {
|
||||
public void loaderIsWrittenToTheRootOfTheJarWhenUsingThePropertiesLauncher() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.execute();
|
||||
this.task.getManifest().getAttributes().put("Main-Class",
|
||||
"org.springframework.boot.loader.PropertiesLauncher");
|
||||
this.task.getManifest().getAttributes().put("Main-Class", "org.springframework.boot.loader.PropertiesLauncher");
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(jarFile.getEntry(
|
||||
"org/springframework/boot/loader/LaunchedURLClassLoader.class"))
|
||||
.isNotNull();
|
||||
assertThat(jarFile.getEntry("org/springframework/boot/loader/LaunchedURLClassLoader.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry("org/springframework/boot/loader/")).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -236,8 +214,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.requiresUnpack("**/one.jar");
|
||||
this.task.execute();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(jarFile.getEntry(this.libPath + "one.jar").getComment())
|
||||
.startsWith("UNPACK:");
|
||||
assertThat(jarFile.getEntry(this.libPath + "one.jar").getComment()).startsWith("UNPACK:");
|
||||
assertThat(jarFile.getEntry(this.libPath + "two.jar").getComment()).isNull();
|
||||
}
|
||||
}
|
||||
@@ -249,8 +226,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.requiresUnpack((element) -> element.getName().endsWith("two.jar"));
|
||||
this.task.execute();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(jarFile.getEntry(this.libPath + "two.jar").getComment())
|
||||
.startsWith("UNPACK:");
|
||||
assertThat(jarFile.getEntry(this.libPath + "two.jar").getComment()).startsWith("UNPACK:");
|
||||
assertThat(jarFile.getEntry(this.libPath + "one.jar").getComment()).isNull();
|
||||
}
|
||||
}
|
||||
@@ -267,8 +243,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
assertThat(Files.readAllBytes(this.task.getArchivePath().toPath()))
|
||||
.startsWith(new DefaultLaunchScript(null, properties).toByteArray());
|
||||
try {
|
||||
Set<PosixFilePermission> permissions = Files
|
||||
.getPosixFilePermissions(this.task.getArchivePath().toPath());
|
||||
Set<PosixFilePermission> permissions = Files.getPosixFilePermissions(this.task.getArchivePath().toPath());
|
||||
assertThat(permissions).contains(PosixFilePermission.OWNER_EXECUTE);
|
||||
}
|
||||
catch (UnsupportedOperationException ex) {
|
||||
@@ -280,12 +255,10 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
public void customLaunchScriptCanBePrepended() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
File customScript = this.temp.newFile("custom.script");
|
||||
Files.write(customScript.toPath(), Arrays.asList("custom script"),
|
||||
StandardOpenOption.CREATE);
|
||||
Files.write(customScript.toPath(), Arrays.asList("custom script"), StandardOpenOption.CREATE);
|
||||
this.task.launchScript((configuration) -> configuration.setScript(customScript));
|
||||
this.task.execute();
|
||||
assertThat(Files.readAllBytes(this.task.getArchivePath().toPath()))
|
||||
.startsWith("custom script".getBytes());
|
||||
assertThat(Files.readAllBytes(this.task.getArchivePath().toPath())).startsWith("custom script".getBytes());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -293,46 +266,38 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.launchScript((configuration) -> {
|
||||
configuration.getProperties().put("initInfoProvides", "provides");
|
||||
configuration.getProperties().put("initInfoShortDescription",
|
||||
"short description");
|
||||
configuration.getProperties().put("initInfoShortDescription", "short description");
|
||||
configuration.getProperties().put("initInfoDescription", "description");
|
||||
});
|
||||
this.task.execute();
|
||||
byte[] bytes = Files.readAllBytes(this.task.getArchivePath().toPath());
|
||||
assertThat(bytes).containsSequence("Provides: provides".getBytes());
|
||||
assertThat(bytes)
|
||||
.containsSequence("Short-Description: short description".getBytes());
|
||||
assertThat(bytes).containsSequence("Short-Description: short description".getBytes());
|
||||
assertThat(bytes).containsSequence("Description: description".getBytes());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customMainClassInTheManifestIsHonored() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.getManifest().getAttributes().put("Main-Class",
|
||||
"com.example.CustomLauncher");
|
||||
this.task.getManifest().getAttributes().put("Main-Class", "com.example.CustomLauncher");
|
||||
this.task.execute();
|
||||
assertThat(this.task.getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class"))
|
||||
.isEqualTo("com.example.CustomLauncher");
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class"))
|
||||
.isEqualTo("com.example.Main");
|
||||
assertThat(jarFile.getEntry(
|
||||
"org/springframework/boot/loader/LaunchedURLClassLoader.class"))
|
||||
.isNull();
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class")).isEqualTo("com.example.Main");
|
||||
assertThat(jarFile.getEntry("org/springframework/boot/loader/LaunchedURLClassLoader.class")).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customStartClassInTheManifestIsHonored() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.getManifest().getAttributes().put("Start-Class",
|
||||
"com.example.CustomMain");
|
||||
this.task.getManifest().getAttributes().put("Start-Class", "com.example.CustomMain");
|
||||
this.task.execute();
|
||||
assertThat(this.task.getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class"))
|
||||
.isEqualTo(this.launcherClass);
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class")).isEqualTo(this.launcherClass);
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class"))
|
||||
.isEqualTo("com.example.CustomMain");
|
||||
}
|
||||
@@ -348,8 +313,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
Enumeration<JarEntry> entries = jarFile.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
JarEntry entry = entries.nextElement();
|
||||
assertThat(entry.getTime())
|
||||
.isEqualTo(BootZipCopyAction.CONSTANT_TIME_FOR_ZIP_ENTRIES);
|
||||
assertThat(entry.getTime()).isEqualTo(BootZipCopyAction.CONSTANT_TIME_FOR_ZIP_ENTRIES);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -382,8 +346,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.execute();
|
||||
assertThat(this.task.getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(jarFile.getEntry(this.libPath + "spring-boot-devtools-0.1.2.jar"))
|
||||
.isNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "spring-boot-devtools-0.1.2.jar")).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,8 +358,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.execute();
|
||||
assertThat(this.task.getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(jarFile.getEntry(this.libPath + "spring-boot-devtools-0.1.2.jar"))
|
||||
.isNotNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "spring-boot-devtools-0.1.2.jar")).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,23 +384,19 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loaderIsWrittenFirstThenApplicationClassesThenLibraries()
|
||||
throws IOException {
|
||||
public void loaderIsWrittenFirstThenApplicationClassesThenLibraries() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
File classpathFolder = this.temp.newFolder();
|
||||
File applicationClass = new File(classpathFolder,
|
||||
"com/example/Application.class");
|
||||
File applicationClass = new File(classpathFolder, "com/example/Application.class");
|
||||
applicationClass.getParentFile().mkdirs();
|
||||
applicationClass.createNewFile();
|
||||
this.task.classpath(classpathFolder, jarFile("first-library.jar"),
|
||||
jarFile("second-library.jar"), jarFile("third-library.jar"));
|
||||
this.task.classpath(classpathFolder, jarFile("first-library.jar"), jarFile("second-library.jar"),
|
||||
jarFile("third-library.jar"));
|
||||
this.task.requiresUnpack("second-library.jar");
|
||||
this.task.execute();
|
||||
assertThat(getEntryNames(this.task.getArchivePath())).containsSubsequence(
|
||||
"org/springframework/boot/loader/",
|
||||
this.classesPath + "com/example/Application.class",
|
||||
this.libPath + "first-library.jar", this.libPath + "second-library.jar",
|
||||
this.libPath + "third-library.jar");
|
||||
assertThat(getEntryNames(this.task.getArchivePath())).containsSubsequence("org/springframework/boot/loader/",
|
||||
this.classesPath + "com/example/Application.class", this.libPath + "first-library.jar",
|
||||
this.libPath + "second-library.jar", this.libPath + "third-library.jar");
|
||||
}
|
||||
|
||||
protected File jarFile(String name) throws IOException {
|
||||
|
||||
@@ -32,16 +32,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class BootJarTests extends AbstractBootArchiveTests<BootJar> {
|
||||
|
||||
public BootJarTests() {
|
||||
super(BootJar.class, "org.springframework.boot.loader.JarLauncher",
|
||||
"BOOT-INF/lib/", "BOOT-INF/classes/");
|
||||
super(BootJar.class, "org.springframework.boot.loader.JarLauncher", "BOOT-INF/lib/", "BOOT-INF/classes/");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void contentCanBeAddedToBootInfUsingCopySpecFromGetter() throws IOException {
|
||||
BootJar bootJar = getTask();
|
||||
bootJar.setMainClassName("com.example.Application");
|
||||
bootJar.getBootInf().into("test")
|
||||
.from(new File("build.gradle").getAbsolutePath());
|
||||
bootJar.getBootInf().into("test").from(new File("build.gradle").getAbsolutePath());
|
||||
bootJar.execute();
|
||||
try (JarFile jarFile = new JarFile(bootJar.getArchivePath())) {
|
||||
assertThat(jarFile.getJarEntry("BOOT-INF/test/build.gradle")).isNotNull();
|
||||
@@ -52,8 +50,7 @@ public class BootJarTests extends AbstractBootArchiveTests<BootJar> {
|
||||
public void contentCanBeAddedToBootInfUsingCopySpecAction() throws IOException {
|
||||
BootJar bootJar = getTask();
|
||||
bootJar.setMainClassName("com.example.Application");
|
||||
bootJar.bootInf((copySpec) -> copySpec.into("test")
|
||||
.from(new File("build.gradle").getAbsolutePath()));
|
||||
bootJar.bootInf((copySpec) -> copySpec.into("test").from(new File("build.gradle").getAbsolutePath()));
|
||||
bootJar.execute();
|
||||
try (JarFile jarFile = new JarFile(bootJar.getArchivePath())) {
|
||||
assertThat(jarFile.getJarEntry("BOOT-INF/test/build.gradle")).isNotNull();
|
||||
|
||||
@@ -32,8 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
|
||||
public BootWarTests() {
|
||||
super(BootWar.class, "org.springframework.boot.loader.WarLauncher",
|
||||
"WEB-INF/lib/", "WEB-INF/classes/");
|
||||
super(BootWar.class, "org.springframework.boot.loader.WarLauncher", "WEB-INF/lib/", "WEB-INF/classes/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -72,37 +71,30 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void devtoolsJarIsExcludedByDefaultWhenItsOnTheProvidedClasspath()
|
||||
throws IOException {
|
||||
public void devtoolsJarIsExcludedByDefaultWhenItsOnTheProvidedClasspath() throws IOException {
|
||||
getTask().setMainClassName("com.example.Main");
|
||||
getTask().providedClasspath(this.temp.newFile("spring-boot-devtools-0.1.2.jar"));
|
||||
getTask().execute();
|
||||
assertThat(getTask().getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchivePath())) {
|
||||
assertThat(jarFile
|
||||
.getEntry("WEB-INF/lib-provided/spring-boot-devtools-0.1.2.jar"))
|
||||
.isNull();
|
||||
assertThat(jarFile.getEntry("WEB-INF/lib-provided/spring-boot-devtools-0.1.2.jar")).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void devtoolsJarCanBeIncludedWhenItsOnTheProvidedClasspath()
|
||||
throws IOException {
|
||||
public void devtoolsJarCanBeIncludedWhenItsOnTheProvidedClasspath() throws IOException {
|
||||
getTask().setMainClassName("com.example.Main");
|
||||
getTask().providedClasspath(jarFile("spring-boot-devtools-0.1.2.jar"));
|
||||
getTask().setExcludeDevtools(false);
|
||||
getTask().execute();
|
||||
assertThat(getTask().getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchivePath())) {
|
||||
assertThat(jarFile
|
||||
.getEntry("WEB-INF/lib-provided/spring-boot-devtools-0.1.2.jar"))
|
||||
.isNotNull();
|
||||
assertThat(jarFile.getEntry("WEB-INF/lib-provided/spring-boot-devtools-0.1.2.jar")).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void webappResourcesInDirectoriesThatOverlapWithLoaderCanBePackaged()
|
||||
throws IOException {
|
||||
public void webappResourcesInDirectoriesThatOverlapWithLoaderCanBePackaged() throws IOException {
|
||||
File webappFolder = this.temp.newFolder("src", "main", "webapp");
|
||||
File orgFolder = new File(webappFolder, "org");
|
||||
orgFolder.mkdir();
|
||||
@@ -123,8 +115,8 @@ public class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
getTask().classpath(jarFile("library.jar"));
|
||||
getTask().providedClasspath(jarFile("provided-library.jar"));
|
||||
getTask().execute();
|
||||
assertThat(getEntryNames(getTask().getArchivePath())).containsSubsequence(
|
||||
"WEB-INF/lib/library.jar", "WEB-INF/lib-provided/provided-library.jar");
|
||||
assertThat(getEntryNames(getTask().getArchivePath())).containsSubsequence("WEB-INF/lib/library.jar",
|
||||
"WEB-INF/lib-provided/provided-library.jar");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -44,50 +44,50 @@ public class LaunchScriptConfigurationTests {
|
||||
@Test
|
||||
public void initInfoProvidesUsesArchiveBaseNameByDefault() {
|
||||
given(this.task.getBaseName()).willReturn("base-name");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties())
|
||||
.containsEntry("initInfoProvides", "base-name");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoProvides",
|
||||
"base-name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initInfoShortDescriptionUsesDescriptionByDefault() {
|
||||
given(this.project.getDescription()).willReturn("Project description");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties())
|
||||
.containsEntry("initInfoShortDescription", "Project description");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoShortDescription",
|
||||
"Project description");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initInfoShortDescriptionUsesArchiveBaseNameWhenDescriptionIsNull() {
|
||||
given(this.task.getBaseName()).willReturn("base-name");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties())
|
||||
.containsEntry("initInfoShortDescription", "base-name");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoShortDescription",
|
||||
"base-name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initInfoShortDescriptionUsesSingleLineVersionOfMultiLineProjectDescription() {
|
||||
given(this.project.getDescription()).willReturn("Project\ndescription");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties())
|
||||
.containsEntry("initInfoShortDescription", "Project description");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoShortDescription",
|
||||
"Project description");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initInfoDescriptionUsesArchiveBaseNameWhenDescriptionIsNull() {
|
||||
given(this.task.getBaseName()).willReturn("base-name");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties())
|
||||
.containsEntry("initInfoDescription", "base-name");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoDescription",
|
||||
"base-name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initInfoDescriptionUsesProjectDescriptionByDefault() {
|
||||
given(this.project.getDescription()).willReturn("Project description");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties())
|
||||
.containsEntry("initInfoDescription", "Project description");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoDescription",
|
||||
"Project description");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void initInfoDescriptionUsesCorrectlyFormattedMultiLineProjectDescription() {
|
||||
given(this.project.getDescription()).willReturn("The\nproject\ndescription");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties())
|
||||
.containsEntry("initInfoDescription", "The\n# project\n# description");
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoDescription",
|
||||
"The\n# project\n# description");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,23 +45,20 @@ public class MavenIntegrationTests {
|
||||
@Test
|
||||
public void bootJarCanBeUploaded() throws FileNotFoundException, IOException {
|
||||
BuildResult result = this.gradleBuild.build("uploadBootArchives");
|
||||
assertThat(result.task(":uploadBootArchives").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.task(":uploadBootArchives").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(artifactWithSuffix("jar")).isFile();
|
||||
assertThat(artifactWithSuffix("pom")).is(pomWith().groupId("com.example")
|
||||
.artifactId(this.gradleBuild.getProjectDir().getName()).version("1.0")
|
||||
.noPackaging().noDependencies());
|
||||
.artifactId(this.gradleBuild.getProjectDir().getName()).version("1.0").noPackaging().noDependencies());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bootWarCanBeUploaded() throws IOException {
|
||||
BuildResult result = this.gradleBuild.build("uploadBootArchives");
|
||||
assertThat(result.task(":uploadBootArchives").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.task(":uploadBootArchives").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(artifactWithSuffix("war")).isFile();
|
||||
assertThat(artifactWithSuffix("pom")).is(pomWith().groupId("com.example")
|
||||
.artifactId(this.gradleBuild.getProjectDir().getName()).version("1.0")
|
||||
.packaging("war").noDependencies());
|
||||
assertThat(artifactWithSuffix("pom"))
|
||||
.is(pomWith().groupId("com.example").artifactId(this.gradleBuild.getProjectDir().getName())
|
||||
.version("1.0").packaging("war").noDependencies());
|
||||
}
|
||||
|
||||
private File artifactWithSuffix(String suffix) {
|
||||
|
||||
@@ -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.
|
||||
@@ -49,8 +49,7 @@ public class MavenPublishingIntegrationTests {
|
||||
assertThat(result.task(":publish").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(artifactWithSuffix("jar")).isFile();
|
||||
assertThat(artifactWithSuffix("pom")).is(pomWith().groupId("com.example")
|
||||
.artifactId(this.gradleBuild.getProjectDir().getName()).version("1.0")
|
||||
.noPackaging().noDependencies());
|
||||
.artifactId(this.gradleBuild.getProjectDir().getName()).version("1.0").noPackaging().noDependencies());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,9 +57,9 @@ public class MavenPublishingIntegrationTests {
|
||||
BuildResult result = this.gradleBuild.build("publish");
|
||||
assertThat(result.task(":publish").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(artifactWithSuffix("war")).isFile();
|
||||
assertThat(artifactWithSuffix("pom")).is(pomWith().groupId("com.example")
|
||||
.artifactId(this.gradleBuild.getProjectDir().getName()).version("1.0")
|
||||
.packaging("war").noDependencies());
|
||||
assertThat(artifactWithSuffix("pom"))
|
||||
.is(pomWith().groupId("com.example").artifactId(this.gradleBuild.getProjectDir().getName())
|
||||
.version("1.0").packaging("war").noDependencies());
|
||||
}
|
||||
|
||||
private File artifactWithSuffix(String suffix) {
|
||||
|
||||
@@ -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.
|
||||
@@ -44,8 +44,8 @@ class PomCondition extends Condition<File> {
|
||||
}
|
||||
|
||||
private PomCondition(Set<String> expectedContents, Set<String> notExpectedContents) {
|
||||
super(new TextDescription("Pom file containing %s and not containing %s",
|
||||
expectedContents, notExpectedContents));
|
||||
super(new TextDescription("Pom file containing %s and not containing %s", expectedContents,
|
||||
notExpectedContents));
|
||||
this.expectedContents = expectedContents;
|
||||
this.notExpectedContents = notExpectedContents;
|
||||
}
|
||||
@@ -73,8 +73,8 @@ class PomCondition extends Condition<File> {
|
||||
|
||||
@Override
|
||||
public Description description() {
|
||||
return new TextDescription("Pom file containing %s and not containing %s",
|
||||
this.expectedContents, this.notExpectedContents);
|
||||
return new TextDescription("Pom file containing %s and not containing %s", this.expectedContents,
|
||||
this.notExpectedContents);
|
||||
}
|
||||
|
||||
PomCondition groupId(String groupId) {
|
||||
@@ -83,8 +83,7 @@ class PomCondition extends Condition<File> {
|
||||
}
|
||||
|
||||
PomCondition artifactId(String artifactId) {
|
||||
this.expectedContents
|
||||
.add(String.format("<artifactId>%s</artifactId>", artifactId));
|
||||
this.expectedContents.add(String.format("<artifactId>%s</artifactId>", artifactId));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -48,12 +48,9 @@ public class BootRunIntegrationTests {
|
||||
new File(this.gradleBuild.getProjectDir(), "src/main/resources").mkdirs();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput())
|
||||
.contains("1. " + canonicalPathOf("build/classes/java/main"));
|
||||
assertThat(result.getOutput())
|
||||
.contains("2. " + canonicalPathOf("build/resources/main"));
|
||||
assertThat(result.getOutput())
|
||||
.doesNotContain(canonicalPathOf("src/main/resources"));
|
||||
assertThat(result.getOutput()).contains("1. " + canonicalPathOf("build/classes/java/main"));
|
||||
assertThat(result.getOutput()).contains("2. " + canonicalPathOf("build/resources/main"));
|
||||
assertThat(result.getOutput()).doesNotContain(canonicalPathOf("src/main/resources"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -61,54 +58,42 @@ public class BootRunIntegrationTests {
|
||||
copyApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput())
|
||||
.contains("1. " + canonicalPathOf("src/main/resources"));
|
||||
assertThat(result.getOutput())
|
||||
.contains("2. " + canonicalPathOf("build/classes/java/main"));
|
||||
assertThat(result.getOutput())
|
||||
.doesNotContain(canonicalPathOf("build/resources/main"));
|
||||
assertThat(result.getOutput()).contains("1. " + canonicalPathOf("src/main/resources"));
|
||||
assertThat(result.getOutput()).contains("2. " + canonicalPathOf("build/classes/java/main"));
|
||||
assertThat(result.getOutput()).doesNotContain(canonicalPathOf("build/resources/main"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springBootExtensionMainClassNameIsUsed() throws IOException {
|
||||
BuildResult result = this.gradleBuild.build("echoMainClassName");
|
||||
assertThat(result.task(":echoMainClassName").getOutcome())
|
||||
.isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
assertThat(result.getOutput())
|
||||
.contains("Main class name = com.example.CustomMainClass");
|
||||
assertThat(result.task(":echoMainClassName").getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
assertThat(result.getOutput()).contains("Main class name = com.example.CustomMainClass");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applicationPluginMainClassNameIsUsed() throws IOException {
|
||||
BuildResult result = this.gradleBuild.build("echoMainClassName");
|
||||
assertThat(result.task(":echoMainClassName").getOutcome())
|
||||
.isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
assertThat(result.getOutput())
|
||||
.contains("Main class name = com.example.CustomMainClass");
|
||||
assertThat(result.task(":echoMainClassName").getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
assertThat(result.getOutput()).contains("Main class name = com.example.CustomMainClass");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applicationPluginMainClassNameIsNotUsedWhenItIsNull() throws IOException {
|
||||
copyApplication();
|
||||
BuildResult result = this.gradleBuild.build("echoMainClassName");
|
||||
assertThat(result.task(":echoMainClassName").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput())
|
||||
.contains("Main class name = com.example.BootRunApplication");
|
||||
assertThat(result.task(":echoMainClassName").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("Main class name = com.example.BootRunApplication");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applicationPluginJvmArgumentsAreUsed() throws IOException {
|
||||
BuildResult result = this.gradleBuild.build("echoJvmArguments");
|
||||
assertThat(result.task(":echoJvmArguments").getOutcome())
|
||||
.isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
assertThat(result.getOutput())
|
||||
.contains("JVM arguments = [-Dcom.foo=bar, -Dcom.bar=baz]");
|
||||
assertThat(result.task(":echoJvmArguments").getOutcome()).isEqualTo(TaskOutcome.UP_TO_DATE);
|
||||
assertThat(result.getOutput()).contains("JVM arguments = [-Dcom.foo=bar, -Dcom.bar=baz]");
|
||||
}
|
||||
|
||||
private void copyApplication() throws IOException {
|
||||
File output = new File(this.gradleBuild.getProjectDir(),
|
||||
"src/main/java/com/example");
|
||||
File output = new File(this.gradleBuild.getProjectDir(), "src/main/java/com/example");
|
||||
output.mkdirs();
|
||||
FileSystemUtils.copyRecursively(new File("src/test/java/com/example"), output);
|
||||
}
|
||||
|
||||
@@ -59,8 +59,7 @@ import org.springframework.util.FileCopyUtils;
|
||||
*/
|
||||
public class GradleBuild implements TestRule {
|
||||
|
||||
private static final Pattern GRADLE_VERSION_PATTERN = Pattern
|
||||
.compile("\\[Gradle .+\\]");
|
||||
private static final Pattern GRADLE_VERSION_PATTERN = Pattern.compile("\\[Gradle .+\\]");
|
||||
|
||||
private final TemporaryFolder temp = new TemporaryFolder();
|
||||
|
||||
@@ -116,8 +115,7 @@ public class GradleBuild implements TestRule {
|
||||
|
||||
private URL getScriptForTestMethod(Description description) {
|
||||
String name = description.getTestClass().getSimpleName() + "-"
|
||||
+ removeGradleVersion(description.getMethodName())
|
||||
+ this.dsl.getExtension();
|
||||
+ removeGradleVersion(description.getMethodName()) + this.dsl.getExtension();
|
||||
return description.getTestClass().getResource(name);
|
||||
}
|
||||
|
||||
@@ -138,10 +136,8 @@ public class GradleBuild implements TestRule {
|
||||
}
|
||||
|
||||
private List<File> pluginClasspath() {
|
||||
return Arrays.asList(new File("bin"), new File("build/classes/java/main"),
|
||||
new File("build/resources/main"),
|
||||
new File(pathOfJarContaining(LaunchScript.class)),
|
||||
new File(pathOfJarContaining(ClassVisitor.class)),
|
||||
return Arrays.asList(new File("bin"), new File("build/classes/java/main"), new File("build/resources/main"),
|
||||
new File(pathOfJarContaining(LaunchScript.class)), new File(pathOfJarContaining(ClassVisitor.class)),
|
||||
new File(pathOfJarContaining(DependencyManagementPlugin.class)),
|
||||
new File(pathOfJarContaining(PropertiesKt.class)),
|
||||
new File(pathOfJarContaining(KotlinCompilerRunner.class)),
|
||||
@@ -155,8 +151,7 @@ public class GradleBuild implements TestRule {
|
||||
}
|
||||
|
||||
public GradleBuild script(String script) {
|
||||
this.script = script.endsWith(this.dsl.getExtension()) ? script
|
||||
: script + this.dsl.getExtension();
|
||||
this.script = script.endsWith(this.dsl.getExtension()) ? script : script + this.dsl.getExtension();
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -181,10 +176,8 @@ public class GradleBuild implements TestRule {
|
||||
public GradleRunner prepareRunner(String... arguments) throws IOException {
|
||||
String scriptContent = FileCopyUtils.copyToString(new FileReader(this.script))
|
||||
.replace("{version}", getBootVersion())
|
||||
.replace("{dependency-management-plugin-version}",
|
||||
getDependencyManagementPluginVersion());
|
||||
FileCopyUtils.copy(scriptContent, new FileWriter(
|
||||
new File(this.projectDir, "build" + this.dsl.getExtension())));
|
||||
.replace("{dependency-management-plugin-version}", getDependencyManagementPluginVersion());
|
||||
FileCopyUtils.copy(scriptContent, new FileWriter(new File(this.projectDir, "build" + this.dsl.getExtension())));
|
||||
GradleRunner gradleRunner = GradleRunner.create().withProjectDir(this.projectDir)
|
||||
.withPluginClasspath(pluginClasspath());
|
||||
if (this.dsl != Dsl.KOTLIN) {
|
||||
@@ -223,29 +216,24 @@ public class GradleBuild implements TestRule {
|
||||
|
||||
private static String getBootVersion() {
|
||||
return evaluateExpression(
|
||||
"/*[local-name()='project']/*[local-name()='parent']/*[local-name()='version']"
|
||||
+ "/text()");
|
||||
"/*[local-name()='project']/*[local-name()='parent']/*[local-name()='version']" + "/text()");
|
||||
}
|
||||
|
||||
private static String getDependencyManagementPluginVersion() {
|
||||
try (FileReader pomReader = new FileReader(".flattened-pom.xml")) {
|
||||
Document pom = DocumentBuilderFactory.newInstance().newDocumentBuilder()
|
||||
.parse(new InputSource(pomReader));
|
||||
Document pom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(pomReader));
|
||||
NodeList dependencyElements = pom.getElementsByTagName("dependency");
|
||||
for (int i = 0; i < dependencyElements.getLength(); i++) {
|
||||
Element dependency = (Element) dependencyElements.item(i);
|
||||
if (dependency.getElementsByTagName("artifactId").item(0).getTextContent()
|
||||
.equals("dependency-management-plugin")) {
|
||||
return dependency.getElementsByTagName("version").item(0)
|
||||
.getTextContent();
|
||||
return dependency.getElementsByTagName("version").item(0).getTextContent();
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException(
|
||||
"dependency management plugin version not found");
|
||||
throw new IllegalStateException("dependency management plugin version not found");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException(
|
||||
"Failed to find dependency management plugin version", ex);
|
||||
throw new IllegalStateException("Failed to find dependency management plugin version", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user