Tooling for PropertiesLauncher in JAR archives
To use PropertiesLauncher instead of JarLauncher in an
executable JAR we have provided tooling support. In Maven
(using the starter parent to default some of the settings):
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
</configuration>
</plugin>
in Gradle:
apply plugin: "spring-boot"
springBoot {
layout = 'ZIP'
}
}
[Fixes #58837492] [bs-330] Add tooling for PropertiesLauncher
This commit is contained in:
@@ -16,13 +16,35 @@
|
||||
|
||||
package org.springframework.boot.gradle
|
||||
|
||||
import org.springframework.boot.loader.tools.Layout
|
||||
import org.springframework.boot.loader.tools.Layouts
|
||||
|
||||
/**
|
||||
* Gradle DSL Extension for 'Spring Boot'.
|
||||
* Gradle DSL Extension for 'Spring Boot'. Most of the time Spring Boot can guess the
|
||||
* settings in this extension, but occasionally you might need to explicitly set one
|
||||
* or two of them. E.g.
|
||||
*
|
||||
* <pre>
|
||||
* apply plugin: "spring-boot"
|
||||
* springBoot {
|
||||
* mainClass = 'org.demo.Application'
|
||||
* layout = 'ZIP'
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class SpringBootPluginExtension {
|
||||
|
||||
static enum LayoutType {
|
||||
JAR(new Layouts.Jar()), WAR(new Layouts.War()), ZIP(new Layouts.Expanded()), DIR(new Layouts.Expanded());
|
||||
Layout layout;
|
||||
private LayoutType(Layout layout) {
|
||||
this.layout = layout;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The main class that should be run. If not specified the value from the
|
||||
* MANIFEST will be used, or if no manifest entry is the archive will be
|
||||
@@ -31,7 +53,8 @@ public class SpringBootPluginExtension {
|
||||
String mainClass
|
||||
|
||||
/**
|
||||
* The name of the provided configuration. If not specified 'providedRuntime' will
|
||||
* The name of the ivy configuration name to treat as 'provided' (when packaging
|
||||
* those dependencies in a separate path). If not specified 'providedRuntime' will
|
||||
* be used.
|
||||
*/
|
||||
String providedConfiguration
|
||||
@@ -40,4 +63,23 @@ public class SpringBootPluginExtension {
|
||||
* If the original source archive should be backed-up before being repackaged.
|
||||
*/
|
||||
boolean backupSource = true;
|
||||
|
||||
/**
|
||||
* The layout of the archive if it can't be derived from the file extension.
|
||||
* Valid values are JAR, WAR, ZIP, DIR (for exploded zip file). ZIP and DIR
|
||||
* are actually synonymous, and should be used if there is no MANIFEST.MF
|
||||
* available, or if you want the MANIFEST.MF 'Main-Class' to be
|
||||
* PropertiesLauncher. Gradle will coerce literal String values to the
|
||||
* correct type.
|
||||
*/
|
||||
LayoutType layout;
|
||||
|
||||
/**
|
||||
* Convenience method for use in a custom task.
|
||||
*
|
||||
* @return the Layout to use or null if not explicitly set
|
||||
*/
|
||||
Layout convertLayout() {
|
||||
layout==null ? null : layout.layout
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,11 +50,13 @@ public class Repackage extends DefaultTask {
|
||||
if (file.exists()) {
|
||||
Repackager repackager = new Repackager(file);
|
||||
repackager.setMainClass(extension.getMainClass());
|
||||
if (extension.convertLayout() != null) {
|
||||
repackager.setLayout(extension.convertLayout());
|
||||
}
|
||||
repackager.setBackupSource(extension.isBackupSource());
|
||||
try {
|
||||
repackager.repackage(libraries);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
} catch (IOException ex) {
|
||||
throw new IllegalStateException(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#Generated by Git-Commit-Id-Plugin
|
||||
#Tue Oct 15 11:07:38 EDT 2013
|
||||
git.commit.id.abbrev=d3fa609
|
||||
#Tue Oct 15 11:35:18 EDT 2013
|
||||
git.commit.id.abbrev=ea11daf
|
||||
git.commit.user.email=dsyer@gopivotal.com
|
||||
git.commit.message.full=Extend PropertiesLauncher to load nested archives\n\nPropertiesLauncher can now be used to run an executable jar, and by\ndefault it will pick up nested archives in lib/ (where the Boot\ntools puts them). User can provide loader.path (colon-separated)\nto change the nested path.\n\n[\#58837492] [bs-330] Add tooling for PropertiesLauncher\n
|
||||
git.commit.id=d3fa60955b06fe78bbf0c914928d794661aca312
|
||||
git.commit.id=ea11dafcbd951b3b23257585bce1f479ca9faa73
|
||||
git.commit.message.short=Extend PropertiesLauncher to load nested archives
|
||||
git.commit.user.name=Dave Syer
|
||||
git.build.user.name=Dave Syer
|
||||
git.build.user.email=dsyer@gopivotal.com
|
||||
git.branch=master
|
||||
git.commit.time=2013-10-15T10\:51\:03-0400
|
||||
git.build.time=2013-10-15T11\:07\:38-0400
|
||||
git.commit.time=2013-10-15T11\:08\:45-0400
|
||||
git.build.time=2013-10-15T11\:35\:18-0400
|
||||
|
||||
Reference in New Issue
Block a user