Class AbstractConfigurationMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
de.iip_ecosphere.platform.tools.maven.python.AbstractLoggingMojo
de.iip_ecosphere.platform.configuration.maven.AbstractConfigurationMojo
All Implemented Interfaces:
DependencyResolver.Caller, de.iip_ecosphere.platform.tools.maven.python.Logger, org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
AbstractAppsConfigurationMojo, GenerateAllMojo, GenerateBrokerMojo, GenerateInterfacesMojo, GeneratePlatformMojo

public abstract class AbstractConfigurationMojo extends de.iip_ecosphere.platform.tools.maven.python.AbstractLoggingMojo implements DependencyResolver.Caller
Abstract configuration Mojo with settings for all configuration Mojos.
Author:
Holger Eichelberger, SSE
  • Field Details

    • project

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

      @Parameter(defaultValue="${session}", required=true, readonly=true) private org.apache.maven.execution.MavenSession session
    • projectBuilder

      @Component private org.apache.maven.project.ProjectBuilder projectBuilder
    • resolver

      @Component private org.apache.maven.artifact.resolver.ArtifactResolver resolver
    • remoteRepos

      @Parameter(defaultValue="${project.remotePluginRepositories}", readonly=true) private List<org.eclipse.aether.repository.RemoteRepository> remoteRepos
    • repoSystem

      @Component private org.eclipse.aether.RepositorySystem repoSystem
    • mojoExecution

      @Parameter(defaultValue="${mojoExecution}", readonly=true, required=true) private org.apache.maven.plugin.MojoExecution mojoExecution
    • model

      @Parameter(property="configuration.model", required=true) private String model
    • modelDirectory

      @Parameter(property="configuration.modelDirectory", required=true, defaultValue="src/test/easy") private String modelDirectory
    • metaModelDirectory

      @Parameter(property="configuration.metaModelDirectory", required=true, defaultValue="src/main/easy") private String metaModelDirectory
    • outputDirectory

      @Parameter(property="configuration.outputDirectory", required=true, defaultValue="gen") private String outputDirectory
    • resourcesDirectory

      @Parameter(property="configuration.resourcesDirectory", required=false, defaultValue="resources.ipr") private String resourcesDirectory
    • fallbackResourcesDirectory

      @Parameter(property="configuration.fallbackResourcesDirectory", required=false, defaultValue="resources") private String fallbackResourcesDirectory
    • tracingLevel

      @Parameter(property="configuration.tracingLevel", required=false, defaultValue="TOP") private String tracingLevel
    • adjustOutputDirectoryIfGenBroker

      @Parameter(property="configuration.adjustOutputDirectoryIfGenBroker", required=false, defaultValue="trues") private boolean adjustOutputDirectoryIfGenBroker
    • apps

      @Parameter(property="configuration.apps", required=false, defaultValue="") private String apps
    • force

      @Parameter(property="configuration.force", required=false, defaultValue="") private boolean force
    • checkChanged

      @Parameter(property="configuration.checkChanged", required=false, defaultValue="false") private boolean checkChanged
    • changeCheckArtifacts

      @Parameter(property="configuration.changeCheckArtifacts", required=false, defaultValue="") private String changeCheckArtifacts
    • unpackForce

      @Parameter(property="unpack.force", required=false, defaultValue="false") private boolean unpackForce
    • asProcess

      @Parameter(required=false, defaultValue="true") private boolean asProcess
    • mavenHome

      @Parameter private File mavenHome
      The home directory of the Maven installation to use for the forked builds. Defaults to the current Maven installation.
  • Constructor Details

    • AbstractConfigurationMojo

      public AbstractConfigurationMojo()
  • Method Details

    • getProject

      public org.apache.maven.project.MavenProject getProject()
      Description copied from interface: DependencyResolver.Caller
      Returns the maven project.
      Specified by:
      getProject in interface DependencyResolver.Caller
      Returns:
      the project
    • getModel

      public String getModel()
      Returns the model (file) name.
      Returns:
      the model (file) name
    • getModelDirectory

      public String getModelDirectory()
      Returns the directory containing the model (to be set up as configuration EASy path).
      Returns:
      the model directory
    • getMetaModelDirectory

      public String getMetaModelDirectory()
      Returns the directory containing the meta model.
      Returns:
      the meta model directory
    • getOutputDirectory

      public String getOutputDirectory()
      Returns the output directory for generated code.
      Returns:
      the output directory the output directory
    • getResourcesDirectory

      public String getResourcesDirectory()
      Returns the path to the optional resources directory.
      Returns:
      the resources directory
    • getFallbackResourcesDirectory

      public String getFallbackResourcesDirectory()
      Returns the path to the optional fallback resources directory to be used if getResourcesDirectory() does not exist. This allows, e.g., to use getResourcesDirectory() for IPR protected resources and the fallback for open resources.
      Returns:
      the resources directory
    • getTracingLevel

      public String getTracingLevel()
      Returns the tracing level.
      Returns:
      the tracing level (ALL, TOP, FUNC)
    • getUnpackForce

      protected boolean getUnpackForce()
      A force through the IIP-Ecosphere unpacking plugin is requested.
      Returns:
      true for force through unpacking, false else
    • checkChanged

      protected boolean checkChanged()
      Returns whether changed models shall be considered.
      Returns:
      true for consider, false else (default, depends on goal)
    • getStartRule

      public abstract String getStartRule()
      Returns the start rule name.
      Returns:
      the start rule name
    • isModelDirectoryValid

      protected boolean isModelDirectoryValid()
      Returns whether getModelDirectory() is valid, i.e., contains at least an IVML file.
      Returns:
      the model directory
    • makeAbsolute

      private String makeAbsolute(String directory)
      Turns directory into an absolute directory name. If directory is yet absolute, return directory, if not, prepend the project base directory.
      Parameters:
      directory - the directory (may be null or empty)
      Returns:
      if directory isnull, empty, or absolute, return directory. If directory is not absolute, prepend MavenProject.getBasedir() from project.
    • validateDirectory

      private String validateDirectory(String directory)
      Validates the given string as existing directory.
      Parameters:
      directory - the directory to validate, may be null
      Returns:
      if directory is null or not existing, return null else directory
    • adjustOutputDir

      protected String adjustOutputDir(String outputDir)
      Adjusts the output directory if necessary.
      Parameters:
      outputDir - the output directory
      Returns:
      the adjusted output directory, by default just outputDir
    • findGenParent

      protected File findGenParent(String outputDir)
      Returns the "gen" parent folder if it exists, if not just outputDir.
      Parameters:
      outputDir - the output directory where to start finding the "gen" parent folder
      Returns:
      the default gen parent folder or outputDir if not found
    • modelNewerThanOut

      protected boolean modelNewerThanOut(String metaModelDir, String modelDir, String outDir)
      Returns whether modelDir is considered to be newer than outDir.
      Parameters:
      metaModelDir - the meta-model directory
      modelDir - the model directory
      outDir - the output directory
      Returns:
      true if modelDir is considered to be newer than outDir, false else
    • isModelFile

      private static boolean isModelFile(File file)
      Returns whether file is an IVML, VIL or VTL file.
      Parameters:
      file - the file to check
      Returns:
      true for one of these files, false else
    • isNewer

      private boolean isNewer(File artifact, File hash)
      Returns whether artifact is newer than hash.
      Parameters:
      artifact - the artifact file
      hash - the hash file
      Returns:
      if artifact is newer than hash
    • enabled

      private boolean enabled(List<File> files)
      Returns whether a list of files from hash checking enables further execution.
      Parameters:
      files - the files
      Returns:
      true for enabled, false else
    • checkFilesByHash

      private List<File> checkFilesByHash(File hashFile, String modelDir, String info)
      Checks files by MD5 change hashes.
      Parameters:
      hashFile - the hash file
      modelDir - the directory of files to analyze
      info - logging information on the task
      Returns:
      the changed files or null for unsure/none detected
    • getMaxLastModified

      protected long getMaxLastModified(String dir, FileFilter filter)
      Returns the maximum modification time of the files in dir fulfilling filter.
      Parameters:
      dir - the directory to analyze
      filter - filter on files found in dir
      Returns:
      the maximum modification time or -1 if no files were found
    • enableRun

      protected boolean enableRun(String metaModelDir, String modelDir, String outputDir)
      Called by execute() to figure out whether the instantiation shall take place. By default, instantiation will be enabled if IVML files in modelDir are newer than files in output directory or if output directory is empty or missing.
      Parameters:
      metaModelDir - the meta model directory
      modelDir - the model directory
      outputDir - the output directory
      Returns:
      true for instantiation, false for no instantiation
    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Specified by:
      execute in interface org.apache.maven.plugin.Mojo
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • adjustMavenHome

      private void adjustMavenHome()
      If ProcessUnit.getMavenBinPath() is not set, try to set it via mavenHome.
    • createExecutor

      private de.iip_ecosphere.platform.configuration.cfg.PlatformInstantiation createExecutor()
      Creates an executor instance.
      Returns:
      the instance
    • composeMvnArgs

      private String composeMvnArgs()
      Composes Maven execution arguments for EASy-Producer/Platform instantiator.
      Returns:
      the Maven arguments
    • recordExecutionTime

      protected void recordExecutionTime(long time)
      Called to record the execution time.
      Parameters:
      time - the passed time in ms
    • getSession

      public org.apache.maven.execution.MavenSession getSession()
      Description copied from interface: DependencyResolver.Caller
      Returns the maven session.
      Specified by:
      getSession in interface DependencyResolver.Caller
      Returns:
      the session
    • getProjectBuilder

      public org.apache.maven.project.ProjectBuilder getProjectBuilder()
      Description copied from interface: DependencyResolver.Caller
      Returns the maven project builder.
      Specified by:
      getProjectBuilder in interface DependencyResolver.Caller
      Returns:
      the builder
    • getRepoSystem

      public org.eclipse.aether.RepositorySystem getRepoSystem()
      Description copied from interface: DependencyResolver.Caller
      Returns the maven repository system.
      Specified by:
      getRepoSystem in interface DependencyResolver.Caller
      Returns:
      the repositories