diff --git a/spring-boot-docs/src/main/asciidoc/deployment.adoc b/spring-boot-docs/src/main/asciidoc/deployment.adoc
index 2827781cc8..399a12fae0 100644
--- a/spring-boot-docs/src/main/asciidoc/deployment.adoc
+++ b/spring-boot-docs/src/main/asciidoc/deployment.adoc
@@ -305,10 +305,39 @@ of this guide.
[[deployment-service]]
== Installing Spring Boot applications
In additional to running Spring Boot applications using `java -jar` it is also possible
-to execute applications directly on Unix systems (Linux, OSX, FreeBSD etc). This makes it
-very easy to install and manage Spring Boot applications in common production
-environments. As long as you are generating '`fully executable`' jars from your build, and
-you are not using a custom `embeddedLaunchScript`, the following techniques can be used.
+to make fully executable applications for Unix systems (Linux, OSX, FreeBSD etc).
+This makes it very easy to install and manage Spring Boot applications in common
+production environments. As long as you are generating '`fully executable`' jars from your
+build, and you are not using a custom `embeddedLaunchScript`, the following techniques
+can be used.
+
+To create a '`fully executable`' jar with Maven use the following plugin configuration:
+
+[source,xml,indent=0,subs="verbatim,quotes,attributes"]
+----
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ true
+
+
+----
+
+With Gradle, the equivalent configuration would be:
+
+[source,groovy,indent=0,subs="verbatim,quotes,attributes"]
+----
+ apply plugin: 'spring-boot'
+
+ springBoot {
+ executable = true
+ }
+----
+
+NOTE: Fully executable jars work by embedding an extra script at the front of the file.
+Not all tools currently accept this format so you may not always be able to use this
+technique.
@@ -318,9 +347,9 @@ or `systemd`.
-==== Installation as a init.d (System V) service
-The default executable script that is embedded into Spring Boot executable jars will act
-as an `init.d` script when it is symlinked to `/etc/init.d`. The standard `start`, `stop`,
+==== Installation as a init.d service (System V)
+The default executable script that can be embedded into Spring Boot jars will act as an
+`init.d` script when it is symlinked to `/etc/init.d`. The standard `start`, `stop`,
`restart` and `status` commands can be used. The script supports the following features:
* Starts the services as the user that owns the jar file
@@ -349,7 +378,32 @@ if you use Debian:
-=== Running a JAR as a regular (not service) script
+==== Installation as a systemd service
+Systemd is the successor to `init.d` scripts, and now being used by many many modern Linux
+distributions. Although you can continue to use `init.d` script with `systemd`, it is also
+possible to launch Spring Boot applications using `systemd` '`service`' scripts.
+
+For example, to run a Spring Boot application installed in `var/myapp` you can add the
+following script in `/etc/systemd/system/myapp.service`:
+
+[indent=0]
+----
+ [Unit]
+ Description=myapp
+ After=syslog.target
+
+ [Service]
+ ExecStart=/var/myapp/myapp.jar
+
+ [Install]
+ WantedBy=multi-user.target
+----
+
+TIP: Remember to change the `Description` and `ExecStart` fields for your application.
+
+
+
+==== Customizing the startup script
The script accepts the following parameters as environment variables, so you can change
the default behavior in a script or on the command line:
@@ -358,11 +412,11 @@ the default behavior in a script or on the command line:
|Variable |Description
|`MODE`
-|The "mode" of operation. The default depends on the way the jar was built, but will
- usually be "auto" (meaning it tries to guess if it is an init script by checking if it
- is a symlink in a directory called "init.d"). You can explicitly set it to "service" so
- that the "stop|start|status|restart" commands work, or to "run" if you just want to run
- the script and not in the background.
+|The "`mode`" of operation. The default depends on the way the jar was built, but will
+ usually be `auto` _(meaning it tries to guess if it is an init script by checking if it
+ is a symlink in a directory called `init.d`)_. You can explicitly set it to `service` so
+ that the `stop\|start\|status\|restart` commands work, or to `run` if you just want to
+ run the script in the foreground.
|`PID_FOLDER`
|The root name of the pid folder (`/var/run` by default).
@@ -390,31 +444,6 @@ the default behavior in a script or on the command line:
-==== Installation as a systemd service
-Systemd is the successor to `init.d` scripts, and now being used by many many modern Linux
-distributions. Although you can continue to use `init.d` script with `systemd`, it is also
-possible to launch Spring Boot applications using `systemd` '`service`' scripts.
-
-For example, to run a Spring Boot application installed in `var/myapp` you can add the
-following script in `/etc/systemd/system/myapp.service`:
-
-[indent=0]
-----
- [Unit]
- Description=myapp
- After=syslog.target
-
- [Service]
- ExecStart=/var/myapp/myapp.jar
-
- [Install]
- WantedBy=multi-user.target
-----
-
-TIP: Remember to change the `Description` and `ExecStart` fields for your application.
-
-
-
[[deployment-whats-next]]
== What to read next
Check out the http://www.cloudfoundry.com/[Cloud Foundry], https://www.heroku.com/[Heroku]
diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPluginExtension.groovy b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPluginExtension.groovy
index a81a27bfdc..196887f502 100644
--- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPluginExtension.groovy
+++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPluginExtension.groovy
@@ -137,7 +137,7 @@ public class SpringBootPluginExtension {
* If a fully executable jar (for *nix machines) should be generated by prepending a
* launch script to the jar.
*/
- boolean executable = true;
+ boolean executable = false;
/**
* The embedded launch script to prepend to the front of the jar if it is fully
diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/repackage/RepackageTask.java b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/repackage/RepackageTask.java
index 97d7fdea71..7b393fb982 100644
--- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/repackage/RepackageTask.java
+++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/repackage/RepackageTask.java
@@ -210,7 +210,8 @@ public class RepackageTask extends DefaultTask {
}
private LaunchScript getLaunchScript() throws IOException {
- if (this.extension.isExecutable()) {
+ if (this.extension.isExecutable()
+ || extension.getEmbeddedLaunchScript() != null) {
return new DefaultLaunchScript(this.extension.getEmbeddedLaunchScript(),
this.extension.getEmbeddedLaunchScriptProperties());
}
diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-executable/pom.xml b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-executable/pom.xml
new file mode 100644
index 0000000000..b8b19b5416
--- /dev/null
+++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-executable/pom.xml
@@ -0,0 +1,58 @@
+
+
+ 4.0.0
+ org.springframework.boot.maven.it
+ jar-executable
+ 0.0.1.BUILD-SNAPSHOT
+
+ UTF-8
+
+
+
+
+ @project.groupId@
+ @project.artifactId@
+ @project.version@
+
+
+
+ repackage
+
+
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 2.4
+
+
+
+ some.random.Main
+
+
+ Foo
+
+
+
+
+
+
+
+
+ org.springframework
+ spring-context
+ @spring.version@
+
+
+ javax.servlet
+ javax.servlet-api
+ @servlet-api.version@
+ provided
+
+
+
diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-executable/src/main/java/org/test/SampleApplication.java b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-executable/src/main/java/org/test/SampleApplication.java
new file mode 100644
index 0000000000..403cd96845
--- /dev/null
+++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-executable/src/main/java/org/test/SampleApplication.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2012-2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.test;
+
+public class SampleApplication {
+
+ public static void main(String[] args) {
+ }
+
+}
diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-executable/verify.groovy b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-executable/verify.groovy
new file mode 100644
index 0000000000..3616b5acd1
--- /dev/null
+++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar-executable/verify.groovy
@@ -0,0 +1,7 @@
+import java.io.*;
+import org.springframework.boot.maven.*;
+
+Verify.verifyJar(
+ new File( basedir, "target/jar-executable-0.0.1.BUILD-SNAPSHOT.jar" ), "some.random.Main", "Spring Boot Startup Script"
+);
+
diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar/verify.groovy b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar/verify.groovy
index 8b5af07aa8..07b375b51f 100644
--- a/spring-boot-tools/spring-boot-maven-plugin/src/it/jar/verify.groovy
+++ b/spring-boot-tools/spring-boot-maven-plugin/src/it/jar/verify.groovy
@@ -2,6 +2,6 @@ import java.io.*;
import org.springframework.boot.maven.*;
Verify.verifyJar(
- new File( basedir, "target/jar-0.0.1.BUILD-SNAPSHOT.jar" ), "some.random.Main", "Spring Boot Startup Script"
+ new File( basedir, "target/jar-0.0.1.BUILD-SNAPSHOT.jar" ), "some.random.Main"
);
diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java
index 63fc856e62..6e3602268d 100644
--- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java
+++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java
@@ -132,7 +132,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
* jar.
* @since 1.3
*/
- @Parameter(defaultValue = "true")
+ @Parameter(defaultValue = "false")
private boolean executable;
/**
@@ -218,7 +218,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
}
private LaunchScript getLaunchScript() throws IOException {
- if (this.executable) {
+ if (this.executable || this.embeddedLaunchScript != null) {
return new DefaultLaunchScript(this.embeddedLaunchScript,
this.embeddedLaunchScriptProperties);
}