diff --git a/spring-boot-docs/src/main/asciidoc/deployment.adoc b/spring-boot-docs/src/main/asciidoc/deployment.adoc index 9cb8c1b625c..a8b0835fab9 100644 --- a/spring-boot-docs/src/main/asciidoc/deployment.adoc +++ b/spring-boot-docs/src/main/asciidoc/deployment.adoc @@ -454,6 +454,28 @@ the default behavior in a script or on the command line: in the script. |=== +In addition, the following properties can be changed when the script is written by using +the `embeddedLaunchScriptProperties` option of the Spring Boot Maven or Gradle plugins. + +[cols="1,6"] +|=== +|Name |Description + +|`mode` +|The script mode. Defaults to `auto`. + +|`initInfoProvides` +|The `Provides` section of "`INIT INFO`". Defaults to `spring-boot-application` for Gradle +and to `${project.artifactId}` for Maven. + +|`initInfoShortDescription` +|The `Short-Description` section of "`INIT INFO`". Defaults to `Spring Boot Application` +for Gradle and to `${project.name}` for Maven. + +|`initInfoDescription` +|The `Description` section of "`INIT INFO`". Defaults to `Spring Boot Application` for +Gradle and to `${project.description}` (falling back to `${project.name}`) for Maven. +|=== [[deployment-script-customization-conf-file]] diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script index 435abfc0d06..247fc278d9b 100755 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script @@ -10,13 +10,13 @@ # ### BEGIN INIT INFO -# Provides: spring-boot-application +# Provides: {{initInfoProvides:spring-boot-application}} # Required-Start: $remote_fs $syslog $network # Required-Stop: $remote_fs $syslog $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: Spring Boot Application -# Description: Spring Boot Application +# Short-Description: {{initInfoShortDescription:Spring Boot Application}} +# Description: {{initInfoDescription:Spring Boot Application}} # chkconfig: 2345 99 01 ### END INIT INFO 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 index b8b19b5416d..769b509c7d7 100644 --- 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 @@ -4,6 +4,8 @@ 4.0.0 org.springframework.boot.maven.it jar-executable + MyFullyExecutableJarName + MyFullyExecutableJarDesc 0.0.1.BUILD-SNAPSHOT UTF-8 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 index 3616b5acd15..7fda11821de 100644 --- 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 @@ -2,6 +2,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" -); + new File( basedir, "target/jar-executable-0.0.1.BUILD-SNAPSHOT.jar" ), + "some.random.Main", "Spring Boot Startup Script", "MyFullyExecutableJarName", + "MyFullyExecutableJarDesc"); 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 03ff3df4414..90cc5033c89 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 @@ -248,11 +248,36 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { private LaunchScript getLaunchScript() throws IOException { if (this.executable || this.embeddedLaunchScript != null) { return new DefaultLaunchScript(this.embeddedLaunchScript, - this.embeddedLaunchScriptProperties); + buildLaunchScriptProperties()); } return null; } + private Properties buildLaunchScriptProperties() { + Properties properties = new Properties(); + if (this.embeddedLaunchScriptProperties != null) { + properties.putAll(this.embeddedLaunchScriptProperties); + } + putIfMissing(properties, "initInfoProvides", this.project.getArtifactId()); + putIfMissing(properties, "initInfoShortDescription", this.project.getName(), + this.project.getArtifactId()); + putIfMissing(properties, "initInfoDescription", this.project.getDescription(), + this.project.getName(), this.project.getArtifactId()); + return properties; + } + + private void putIfMissing(Properties properties, String key, + String... valueCandidates) { + if (!properties.containsKey(key)) { + for (String candidate : valueCandidates) { + if (candidate != null && candidate.length() > 0) { + properties.put(key, candidate); + return; + } + } + } + } + /** * Archive layout types. */