Add "INIT INFO" property substitutions
Update the "INIT INFO section" of `launch.script` to include
`initInfoProvides`, `initInfoShortDescription` and `initInfoDescription`
property substitutions.
The Maven plugin has been updated to populate substitutions with
`${project.artifactId}`, `${project.name}` and `${project.description}`.
Fixes gh-4245
This commit is contained in:
parent
fe42ced7ab
commit
a7a2aa0461
|
|
@ -454,6 +454,28 @@ the default behavior in a script or on the command line:
|
||||||
in the script.
|
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]]
|
[[deployment-script-customization-conf-file]]
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,13 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
### BEGIN INIT INFO
|
### BEGIN INIT INFO
|
||||||
# Provides: spring-boot-application
|
# Provides: {{initInfoProvides:spring-boot-application}}
|
||||||
# Required-Start: $remote_fs $syslog $network
|
# Required-Start: $remote_fs $syslog $network
|
||||||
# Required-Stop: $remote_fs $syslog $network
|
# Required-Stop: $remote_fs $syslog $network
|
||||||
# Default-Start: 2 3 4 5
|
# Default-Start: 2 3 4 5
|
||||||
# Default-Stop: 0 1 6
|
# Default-Stop: 0 1 6
|
||||||
# Short-Description: Spring Boot Application
|
# Short-Description: {{initInfoShortDescription:Spring Boot Application}}
|
||||||
# Description: Spring Boot Application
|
# Description: {{initInfoDescription:Spring Boot Application}}
|
||||||
# chkconfig: 2345 99 01
|
# chkconfig: 2345 99 01
|
||||||
### END INIT INFO
|
### END INIT INFO
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.springframework.boot.maven.it</groupId>
|
<groupId>org.springframework.boot.maven.it</groupId>
|
||||||
<artifactId>jar-executable</artifactId>
|
<artifactId>jar-executable</artifactId>
|
||||||
|
<name>MyFullyExecutableJarName</name>
|
||||||
|
<description>MyFullyExecutableJarDesc</description>
|
||||||
<version>0.0.1.BUILD-SNAPSHOT</version>
|
<version>0.0.1.BUILD-SNAPSHOT</version>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import java.io.*;
|
||||||
import org.springframework.boot.maven.*;
|
import org.springframework.boot.maven.*;
|
||||||
|
|
||||||
Verify.verifyJar(
|
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");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -248,11 +248,36 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
|
||||||
private LaunchScript getLaunchScript() throws IOException {
|
private LaunchScript getLaunchScript() throws IOException {
|
||||||
if (this.executable || this.embeddedLaunchScript != null) {
|
if (this.executable || this.embeddedLaunchScript != null) {
|
||||||
return new DefaultLaunchScript(this.embeddedLaunchScript,
|
return new DefaultLaunchScript(this.embeddedLaunchScript,
|
||||||
this.embeddedLaunchScriptProperties);
|
buildLaunchScriptProperties());
|
||||||
}
|
}
|
||||||
return null;
|
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.
|
* Archive layout types.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue