File tree Expand file tree Collapse file tree 5 files changed +85
-3
lines changed
spring-boot-integration-tests/src/test
java/org/springframework/boot/gradle
resources/spring-loaded-old-gradle
spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/run Expand file tree Collapse file tree 5 files changed +85
-3
lines changed Original file line number Diff line number Diff line change 30
30
*/
31
31
public class ProjectCreator {
32
32
33
+ private String gradleVersion ;
34
+
35
+ public ProjectCreator () {
36
+ this ("1.12" );
37
+ }
38
+
39
+ public ProjectCreator (String gradleVersion ) {
40
+ this .gradleVersion = gradleVersion ;
41
+ }
42
+
33
43
public ProjectConnection createProject (String name ) throws IOException {
34
44
File projectDirectory = new File ("target/" + name );
35
45
projectDirectory .mkdirs ();
@@ -46,7 +56,7 @@ public ProjectConnection createProject(String name) throws IOException {
46
56
}
47
57
48
58
GradleConnector gradleConnector = GradleConnector .newConnector ();
49
- gradleConnector .useGradleVersion ("1.12" );
59
+ gradleConnector .useGradleVersion (this . gradleVersion );
50
60
51
61
((DefaultGradleConnector ) gradleConnector ).embedded (true );
52
62
return gradleConnector .forProjectDirectory (projectDirectory ).connect ();
Original file line number Diff line number Diff line change @@ -60,6 +60,21 @@ public void defaultJvmArgsArePreservedWhenLoadedAgentIsConfigured()
60
60
"-javaagent:.*springloaded-" + SPRING_LOADED_VERSION + ".jar" , output );
61
61
}
62
62
63
+ @ Test
64
+ public void springLoadedCanBeUsedWithGradle16 () throws IOException {
65
+ ProjectConnection project = new ProjectCreator ("1.6" )
66
+ .createProject ("spring-loaded-old-gradle" );
67
+ project .newBuild ()
68
+ .forTasks ("bootRun" )
69
+ .withArguments ("-PbootVersion=" + BOOT_VERSION ,
70
+ "-PspringLoadedVersion=" + SPRING_LOADED_VERSION , "--stacktrace" )
71
+ .run ();
72
+
73
+ List <String > output = getOutput ();
74
+ assertOutputMatches (
75
+ "-javaagent:.*springloaded-" + SPRING_LOADED_VERSION + ".jar" , output );
76
+ }
77
+
63
78
private List <String > getOutput () throws IOException {
64
79
BufferedReader reader = new BufferedReader (new FileReader (new File (
65
80
"target/spring-loaded-jvm-args/build/output.txt" )));
Original file line number Diff line number Diff line change
1
+ buildscript {
2
+ repositories {
3
+ mavenLocal()
4
+ mavenCentral()
5
+ }
6
+ dependencies {
7
+ classpath(" org.springframework.boot:spring-boot-gradle-plugin:${ project.bootVersion} " )
8
+ classpath(" org.springframework:springloaded:${ project.springLoadedVersion} " )
9
+ }
10
+ }
11
+
12
+ apply plugin : ' java'
13
+ apply plugin : ' spring-boot'
14
+
15
+ repositories {
16
+ mavenLocal()
17
+ mavenCentral()
18
+ }
19
+
20
+ dependencies {
21
+ compile(" org.springframework.boot:spring-boot-starter" )
22
+ }
23
+
24
+ jar {
25
+ baseName = ' spring-loaded-old-gradle'
26
+ }
Original file line number Diff line number Diff line change
1
+ package test ;
2
+
3
+ import java .io .File ;
4
+ import java .io .FileWriter ;
5
+ import java .io .PrintWriter ;
6
+ import java .lang .management .ManagementFactory ;
7
+
8
+ import org .springframework .beans .factory .annotation .Value ;
9
+ import org .springframework .boot .SpringApplication ;
10
+ import org .springframework .boot .autoconfigure .EnableAutoConfiguration ;
11
+ import org .springframework .context .annotation .Bean ;
12
+ import org .springframework .context .annotation .ComponentScan ;
13
+ import org .springframework .context .annotation .Configuration ;
14
+ import org .springframework .util .Assert ;
15
+
16
+ public class Application {
17
+
18
+ public static void main (String [] args ) throws Exception {
19
+ PrintWriter writer = new PrintWriter (new FileWriter (new File ("build/output.txt" )));
20
+ for (String argument : ManagementFactory .getRuntimeMXBean ().getInputArguments ()) {
21
+ writer .println (argument );
22
+ }
23
+ writer .close ();
24
+ }
25
+ }
Original file line number Diff line number Diff line change 16
16
17
17
package org .springframework .boot .gradle .run ;
18
18
19
+ import java .util .Collections ;
19
20
import java .util .concurrent .Callable ;
20
21
21
22
import org .gradle .api .Action ;
@@ -74,9 +75,14 @@ public Object call() throws Exception {
74
75
run .getConventionMapping ().map ("jvmArgs" , new Callable <Object >() {
75
76
@ Override
76
77
public Object call () throws Exception {
77
- return project .property ("applicationDefaultJvmArgs" );
78
+ if (project .hasProperty ("applicationDefaultJvmArgs" )) {
79
+ return project .property ("applicationDefaultJvmArgs" );
80
+ }
81
+ else {
82
+ return Collections .emptyList ();
83
+ }
84
+
78
85
}
79
86
});
80
87
}
81
-
82
88
}
You can’t perform that action at this time.
0 commit comments