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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user