All Implemented Interfaces:
Comparable<Task>, ContentFilterable, CopyProcessingSpec, CopySourceSpec, CopySpec, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.file.copy.CopySpecSource, org.gradle.api.internal.IConventionAware, org.gradle.api.internal.TaskInternal, ExtensionAware, Task, PatternFilterable, Configurable<Task>, BootArchive

@DisableCachingByDefault(because="Not worth caching") public abstract class BootJar extends Jar implements BootArchive
A custom Jar task that produces a Spring Boot executable jar.
Since:
2.0.0
Author:
Andy Wilkinson, Madhura Bhave, Scott Frederick, Phillip Webb
  • Constructor Details

    • BootJar

      public BootJar()
      Creates a new BootJar task.
  • Method Details

    • copy

      public void copy()
      Overrides:
      copy in class AbstractCopyTask
    • createCopyAction

      protected org.gradle.api.internal.file.copy.CopyAction createCopyAction()
      Overrides:
      createCopyAction in class Zip
    • requiresUnpack

      public void requiresUnpack(String... patterns)
      Description copied from interface: BootArchive
      Adds Ant-style patterns that identify files that must be unpacked from the archive when it is launched.
      Specified by:
      requiresUnpack in interface BootArchive
      Parameters:
      patterns - the patterns
    • requiresUnpack

      public void requiresUnpack(Spec<FileTreeElement> spec)
      Description copied from interface: BootArchive
      Adds a spec that identifies files that must be unpacked from the archive when it is launched.
      Specified by:
      requiresUnpack in interface BootArchive
      Parameters:
      spec - the spec
    • getLaunchScript

      public LaunchScriptConfiguration getLaunchScript()
      Description copied from interface: BootArchive
      Returns the LaunchScriptConfiguration that will control the script that is prepended to the archive.
      Specified by:
      getLaunchScript in interface BootArchive
      Returns:
      the launch script configuration, or null if the launch script has not been configured.
    • launchScript

      public void launchScript()
      Description copied from interface: BootArchive
      Configures the archive to have a prepended launch script.
      Specified by:
      launchScript in interface BootArchive
    • launchScript

      public void launchScript(Action<LaunchScriptConfiguration> action)
      Description copied from interface: BootArchive
      Configures the archive to have a prepended launch script, customizing its configuration using the given action.
      Specified by:
      launchScript in interface BootArchive
      Parameters:
      action - the action to apply
    • getLayered

      public LayeredSpec getLayered()
      Returns the spec that describes the layers in a layered jar.
      Returns:
      the spec for the layers
      Since:
      2.3.0
    • layered

      public void layered(Action<LayeredSpec> action)
      Configures the jar's layering using the given action.
      Parameters:
      action - the action to apply
      Since:
      2.3.0
    • getClasspath

      public FileCollection getClasspath()
      Description copied from interface: BootArchive
      Returns the classpath that will be included in the archive.
      Specified by:
      getClasspath in interface BootArchive
      Returns:
      the classpath
    • classpath

      public void classpath(Object... classpath)
      Description copied from interface: BootArchive
      Adds files to the classpath to include in the archive. The given classpath is evaluated as per Project.files(Object...).
      Specified by:
      classpath in interface BootArchive
      Parameters:
      classpath - the additions to the classpath
    • setClasspath

      public void setClasspath(Object classpath)
      Description copied from interface: BootArchive
      Sets the classpath to include in the archive. The given classpath is evaluated as per Project.files(Object...).
      Specified by:
      setClasspath in interface BootArchive
      Parameters:
      classpath - the classpath
    • setClasspath

      public void setClasspath(FileCollection classpath)
      Description copied from interface: BootArchive
      Sets the classpath to include in the archive.
      Specified by:
      setClasspath in interface BootArchive
      Parameters:
      classpath - the classpath
    • getBootInf

      @Internal public CopySpec getBootInf()
      Returns a CopySpec that can be used to add content to the BOOT-INF directory of the jar.
      Returns:
      a CopySpec for BOOT-INF
      Since:
      2.0.3
    • bootInf

      public CopySpec bootInf(Action<CopySpec> action)
      Calls the given action to add content to the BOOT-INF directory of the jar.
      Parameters:
      action - the Action to call
      Returns:
      the CopySpec for BOOT-INF that was passed to the Action
      Since:
      2.0.3
    • resolveZipCompression

      protected ZipCompression resolveZipCompression(FileCopyDetails details)
      Return the ZipCompression that should be used when adding the file represented by the given details to the jar. By default, any library is stored and all other files are deflated.
      Parameters:
      details - the file copy details
      Returns:
      the compression to use
    • isLibrary

      protected boolean isLibrary(FileCopyDetails details)
      Return if the FileCopyDetails are for a library. By default any file in BOOT-INF/lib is considered to be a library.
      Parameters:
      details - the file copy details
      Returns:
      true if the details are for a library
      Since:
      2.3.0