Support custom fat jar layouts

Allow support for custom Lyout implementations with both the Maven
and Gradle plugin. Implementations of `LayoutFactory` can now be
specified to allow customization of the layout. In addition a
layout may now implement `CustomLoaderLayout` if it wishes to
write custom loader classes.

See gh-7263
This commit is contained in:
Dave Syer
2016-11-18 14:42:28 -08:00
committed by Phillip Webb
parent f5b03c81f3
commit c6c6524b40
14 changed files with 444 additions and 22 deletions

View File

@@ -26,6 +26,7 @@ import org.gradle.api.plugins.JavaPlugin;
import org.springframework.boot.gradle.buildinfo.BuildInfo;
import org.springframework.boot.loader.tools.Layout;
import org.springframework.boot.loader.tools.LayoutFactory;
import org.springframework.boot.loader.tools.Layouts;
/**
@@ -90,6 +91,12 @@ public class SpringBootPluginExtension {
*/
LayoutType layout;
/**
* The layout factory that will be used when no explicit layout is specified.
* Alternative layouts can be provided by 3rd parties.
*/
LayoutFactory layoutFactory;
/**
* Libraries that must be unpacked from fat jars in order to run. Use Strings in the
* form {@literal groupId:artifactId}.
@@ -196,6 +203,14 @@ public class SpringBootPluginExtension {
this.layout = layout;
}
public LayoutFactory getLayoutFactory() {
return this.layoutFactory;
}
public void setLayoutFactory(LayoutFactory layoutFactory) {
this.layoutFactory = layoutFactory;
}
public Set<String> getRequiresUnpack() {
return this.requiresUnpack;
}

View File

@@ -213,7 +213,8 @@ public class RepackageTask extends DefaultTask {
copy(file, outputFile);
file = outputFile;
}
Repackager repackager = new Repackager(file);
Repackager repackager = new Repackager(file,
this.extension.getLayoutFactory());
repackager.addMainClassTimeoutWarningListener(
new LoggingMainClassTimeoutWarningListener());
setMainClass(repackager);