@ -1,5 +1,5 @@
/ *
* Copyright 2012 - 202 0 the original author or authors .
* Copyright 2012 - 202 1 the original author or authors .
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -53,6 +53,7 @@ import org.springframework.boot.loader.tools.layer.CustomLayers;
* Abstract base class for classes that work with an { @link Packager } .
*
* @author Phillip Webb
* @author Scott Frederick
* @since 2.3 .0
* /
public abstract class AbstractPackagerMojo extends AbstractDependencyFilterMojo {
@ -81,24 +82,6 @@ public abstract class AbstractPackagerMojo extends AbstractDependencyFilterMojo
@Parameter
private String mainClass ;
/ * *
* The type of archive ( which corresponds to how the dependencies are laid out inside
* it ) . Possible values are { @code JAR } , { @code WAR } , { @code ZIP } , { @code DIR } ,
* { @code NONE } . Defaults to a guess based on the archive type .
* @since 1.0 .0
* /
@Parameter ( property = "spring-boot.repackage.layout" )
private LayoutType layout ;
/ * *
* The layout factory that will be used to create the executable archive if no
* explicit layout is set . Alternative layouts implementations can be provided by 3 rd
* parties .
* @since 1.5 .0
* /
@Parameter
private LayoutFactory layoutFactory ;
/ * *
* Exclude Spring Boot devtools from the repackaged archive .
* @since 1.3 .0
@ -121,6 +104,24 @@ public abstract class AbstractPackagerMojo extends AbstractDependencyFilterMojo
@Parameter
private Layers layers ;
/ * *
* Return the type of archive that should be packaged by this MOJO .
* @return { @code null } , indicating a layout type will be chosen based on the original
* archive type
* /
protected LayoutType getLayout ( ) {
return null ;
}
/ * *
* Return the layout factory that will be used to determine the { @link LayoutType } if
* no explicit layout is set .
* @return { @code null } , indicating a default layout factory will be chosen
* /
protected LayoutFactory getLayoutFactory ( ) {
return null ;
}
/ * *
* Return a { @link Packager } configured for this MOJO .
* @param < P > the packager type
@ -129,12 +130,13 @@ public abstract class AbstractPackagerMojo extends AbstractDependencyFilterMojo
* /
protected < P extends Packager > P getConfiguredPackager ( Supplier < P > supplier ) {
P packager = supplier . get ( ) ;
packager . setLayoutFactory ( this . layoutFactory ) ;
packager . setLayoutFactory ( getLayoutFactory ( ) ) ;
packager . addMainClassTimeoutWarningListener ( new LoggingMainClassTimeoutWarningListener ( this : : getLog ) ) ;
packager . setMainClass ( this . mainClass ) ;
if ( this . layout ! = null ) {
getLog ( ) . info ( "Layout: " + this . layout ) ;
packager . setLayout ( this . layout . layout ( ) ) ;
LayoutType layout = getLayout ( ) ;
if ( layout ! = null ) {
getLog ( ) . info ( "Layout: " + layout ) ;
packager . setLayout ( layout . layout ( ) ) ;
}
if ( this . layers ! = null & & this . layers . isEnabled ( ) ) {
packager . setLayers ( ( this . layers . getConfiguration ( ) ! = null )