Fix configuration of Spring Loaded on Gradle 1.6
The applicationDefaultJvmArgs property was added in Gradle 1.7. This commit updates RunPluginFeatures to access the property defensively so that the plugin can be used with Gradle 1.6. Fixes gh-1511
This commit is contained in:
@@ -30,6 +30,16 @@ import org.springframework.util.FileSystemUtils;
|
||||
*/
|
||||
public class ProjectCreator {
|
||||
|
||||
private String gradleVersion;
|
||||
|
||||
public ProjectCreator() {
|
||||
this("1.12");
|
||||
}
|
||||
|
||||
public ProjectCreator(String gradleVersion) {
|
||||
this.gradleVersion = gradleVersion;
|
||||
}
|
||||
|
||||
public ProjectConnection createProject(String name) throws IOException {
|
||||
File projectDirectory = new File("target/" + name);
|
||||
projectDirectory.mkdirs();
|
||||
@@ -46,7 +56,7 @@ public class ProjectCreator {
|
||||
}
|
||||
|
||||
GradleConnector gradleConnector = GradleConnector.newConnector();
|
||||
gradleConnector.useGradleVersion("1.12");
|
||||
gradleConnector.useGradleVersion(this.gradleVersion);
|
||||
|
||||
((DefaultGradleConnector) gradleConnector).embedded(true);
|
||||
return gradleConnector.forProjectDirectory(projectDirectory).connect();
|
||||
|
||||
@@ -60,6 +60,21 @@ public class SpringLoadedTests {
|
||||
"-javaagent:.*springloaded-" + SPRING_LOADED_VERSION + ".jar", output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void springLoadedCanBeUsedWithGradle16() throws IOException {
|
||||
ProjectConnection project = new ProjectCreator("1.6")
|
||||
.createProject("spring-loaded-old-gradle");
|
||||
project.newBuild()
|
||||
.forTasks("bootRun")
|
||||
.withArguments("-PbootVersion=" + BOOT_VERSION,
|
||||
"-PspringLoadedVersion=" + SPRING_LOADED_VERSION, "--stacktrace")
|
||||
.run();
|
||||
|
||||
List<String> output = getOutput();
|
||||
assertOutputMatches(
|
||||
"-javaagent:.*springloaded-" + SPRING_LOADED_VERSION + ".jar", output);
|
||||
}
|
||||
|
||||
private List<String> getOutput() throws IOException {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(new File(
|
||||
"target/spring-loaded-jvm-args/build/output.txt")));
|
||||
|
||||
Reference in New Issue
Block a user