java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.gradle.api.internal.ConventionTask
org.gradle.api.tasks.AbstractCopyTask
org.gradle.api.tasks.bundling.AbstractArchiveTask
org.gradle.api.tasks.bundling.Zip
org.gradle.jvm.tasks.Jar
org.gradle.api.tasks.bundling.Jar
org.springframework.boot.gradle.tasks.bundling.BootJar
All Implemented Interfaces:
Comparable<org.gradle.api.Task>, org.gradle.api.file.ContentFilterable, org.gradle.api.file.CopyProcessingSpec, org.gradle.api.file.CopySourceSpec, org.gradle.api.file.CopySpec, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.file.copy.CopySpecSource, org.gradle.api.internal.IConventionAware, org.gradle.api.internal.TaskInternal, org.gradle.api.plugins.ExtensionAware, org.gradle.api.Task, org.gradle.api.tasks.util.PatternFilterable, org.gradle.util.Configurable<org.gradle.api.Task>, BootArchive

@DisableCachingByDefault(because="Not worth caching") public class BootJar extends org.gradle.api.tasks.bundling.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
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.gradle.api.Task

    org.gradle.api.Task.Namer
  • Field Summary

    Fields inherited from class org.gradle.jvm.tasks.Jar

    DEFAULT_EXTENSION

    Fields inherited from class org.gradle.api.tasks.bundling.Zip

    ZIP_EXTENSION

    Fields inherited from interface org.gradle.api.Task

    TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new BootJar task.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.gradle.api.file.CopySpec
    bootInf(org.gradle.api.Action<org.gradle.api.file.CopySpec> action)
    Calls the given action to add content to the BOOT-INF directory of the jar.
    void
    classpath(Object... classpath)
    Adds files to the classpath to include in the archive.
    void
     
    protected org.gradle.api.internal.file.copy.CopyAction
     
    org.gradle.api.file.CopySpec
    Returns a CopySpec that can be used to add content to the BOOT-INF directory of the jar.
    org.gradle.api.file.FileCollection
    Returns the classpath that will be included in the archive.
    Returns the LaunchScriptConfiguration that will control the script that is prepended to the archive.
    Returns the spec that describes the layers in a layered jar.
    org.gradle.api.provider.Property<String>
    Returns the fully-qualified name of the application's main class.
    protected boolean
    isLibrary(org.gradle.api.file.FileCopyDetails details)
    Return if the FileCopyDetails are for a library.
    void
    Configures the archive to have a prepended launch script.
    void
    launchScript(org.gradle.api.Action<LaunchScriptConfiguration> action)
    Configures the archive to have a prepended launch script, customizing its configuration using the given action.
    void
    layered(org.gradle.api.Action<LayeredSpec> action)
    Configures the jar's layering using the given action.
    void
    requiresUnpack(String... patterns)
    Adds Ant-style patterns that identify files that must be unpacked from the archive when it is launched.
    void
    requiresUnpack(org.gradle.api.specs.Spec<org.gradle.api.file.FileTreeElement> spec)
    Adds a spec that identifies files that must be unpacked from the archive when it is launched.
    protected ZipCompression
    resolveZipCompression(org.gradle.api.file.FileCopyDetails details)
    Return the ZipCompression that should be used when adding the file represented by the given details to the jar.
    void
    setClasspath(Object classpath)
    Sets the classpath to include in the archive.
    void
    setClasspath(org.gradle.api.file.FileCollection classpath)
    Sets the classpath to include in the archive.

    Methods inherited from class org.gradle.api.tasks.bundling.Jar

    manifest

    Methods inherited from class org.gradle.jvm.tasks.Jar

    getManifest, getManifestContentCharset, getMetadataCharset, getMetaInf, manifest, metaInf, metaInf, setManifest, setManifestContentCharset, setMetadataCharset

    Methods inherited from class org.gradle.api.tasks.bundling.Zip

    getCompressor, getEntryCompression, isZip64, setEntryCompression, setZip64

    Methods inherited from class org.gradle.api.tasks.bundling.AbstractArchiveTask

    createCopyActionExecuter, getAppendix, getArchiveAppendix, getArchiveBaseName, getArchiveClassifier, getArchiveExtension, getArchiveFile, getArchiveFileName, getArchiveName, getArchivePath, getArchiveVersion, getBaseName, getClassifier, getDestinationDir, getDestinationDirectory, getExtension, getVersion, into, into, into, isPreserveFileTimestamps, isReproducibleFileOrder, setAppendix, setArchiveName, setBaseName, setClassifier, setDestinationDir, setExtension, setPreserveFileTimestamps, setReproducibleFileOrder, setVersion

    Methods inherited from class org.gradle.api.tasks.AbstractCopyTask

    createRootSpec, eachFile, eachFile, exclude, exclude, exclude, exclude, expand, expand, filesMatching, filesMatching, filesNotMatching, filesNotMatching, filter, filter, filter, filter, from, from, from, getDirectoryFileTreeFactory, getDirMode, getDocumentationRegistry, getDuplicatesStrategy, getExcludes, getFileLookup, getFileMode, getFileResolver, getFileSystem, getFilteringCharset, getIncludeEmptyDirs, getIncludes, getInstantiator, getMainSpec, getObjectFactory, getRootSpec, getSource, include, include, include, include, isCaseSensitive, rename, rename, rename, rename, setCaseSensitive, setDirMode, setDuplicatesStrategy, setExcludes, setFileMode, setFilteringCharset, setIncludeEmptyDirs, setIncludes, with

    Methods inherited from class org.gradle.api.internal.ConventionTask

    conventionMapping, conventionMapping, getConventionMapping

    Methods inherited from class org.gradle.api.DefaultTask

    compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService

    Methods inherited from class org.gradle.api.internal.AbstractTask

    appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getOnlyIf, getReasonNotToTrackState, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isEnabled, isHasCustomActions, prependParallelSafeAction, setImpliesSubProjects

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Comparable

    compareTo

    Methods inherited from interface org.gradle.api.plugins.ExtensionAware

    getExtensions

    Methods inherited from interface org.gradle.api.Task

    configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, doNotTrackState, finalizedBy, getActions, getAnt, getConvention, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getFinalizedBy, getGroup, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getPath, getProject, getShouldRunAfter, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService
  • Constructor Details

    • BootJar

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

    • copy

      public void copy()
      Overrides:
      copy in class org.gradle.api.tasks.AbstractCopyTask
    • createCopyAction

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

      public org.gradle.api.provider.Property<String> getMainClass()
      Description copied from interface: BootArchive
      Returns the fully-qualified name of the application's main class.
      Specified by:
      getMainClass in interface BootArchive
      Returns:
      the fully-qualified name of the application's main class
    • 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(org.gradle.api.specs.Spec<org.gradle.api.file.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(org.gradle.api.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(org.gradle.api.Action<LayeredSpec> action)
      Configures the jar's layering using the given action.
      Parameters:
      action - the action to apply
      Since:
      2.3.0
    • getClasspath

      public org.gradle.api.file.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(org.gradle.api.file.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 org.gradle.api.file.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 org.gradle.api.file.CopySpec bootInf(org.gradle.api.Action<org.gradle.api.file.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(org.gradle.api.file.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(org.gradle.api.file.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