From 925e5a64ae205e3f6ebda5156b2f8ebe7d45eab1 Mon Sep 17 00:00:00 2001 From: Alessio Stalla Date: Sat, 2 Jun 2018 00:07:23 +0200 Subject: [PATCH 1/4] Thin jar option for Spring Boot bootstrap and gradle projects. --- parent-boot-2/pom.xml | 20 ++++++++++++++++++ spring-boot-bootstrap/pom.xml | 21 +++++++++++++++++++ spring-boot-gradle/build.gradle | 10 +++++++++ .../gradle/wrapper/gradle-wrapper.properties | 4 ++-- 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/parent-boot-2/pom.xml b/parent-boot-2/pom.xml index a9c54dece9b3..cde3a0f5c572 100644 --- a/parent-boot-2/pom.xml +++ b/parent-boot-2/pom.xml @@ -105,6 +105,25 @@ + + thin-jar + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.springframework.boot.experimental + spring-boot-thin-layout + ${wrapper.version} + + + + + + @@ -115,6 +134,7 @@ 1.8 1.8 + 1.0.11.RELEASE \ No newline at end of file diff --git a/spring-boot-bootstrap/pom.xml b/spring-boot-bootstrap/pom.xml index 03ce9b6906e1..380192fced03 100644 --- a/spring-boot-bootstrap/pom.xml +++ b/spring-boot-bootstrap/pom.xml @@ -107,6 +107,27 @@ + + thin-jar + + + + org.springframework.boot.experimental + spring-boot-thin-maven-plugin + ${wrapper.version} + + + resolve + + resolve + + false + + + + + + diff --git a/spring-boot-gradle/build.gradle b/spring-boot-gradle/build.gradle index e602c485a99f..74dd09415eb5 100644 --- a/spring-boot-gradle/build.gradle +++ b/spring-boot-gradle/build.gradle @@ -23,6 +23,12 @@ repositories { mavenCentral() } +buildscript { + def wrapperVersion = '1.0.11.RELEASE' + dependencies { + classpath("org.springframework.boot.experimental:spring-boot-thin-gradle-plugin:${wrapperVersion}") + } +} dependencies { compile('org.springframework.boot:spring-boot-starter') @@ -42,3 +48,7 @@ bootJar { // attributes 'Start-Class': 'org.baeldung.DemoApplication' // } } + +//add tasks thinJar and thinResolve for thin JAR deployments +apply plugin: 'maven' +apply plugin: 'org.springframework.boot.experimental.thin-launcher' \ No newline at end of file diff --git a/spring-boot-gradle/gradle/wrapper/gradle-wrapper.properties b/spring-boot-gradle/gradle/wrapper/gradle-wrapper.properties index 44d9d03d8094..a8868a918a84 100644 --- a/spring-boot-gradle/gradle/wrapper/gradle-wrapper.properties +++ b/spring-boot-gradle/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Feb 06 12:27:20 CET 2018 +#Fri Jun 01 20:39:48 CEST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-all.zip From 895f9e31e11941995952c9f5258b0ec75cf779e0 Mon Sep 17 00:00:00 2001 From: Alessio Stalla Date: Sat, 2 Jun 2018 00:08:16 +0200 Subject: [PATCH 2/4] .gitignore for spring-boot-gradle project. --- spring-boot-gradle/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 spring-boot-gradle/.gitignore diff --git a/spring-boot-gradle/.gitignore b/spring-boot-gradle/.gitignore new file mode 100644 index 000000000000..192221b47d1d --- /dev/null +++ b/spring-boot-gradle/.gitignore @@ -0,0 +1,2 @@ +.gradle/ +build/ \ No newline at end of file From a32ddef31f434da5b94fa1214deb782a7c0f17bb Mon Sep 17 00:00:00 2001 From: Alessio Stalla Date: Fri, 8 Jun 2018 21:22:50 +0200 Subject: [PATCH 3/4] Maven and Gradle 'thin' Boot builds (optional) --- spring-boot-bootstrap/pom.xml | 1 + spring-boot-gradle/build.gradle | 30 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/spring-boot-bootstrap/pom.xml b/spring-boot-bootstrap/pom.xml index 380192fced03..d693cf60b5d8 100644 --- a/spring-boot-bootstrap/pom.xml +++ b/spring-boot-bootstrap/pom.xml @@ -117,6 +117,7 @@ ${wrapper.version} + resolve resolve diff --git a/spring-boot-gradle/build.gradle b/spring-boot-gradle/build.gradle index 74dd09415eb5..caeaa19c1ae3 100644 --- a/spring-boot-gradle/build.gradle +++ b/spring-boot-gradle/build.gradle @@ -1,12 +1,14 @@ buildscript { ext { - springBootVersion = '2.0.0.RELEASE' + springBootVersion = '2.0.2.RELEASE' + wrapperVersion = '1.0.11.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") + classpath("org.springframework.boot.experimental:spring-boot-thin-gradle-plugin:${wrapperVersion}") } } @@ -14,6 +16,8 @@ apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' +//add tasks thinJar and thinResolve for thin JAR deployments +apply plugin: 'org.springframework.boot.experimental.thin-launcher' group = 'org.baeldung' version = '0.0.1-SNAPSHOT' @@ -23,13 +27,6 @@ repositories { mavenCentral() } -buildscript { - def wrapperVersion = '1.0.11.RELEASE' - dependencies { - classpath("org.springframework.boot.experimental:spring-boot-thin-gradle-plugin:${wrapperVersion}") - } -} - dependencies { compile('org.springframework.boot:spring-boot-starter') testCompile('org.springframework.boot:spring-boot-starter-test') @@ -49,6 +46,19 @@ bootJar { // } } -//add tasks thinJar and thinResolve for thin JAR deployments +//Enable this to generate and use a pom.xml file apply plugin: 'maven' -apply plugin: 'org.springframework.boot.experimental.thin-launcher' \ No newline at end of file + +//If you want to customize the generated pom.xml you can edit this task and add it as a dependency to the bootJar task +task createPom { + doLast { + pom { + withXml(dependencyManagement.pomConfigurer) + }.writeTo("build/resources/main/META-INF/maven/${project.group}/${project.name}/pom.xml") + } +} +//Uncomment the following to use your custom generated pom.xml +//bootJar.dependsOn = [createPom] + +//Enable this to generate and use a thin.properties file +//bootJar.dependsOn = [thinProperties] \ No newline at end of file From 9d5d6692aa8fd1d5e81530d171f3efd3d85d94b3 Mon Sep 17 00:00:00 2001 From: Alessio Stalla Date: Fri, 8 Jun 2018 21:42:09 +0200 Subject: [PATCH 4/4] Rename 'wrapper' to 'thin' and shorten some lines of code to fit the article. --- parent-boot-2/pom.xml | 4 ++-- spring-boot-bootstrap/pom.xml | 2 +- spring-boot-gradle/build.gradle | 13 ++++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/parent-boot-2/pom.xml b/parent-boot-2/pom.xml index cde3a0f5c572..625a96ff9d6d 100644 --- a/parent-boot-2/pom.xml +++ b/parent-boot-2/pom.xml @@ -117,7 +117,7 @@ org.springframework.boot.experimental spring-boot-thin-layout - ${wrapper.version} + ${thin.version} @@ -134,7 +134,7 @@ 1.8 1.8 - 1.0.11.RELEASE + 1.0.11.RELEASE \ No newline at end of file diff --git a/spring-boot-bootstrap/pom.xml b/spring-boot-bootstrap/pom.xml index d693cf60b5d8..8561acbfadb3 100644 --- a/spring-boot-bootstrap/pom.xml +++ b/spring-boot-bootstrap/pom.xml @@ -114,7 +114,7 @@ org.springframework.boot.experimental spring-boot-thin-maven-plugin - ${wrapper.version} + ${thin.version} diff --git a/spring-boot-gradle/build.gradle b/spring-boot-gradle/build.gradle index caeaa19c1ae3..96055536c36a 100644 --- a/spring-boot-gradle/build.gradle +++ b/spring-boot-gradle/build.gradle @@ -1,14 +1,16 @@ buildscript { ext { + springBootPlugin = 'org.springframework.boot:spring-boot-gradle-plugin' springBootVersion = '2.0.2.RELEASE' - wrapperVersion = '1.0.11.RELEASE' + thinPlugin = 'org.springframework.boot.experimental:spring-boot-thin-gradle-plugin' + thinVersion = '1.0.11.RELEASE' } repositories { mavenCentral() } dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") - classpath("org.springframework.boot.experimental:spring-boot-thin-gradle-plugin:${wrapperVersion}") + classpath("${springBootPlugin}:${springBootVersion}") + classpath("${thinPlugin}:${thinVersion}") } } @@ -51,14 +53,15 @@ apply plugin: 'maven' //If you want to customize the generated pom.xml you can edit this task and add it as a dependency to the bootJar task task createPom { + def basePath = 'build/resources/main/META-INF/maven' doLast { pom { withXml(dependencyManagement.pomConfigurer) - }.writeTo("build/resources/main/META-INF/maven/${project.group}/${project.name}/pom.xml") + }.writeTo("${basePath}/${project.group}/${project.name}/pom.xml") } } //Uncomment the following to use your custom generated pom.xml -//bootJar.dependsOn = [createPom] +bootJar.dependsOn = [createPom] //Enable this to generate and use a thin.properties file //bootJar.dependsOn = [thinProperties] \ No newline at end of file