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:
Phillip Webb
2015-10-20 16:49:06 -07:00
parent fe42ced7ab
commit a7a2aa0461
5 changed files with 56 additions and 6 deletions

View File

@@ -4,6 +4,8 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.boot.maven.it</groupId>
<artifactId>jar-executable</artifactId>
<name>MyFullyExecutableJarName</name>
<description>MyFullyExecutableJarDesc</description>
<version>0.0.1.BUILD-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@@ -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");

View File

@@ -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.
*/