diff --git a/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc b/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc index 8a4f14aa4aa..a706c9c17bb 100644 --- a/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc +++ b/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc @@ -125,6 +125,31 @@ To build and run a project artifact, you can type the following: $ java -jar target/mymodule-0.0.1-SNAPSHOT.jar ---- +To build a war file that is both executable and deployable into an external container +you need to mark the embedded container dependencies as "provided", e.g. + +[source,xml,indent=0,subs="verbatim,attributes"] +---- + + + + war + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + +---- [[build-tool-plugins-maven-packaging-configuration]] @@ -347,6 +372,35 @@ To build and run a project artifact, you can type the following: $ java -jar build/libs/mymodule-0.0.1-SNAPSHOT.jar ---- +To build a war file that is both executable and deployable into an external container, +you need to mark the embedded container dependencies as belonging to a configuration +named "providedRuntime", e.g. + +[source,groovy,indent=0,subs="verbatim,attributes"] +---- +... +apply plugin: 'war' + +war { + baseName = 'myapp' + version = '0.5.0' +} + +repositories { + mavenCentral() + maven { url "http://repo.spring.io/libs-snapshot" } +} + +configurations { + providedRuntime +} + +dependencies { + compile("org.springframework.boot:spring-boot-starter-web") + providedRuntime("org.springframework.boot:spring-boot-starter-tomcat") + ... +} +---- [[build-tool-plugins-gradle-running-applications]] diff --git a/spring-boot-samples/spring-boot-sample-web-static/build.gradle b/spring-boot-samples/spring-boot-sample-web-static/build.gradle new file mode 100644 index 00000000000..a3105654604 --- /dev/null +++ b/spring-boot-samples/spring-boot-sample-web-static/build.gradle @@ -0,0 +1,43 @@ +buildscript { + ext { + springBootVersion = '1.0.0.BUILD-SNAPSHOT' + } + repositories { + mavenLocal() + maven { url "http://repo.spring.io/libs-snapshot" } + } + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") + } +} + + +apply plugin: 'java' +apply plugin: 'eclipse-wtp' +apply plugin: 'idea' +apply plugin: 'spring-boot' +apply plugin: 'war' + +mainClassName = "sample.ui.SampleWebStaticApplication" + +war { + baseName = 'spring-boot-sample-web-static' + version = '0.5.0' +} + +repositories { + mavenCentral() + maven { url "http://repo.spring.io/libs-snapshot" } +} + +configurations { + providedRuntime +} + +dependencies { + compile("org.springframework.boot:spring-boot-starter-web") + providedRuntime("org.springframework.boot:spring-boot-starter-tomcat") + testCompile("org.springframework.boot:spring-boot-starter-test") +} + +task wrapper(type: Wrapper) { gradleVersion = '1.6' } diff --git a/spring-boot-samples/spring-boot-sample-web-ui/build.gradle b/spring-boot-samples/spring-boot-sample-web-ui/build.gradle index 90a62d3be10..ac1dd4a26bf 100644 --- a/spring-boot-samples/spring-boot-sample-web-ui/build.gradle +++ b/spring-boot-samples/spring-boot-sample-web-ui/build.gradle @@ -22,7 +22,7 @@ apply plugin: 'spring-boot' mainClassName = "sample.ui.SampleWebUiApplication" jar { - baseName = 'spring-boot-sample-simple' + baseName = 'spring-boot-sample-web-ui' version = '0.5.0' }