Class SplitClasspathMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
de.iip_ecosphere.platform.tools.maven.dependencies.SplitClasspathMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="split-classpath", defaultPhase=PACKAGE, threadSafe=true) public class SplitClasspathMojo extends org.apache.maven.plugin.AbstractMojo
A mojo that splits classpaths into main and app classpaths based on contained file name parts. Handlers spring app package as well as oktoflow classpath jars.
Author:
Holger Eichelberger, SSE
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private class 
    Represents classpaths and indexes.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private List<File>
     
    private boolean
     
    private List<String>
     
    private List<String>
     
    private org.apache.maven.project.MavenProject
     
    private boolean
     

    Fields inherited from interface org.apache.maven.plugin.Mojo

    ROLE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    addToIndex(de.oktoflow.platform.tools.lib.loader.LoaderIndex index, Path path, String location)
    Adds the contents of path to index.
    private void
    Analyzes the dependencies for discouraged use of plugins as direct dependencies.
    private void
    analyzeDependencies(List<org.apache.maven.model.Dependency> dependencies, List<String> patterns, String profile)
    Analyzes the dependencies for discouraged use of plugins as direct dependencies.
    private void
    Cleans up left-over files.
    void
     
    private boolean
    Returns whether (parts of) file are compressed/deflated.
    private boolean
    isMainFile(String name, boolean includeSpringLoader)
    Returns whether the given name/line contains on of the main file patterns.
    void
    moveAll(Path sourcePath, Path destPath, boolean keepSourcePath, Predicate<Path> filter)
    Moves all files and folders from a source directory to a destination directory.
    private void
    Post-processes a spring jar, by moving those files that are not mentioned in an index file.
    private void
    Processes a given file.
    private String
    processSpringLine(FileSystem fs, String line, de.oktoflow.platform.tools.lib.loader.LoaderIndex index)
    Processes a spring index line.
    private void
    toStream(de.oktoflow.platform.tools.lib.loader.LoaderIndex index, Path path)
    Stores a loader index to path.

    Methods inherited from class org.apache.maven.plugin.AbstractMojo

    getLog, getPluginContext, setLog, setPluginContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • project

      @Parameter(defaultValue="${project}", readonly=true) private org.apache.maven.project.MavenProject project
    • archiveFiles

      @Parameter(property="mdep.archiveFile", defaultValue="", required=true) private List<File> archiveFiles
    • skip

      @Parameter(property="mdep.skip", defaultValue="false", required=false) private boolean skip
    • createIndex

      @Parameter(property="mdep.createIndex", defaultValue="true") private boolean createIndex
    • mainPatterns

      @Parameter(required=false) private List<String> mainPatterns
    • keepClasses

      @Parameter(required=false) private List<String> keepClasses
  • Constructor Details

    • SplitClasspathMojo

      public SplitClasspathMojo()
  • Method Details

    • isMainFile

      private boolean isMainFile(String name, boolean includeSpringLoader)
      Returns whether the given name/line contains on of the main file patterns.
      Parameters:
      name - the name to check
      Returns:
      true for match, false else
    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • analyzeDependencies

      private void analyzeDependencies() throws org.apache.maven.plugin.MojoFailureException
      Analyzes the dependencies for discouraged use of plugins as direct dependencies.
      Throws:
      org.apache.maven.plugin.MojoFailureException - if the discouraged use is considered to be a failure
    • analyzeDependencies

      private void analyzeDependencies(List<org.apache.maven.model.Dependency> dependencies, List<String> patterns, String profile)
      Analyzes the dependencies for discouraged use of plugins as direct dependencies.
      Parameters:
      dependencies - dependencies to be analyzed
      patterns - artifactId prefixes that must not be used
      profile - the name of the profile, null for no profile
    • isCompressed

      private boolean isCompressed(File file)
      Returns whether (parts of) file are compressed/deflated. Keep stored/deflated, in particular for Spring boot app jars, which are either exploded or stored.
      Parameters:
      file - the file to check
      Returns:
      true for compression, false else
    • processFile

      private void processFile(File file) throws org.apache.maven.plugin.MojoExecutionException
      Processes a given file.
      Parameters:
      file - the file to be processed
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if processing fails
    • toStream

      private void toStream(de.oktoflow.platform.tools.lib.loader.LoaderIndex index, Path path) throws IOException
      Stores a loader index to path. Disabled if createIndex is false.
      Parameters:
      index - the index, may be null, ignored then
      path - the path to store the index to
      Throws:
      IOException - if storing fails
    • addToIndex

      private void addToIndex(de.oktoflow.platform.tools.lib.loader.LoaderIndex index, Path path, String location) throws IOException
      Adds the contents of path to index. Disabled if createIndex is false.
      Parameters:
      index - the index, may be null, ignored then
      path -
      location -
      Throws:
      IOException
    • cleanup

      private void cleanup()
      Cleans up left-over files.
    • processSpringLine

      private String processSpringLine(FileSystem fs, String line, de.oktoflow.platform.tools.lib.loader.LoaderIndex index) throws IOException
      Processes a spring index line. May move files in the archive.
      Parameters:
      fs - the filesystem to operate on
      line - the line to process
      Returns:
      the potentially modified line
      Throws:
      IOException - if moving files fails
    • postProcessSpringJar

      private void postProcessSpringJar(FileSystem fs) throws IOException
      Post-processes a spring jar, by moving those files that are not mentioned in an index file.
      Parameters:
      fs - the filesystem to operate on
      Throws:
      IOException - if moving files fails
    • moveAll

      public void moveAll(Path sourcePath, Path destPath, boolean keepSourcePath, Predicate<Path> filter) throws IOException
      Moves all files and folders from a source directory to a destination directory.
      Parameters:
      sourcePath - The path to the source directory
      destPath - The path to the destination directory
      keepSourcePath - keep sourcePath itself if true, else remove also sourcePath
      filter - determines the files to move, may be null for all
      Throws:
      IOException - If an I/O error occurs during the move operation