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
7272
7373tasks. withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask ) {
7474 dependsOn dependencyVersions
75+ inputs. dir(' src/docs/gradle' ). withPathSensitivity(PathSensitivity . RELATIVE )
7576 doFirst {
7677 attributes " dependency-management-plugin-version" : dependencyVersions. versionConstraints[" io.spring.gradle:dependency-management-plugin" ]
7778 }
Original file line number Diff line number Diff line change @@ -15,3 +15,9 @@ bootBuildImage {
1515 ]
1616}
1717// 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
22
33plugins {
44 java
55 id(" org.springframework.boot" ) version " {gradle-project-version}"
66}
77
8- tasks.getByName<BootJar >(" bootJar" ) {
9- mainClassName = " com.example.ExampleApplication"
10- }
11-
128// tag::env[]
139tasks.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" )
1812}
1913// 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 {
1212 environment = [" BP_JVM_VERSION" : " 13.0.1" ]
1313}
1414// 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
22
33plugins {
44 java
55 id(" org.springframework.boot" ) version " {gradle-project-version}"
66}
77
8- tasks.getByName<BootJar >(" bootJar" ) {
9- mainClassName = " com.example.ExampleApplication"
10- }
11-
128// tag::env[]
139tasks.getByName<BootBuildImage >(" bootBuildImage" ) {
14- environment = [ " BP_JVM_VERSION" : " 13.0.1" ]
10+ environment = mapOf ( " BP_JVM_VERSION" to " 13.0.1" )
1511}
1612// 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 2828import java .util .jar .Manifest ;
2929import java .util .zip .ZipEntry ;
3030
31+ import org .gradle .testkit .runner .BuildResult ;
3132import org .junit .jupiter .api .TestTemplate ;
3233import org .junit .jupiter .api .extension .ExtendWith ;
3334
@@ -221,6 +222,21 @@ void bootJarLayeredExcludeTools() throws IOException {
221222 }
222223 }
223224
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+
224240 protected void jarFile (File file ) throws IOException {
225241 try (JarOutputStream jar = new JarOutputStream (new FileOutputStream (file ))) {
226242 jar .putNextEntry (new ZipEntry ("META-INF/MANIFEST.MF" ));
You can’t perform that action at this time.
0 commit comments