Class AbstractBootOperation<T extends AbstractBootOperation<T>>

java.lang.Object
rife.bld.operations.AbstractOperation<AbstractBootOperation<T>>
rife.bld.extension.AbstractBootOperation<T>
Type Parameters:
T - the type parameter
Direct Known Subclasses:
BootJarOperation, BootWarOperation

public abstract class AbstractBootOperation<T extends AbstractBootOperation<T>> extends AbstractOperation<AbstractBootOperation<T>>
Implements common methods used by Spring Boot operations, such as BootJarOperation and BootWarOperation.
Since:
1.0
Author:
Erik C. Thauvin
  • Field Details

    • logger

      protected final Logger logger
  • Constructor Details

    • AbstractBootOperation

      public AbstractBootOperation()
  • Method Details

    • destinationDirectory

      public T destinationDirectory(@NonNull String directory)
      Provides the destination directory in which the archive will be created.
      Parameters:
      directory - the destination directory
      Returns:
      this operation instance
      Throws:
      NullPointerException - if directory is null
      IllegalArgumentException - if directory is empty
    • destinationDirectory

      public T destinationDirectory(@NonNull File directory)
      Provides the destination directory in which the archive will be created.
      Parameters:
      directory - the destination directory
      Returns:
      this operation instance
      Throws:
      NullPointerException - if directory is null
    • destinationDirectory

      public T destinationDirectory(@NonNull Path directory)
      Provides the destination directory in which the archive will be created.
      Parameters:
      directory - the destination directory
      Returns:
      this operation instance
      Throws:
      NullPointerException - if directory is null
    • destinationDirectory

      public File destinationDirectory()
      Retrieves the destination directory in which the archive will be created.
      Returns:
      the destination directory
    • destinationFileName

      public T destinationFileName(@NonNull String name)
      Provides the file name that will be used for the archive creation.
      Parameters:
      name - the archive file name
      Returns:
      this operation instance
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is empty
    • destinationFileName

      public String destinationFileName()
      Retrieves the file name that will be used for the archive creation.
      Returns:
      the archive file name
    • fromProject

      public abstract T fromProject(Project project)
      Configures the operation from a Project.
      Parameters:
      project - the project
      Returns:
      this operation instance
    • infLibs

      public T infLibs(@NonNull File... jars)
      Provides the libraries that will be stored in BOOT-INF or WEB-INF.
      Parameters:
      jars - one or more Java archive files
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jars is null
      IllegalArgumentException - if jars is empty, or contains null or empty elements
      See Also:
    • infLibs

      public final T infLibs(@NonNull Collection<File> jars)
      Provides the libraries that will be stored in BOOT-INF or WEB-INF.
      Parameters:
      jars - a collection of Java archive files
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jars is null
      IllegalArgumentException - if jars is empty, or contains null or empty elements
      See Also:
    • infLibs

      public T infLibs(@NonNull Path... jars)
      Provides the libraries that will be stored in BOOT-INF or WEB-INF.
      Parameters:
      jars - one or more Java archive files
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jars is null
      IllegalArgumentException - if jars is empty, or contains null or empty elements
      See Also:
    • infLibs

      public T infLibs(@NonNull String... jars)
      Provides the libraries that will be stored in BOOT-INF or WEB-INF.
      Parameters:
      jars - one or more Java archive files
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jars is null
      IllegalArgumentException - if jars is empty, or contains null or empty elements
      See Also:
    • infLibs

      public List<File> infLibs()
      Retrieves the libraries in BOOT-INF or WEB-INF.
      Returns:
      the Java archives
    • infLibsPaths

      public final T infLibsPaths(@NonNull Collection<Path> jars)
      Provides the libraries that will be stored in BOOT-INF or WEB-INF.
      Parameters:
      jars - one or more Java archive files
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jars is null
      IllegalArgumentException - if jars is empty, or contains null or empty elements
      See Also:
    • infLibsStrings

      public final T infLibsStrings(@NonNull Collection<String> jars)
      Provides the libraries that will be stored in BOOT-INF or WEB-INF.
      Parameters:
      jars - one or more Java archive files
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jars is null
      IllegalArgumentException - if jars is empty, or contains null or empty elements
      See Also:
    • launcherClass

      public T launcherClass(@NonNull String className)
      Provides the Spring Boot loader launcher fully qualified class name.

      For examples:

      • org.springframework.boot.loader.JarLauncher
      • org.springframework.boot.loader.PropertiesLauncher
      • org.springframework.boot.loader.WarLauncher
      Parameters:
      className - the launcher class name
      Returns:
      this operation instance
      Throws:
      NullPointerException - if className is null
      IllegalArgumentException - if className is empty
    • launcherLibs

      public T launcherLibs(@NonNull File... jars)
      Provides the libraries for the Spring Boot loader launcher.
      Parameters:
      jars - one or more Java archives
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jars is null
      IllegalArgumentException - if jars is empty, or contains null or empty elements
      See Also:
    • launcherLibs

      public final T launcherLibs(@NonNull Collection<File> jars)
      Provides the libraries for the Spring Boot loader launcher.
      Parameters:
      jars - a collection of Java archives
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jars is null
      IllegalArgumentException - if jars is empty, or contains null or empty elements
      See Also:
    • launcherLibs

      public T launcherLibs(@NonNull String... jars)
      Provides the libraries for the Spring Boot loader launcher.
      Parameters:
      jars - one or more Java archives
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jars is null
      IllegalArgumentException - if jars is empty, or contains null or empty elements
      See Also:
    • launcherLibs

      public T launcherLibs(@NonNull Path... jars)
      Provides the libraries for the Spring Boot loader launcher.
      Parameters:
      jars - one or more Java archives
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jars is null
      IllegalArgumentException - if jars is empty, or contains null or empty elements
      See Also:
    • launcherLibs

      public List<File> launcherLibs()
      Retrieves the Spring Boot loader launcher libraries.
      Returns:
      the Java archives
    • launcherLibsPaths

      public final T launcherLibsPaths(@NonNull Collection<Path> jars)
      Provides the libraries for the Spring Boot loader launcher.
      Parameters:
      jars - one or more Java archives
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jars is null
      IllegalArgumentException - if jars is empty, or contains null or empty elements
      See Also:
    • launcherLibsStrings

      public final T launcherLibsStrings(@NonNull Collection<String> jars)
      Provides the libraries for the Spring Boot loader launcher.
      Parameters:
      jars - one or more Java archives
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jars is null
      IllegalArgumentException - if jars is empty, or contains null or empty elements
      See Also:
    • mainClass

      public String mainClass()
      Retrieves the main class name.
      Returns:
      the class name
    • manifestAttribute

      public T manifestAttribute(@NonNull String name, @NonNull String value)
      Provides an attribute to put in the archive manifest.
      Parameters:
      name - the attribute name
      value - the attribute value
      Returns:
      this operation instance
      Throws:
      NullPointerException - if name or value is null
      IllegalArgumentException - if name or value is empty
    • manifestAttributes

      public Map<String,String> manifestAttributes()
      Retrieves the attributes that will be put in the archive manifest.
      Returns:
      the manifest attributes
    • manifestAttributes

      public T manifestAttributes(@NonNull Map<String,String> attributes)
      Provides a map of attributes to put in the archive manifest.
      Parameters:
      attributes - the manifest attributes
      Returns:
      this operation instance
      Throws:
      NullPointerException - if attributes is null
      IllegalArgumentException - if attributes is empty, or contains null or empty elements
      See Also:
    • sourceDirectories

      public T sourceDirectories(@NonNull File... directories)
      Provides source directories that will be used for the archive creation.
      Parameters:
      directories - one or more source directories
      Returns:
      this operation instance
      Throws:
      NullPointerException - if directories is null
      IllegalArgumentException - if directories is empty, or contains null or empty elements
      See Also:
    • sourceDirectories

      public final T sourceDirectories(@NonNull Collection<File> directories)
      Provides source directories that will be used for the archive creation.
      Parameters:
      directories - one or more source directories
      Returns:
      this operation instance
      Throws:
      NullPointerException - if directories is null
      IllegalArgumentException - if directories is empty, or contains null or empty elements
      See Also:
    • sourceDirectories

      public T sourceDirectories(@NonNull String... directories)
      Provides source directories that will be used for the archive creation.
      Parameters:
      directories - one or more source directories
      Returns:
      this operation instance
      Throws:
      NullPointerException - if directories is null
      IllegalArgumentException - if directories is empty, or contains null or empty elements
      See Also:
    • sourceDirectories

      public T sourceDirectories(@NonNull Path... directories)
      Provides source directories that will be used for the archive creation.
      Parameters:
      directories - one or more source directories
      Returns:
      this operation instance
      Throws:
      NullPointerException - if directories is null
      IllegalArgumentException - if directories is empty, or contains null or empty elements
      See Also:
    • sourceDirectories

      public List<File> sourceDirectories()
      Retrieves the source directories that will be used for the archive creation.
      Returns:
      the source directories
    • sourceDirectoriesPaths

      public final T sourceDirectoriesPaths(@NonNull Collection<Path> directories)
      Provides source directories that will be used for the archive creation.
      Parameters:
      directories - one or more source directories
      Returns:
      this operation instance
      Throws:
      NullPointerException - if directories is null
      IllegalArgumentException - if directories is empty, or contains null or empty elements
      See Also:
    • sourceDirectoriesStrings

      public final T sourceDirectoriesStrings(@NonNull Collection<String> directories)
      Provides source directories that will be used for the archive creation.
      Parameters:
      directories - one or more source directories
      Returns:
      this operation instance
      Throws:
      NullPointerException - if directories is null
      IllegalArgumentException - if directories is empty, or contains null or empty elements
      See Also:
    • executeCopyBootLoader

      protected void executeCopyBootLoader(File stagingDirectory) throws FileUtilsErrorException, ExitStatusException
      Part of the execute operation, copies the Spring Boot loader launcher archive content to the staging directory.
      Parameters:
      stagingDirectory - the staging directory
      Throws:
      FileUtilsErrorException - if an error occurs
      ExitStatusException - if the launcher libraries are missing
    • executeCopyInfClassesFiles

      protected void executeCopyInfClassesFiles(File stagingInfDirectory) throws IOException
      Part of the execute operation, copies the BOOT-INF or WEB-INF classes.
      Parameters:
      stagingInfDirectory - the staging INF directory
      Throws:
      IOException - if an error occurs
    • executeCopyInfLibs

      protected void executeCopyInfLibs(File stagingInfDirectory) throws IOException
      Part of the execute operation, copies the BOOT-INF or WEB-INF libs.
      Parameters:
      stagingInfDirectory - the staging INF directory
      Throws:
      IOException - if an error occurs
    • executeCreateArchive

      protected File executeCreateArchive(File stagingDirectory) throws IOException
      Part of the execute operation, creates the archive from the staging directory.
      Parameters:
      stagingDirectory - the staging directory
      Returns:
      the archive
      Throws:
      IOException - if an error occurs
    • executeCreateManifest

      protected void executeCreateManifest(File stagingDirectory) throws IOException
      Part of the execute operation, creates the manifest for the archive.
      Parameters:
      stagingDirectory - the staging directory
      Throws:
      IOException - if an error occurs
    • launcherClass

      protected String launcherClass()
      Retrieves the Spring Boot loader launcher fully qualified class name.
      Returns:
      the launcher class name, or null if not set
    • mainClass

      protected T mainClass(String className)
      Provides the fully qualified main class name.
      Parameters:
      className - the class name
      Returns:
      this operation instance
    • verifyExecute

      protected void verifyExecute() throws IllegalArgumentException, IOException
      Verifies that all the elements (mainClass, launcherClass and launcherLibs) required to create the archive have been provided, throws an IllegalArgumentException otherwise.
      Throws:
      IOException - if the destination directory could not be created
      IllegalArgumentException - if a required element is missing or invalid