File tree Expand file tree Collapse file tree 6 files changed +51
-15
lines changed
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin
test/java/org/springframework/boot/gradle/docs Expand file tree Collapse file tree 6 files changed +51
-15
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ task dependencyVersions(type: org.springframework.boot.build.constraints.Extract
72
72
73
73
tasks. withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask ) {
74
74
dependsOn dependencyVersions
75
+ inputs. dir(' src/docs/gradle' ). withPathSensitivity(PathSensitivity . RELATIVE )
75
76
doFirst {
76
77
attributes " dependency-management-plugin-version" : dependencyVersions. versionConstraints[" io.spring.gradle:dependency-management-plugin" ]
77
78
}
Original file line number Diff line number Diff line change @@ -15,3 +15,9 @@ bootBuildImage {
15
15
]
16
16
}
17
17
// end::env[]
18
+
19
+ task bootBuildImageEnvironment {
20
+ doFirst {
21
+ bootBuildImage. environment. each { name , value -> println " $name =$value " }
22
+ }
23
+ }
Original file line number Diff line number Diff line change 1
- import org.springframework.boot.gradle.tasks.bundling.BootJar
1
+ import org.springframework.boot.gradle.tasks.bundling.BootBuildImage
2
2
3
3
plugins {
4
4
java
5
5
id(" org.springframework.boot" ) version " {gradle-project-version}"
6
6
}
7
7
8
- tasks.getByName<BootJar >(" bootJar" ) {
9
- mainClassName = " com.example.ExampleApplication"
10
- }
11
-
12
8
// tag::env[]
13
9
tasks.getByName<BootBuildImage >(" bootBuildImage" ) {
14
- environment = [
15
- " HTTP_PROXY" : " http://proxy.example.com" ,
16
- " HTTPS_PROXY" : " https://proxy.example.com"
17
- ]
10
+ environment = mapOf (" HTTP_PROXY" to " http://proxy.example.com" ,
11
+ " HTTPS_PROXY" to " https://proxy.example.com" )
18
12
}
19
13
// end::env[]
14
+
15
+ tasks.register(" bootBuildImageEnvironment" ) {
16
+ doFirst {
17
+ for ((name, value) in tasks.getByName<BootBuildImage >(" bootBuildImage" ).environment) {
18
+ print (name + " =" + value)
19
+ }
20
+ }
21
+ }
Original file line number Diff line number Diff line change @@ -12,3 +12,9 @@ bootBuildImage {
12
12
environment = [" BP_JVM_VERSION" : " 13.0.1" ]
13
13
}
14
14
// end::env[]
15
+
16
+ task bootBuildImageEnvironment {
17
+ doFirst {
18
+ bootBuildImage. environment. each { name , value -> println " $name =$value " }
19
+ }
20
+ }
Original file line number Diff line number Diff line change 1
- import org.springframework.boot.gradle.tasks.bundling.BootJar
1
+ import org.springframework.boot.gradle.tasks.bundling.BootBuildImage
2
2
3
3
plugins {
4
4
java
5
5
id(" org.springframework.boot" ) version " {gradle-project-version}"
6
6
}
7
7
8
- tasks.getByName<BootJar >(" bootJar" ) {
9
- mainClassName = " com.example.ExampleApplication"
10
- }
11
-
12
8
// tag::env[]
13
9
tasks.getByName<BootBuildImage >(" bootBuildImage" ) {
14
- environment = [ " BP_JVM_VERSION" : " 13.0.1" ]
10
+ environment = mapOf ( " BP_JVM_VERSION" to " 13.0.1" )
15
11
}
16
12
// end::env[]
13
+
14
+ tasks.register(" bootBuildImageEnvironment" ) {
15
+ doFirst {
16
+ for ((name, value) in tasks.getByName<BootBuildImage >(" bootBuildImage" ).environment) {
17
+ print (name + " =" + value)
18
+ }
19
+ }
20
+ }
21
+
Original file line number Diff line number Diff line change 28
28
import java .util .jar .Manifest ;
29
29
import java .util .zip .ZipEntry ;
30
30
31
+ import org .gradle .testkit .runner .BuildResult ;
31
32
import org .junit .jupiter .api .TestTemplate ;
32
33
import org .junit .jupiter .api .extension .ExtendWith ;
33
34
@@ -221,6 +222,21 @@ void bootJarLayeredExcludeTools() throws IOException {
221
222
}
222
223
}
223
224
225
+ @ TestTemplate
226
+ void bootBuildImageWithCustomBuildpackJvmVersion () throws IOException {
227
+ BuildResult result = this .gradleBuild .script ("src/docs/gradle/packaging/boot-build-image-env" )
228
+ .build ("bootBuildImageEnvironment" );
229
+ assertThat (result .getOutput ()).contains ("BP_JVM_VERSION=13.0.1" );
230
+ }
231
+
232
+ @ TestTemplate
233
+ void bootBuildImageWithCustomProxySettings () throws IOException {
234
+ BuildResult result = this .gradleBuild .script ("src/docs/gradle/packaging/boot-build-image-env-proxy" )
235
+ .build ("bootBuildImageEnvironment" );
236
+ assertThat (result .getOutput ()).contains ("HTTP_PROXY=http://proxy.example.com" )
237
+ .contains ("HTTPS_PROXY=https://proxy.example.com" );
238
+ }
239
+
224
240
protected void jarFile (File file ) throws IOException {
225
241
try (JarOutputStream jar = new JarOutputStream (new FileOutputStream (file ))) {
226
242
jar .putNextEntry (new ZipEntry ("META-INF/MANIFEST.MF" ));
You can’t perform that action at this time.
0 commit comments