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 Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate Stringprivate booleanprivate Stringprivate booleanprivate Stringprivate booleanprivate FileThe home directory of the Maven installation to use for the forked builds.private Stringprivate Stringprivate Stringprivate org.apache.maven.plugin.MojoExecutionprivate Stringprivate org.apache.maven.project.MavenProjectprivate org.apache.maven.project.ProjectBuilderprivate List<org.eclipse.aether.repository.RemoteRepository> private org.eclipse.aether.RepositorySystemprivate org.apache.maven.artifact.resolver.ArtifactResolverprivate Stringprivate org.apache.maven.execution.MavenSessionprivate Stringprivate booleanFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidIfProcessUnit.getMavenBinPath()is not set, try to set it viamavenHome.protected StringadjustOutputDir(String outputDir) Adjusts the output directory if necessary.protected booleanReturns whether changed models shall be considered.checkFilesByHash(File hashFile, String modelDir, String info) Checks files by MD5 change hashes.private StringComposes Maven execution arguments for EASy-Producer/Platform instantiator.private de.iip_ecosphere.platform.configuration.cfg.PlatformInstantiationCreates an executor instance.private booleanReturns whether a list of files from hash checking enables further execution.protected booleanCalled byexecute()to figure out whether the instantiation shall take place.voidexecute()protected FilefindGenParent(String outputDir) Returns the "gen" parent folder if it exists, if not justoutputDir.Returns the path to the optional fallback resources directory to be used ifgetResourcesDirectory()does not exist.protected longgetMaxLastModified(String dir, FileFilter filter) Returns the maximum modification time of the files indirfulfillingfilter.Returns the directory containing the meta model.getModel()Returns the model (file) name.Returns the directory containing the model (to be set up as configuration EASy path).Returns the output directory for generated code.org.apache.maven.project.MavenProjectReturns the maven project.org.apache.maven.project.ProjectBuilderReturns the maven project builder.org.eclipse.aether.RepositorySystemReturns the maven repository system.Returns the path to the optional resources directory.org.apache.maven.execution.MavenSessionReturns the maven session.abstract StringReturns the start rule name.Returns the tracing level.protected booleanA force through the IIP-Ecosphere unpacking plugin is requested.protected booleanReturns whethergetModelDirectory()is valid, i.e., contains at least an IVML file.private static booleanisModelFile(File file) Returns whetherfileis an IVML, VIL or VTL file.private booleanReturns whetherartifactis newer thanhash.private StringmakeAbsolute(String directory) Turnsdirectoryinto an absolute directory name.protected booleanmodelNewerThanOut(String metaModelDir, String modelDir, String outDir) Returns whethermodelDiris considered to be newer thanoutDir.protected voidrecordExecutionTime(long time) Called to record the execution time.private StringvalidateDirectory(String directory) Validates the given string as existing directory.Methods inherited from class de.iip_ecosphere.platform.tools.maven.python.AbstractLoggingMojo
error, error, info, warnMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.iip_ecosphere.platform.configuration.maven.DependencyResolver.Caller
getLog, getRemoteRepos, getRepoSession
-
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
-
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
-
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
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.CallerReturns the maven project.- Specified by:
getProjectin interfaceDependencyResolver.Caller- Returns:
- the project
-
getModel
Returns the model (file) name.- Returns:
- the model (file) name
-
getModelDirectory
Returns the directory containing the model (to be set up as configuration EASy path).- Returns:
- the model directory
-
getMetaModelDirectory
Returns the directory containing the meta model.- Returns:
- the meta model directory
-
getOutputDirectory
Returns the output directory for generated code.- Returns:
- the output directory the output directory
-
getResourcesDirectory
Returns the path to the optional resources directory.- Returns:
- the resources directory
-
getFallbackResourcesDirectory
Returns the path to the optional fallback resources directory to be used ifgetResourcesDirectory()does not exist. This allows, e.g., to usegetResourcesDirectory()for IPR protected resources and the fallback for open resources.- Returns:
- the resources directory
-
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:
truefor force through unpacking,falseelse
-
checkChanged
protected boolean checkChanged()Returns whether changed models shall be considered.- Returns:
truefor consider,falseelse (default, depends on goal)
-
getStartRule
Returns the start rule name.- Returns:
- the start rule name
-
isModelDirectoryValid
protected boolean isModelDirectoryValid()Returns whethergetModelDirectory()is valid, i.e., contains at least an IVML file.- Returns:
- the model directory
-
makeAbsolute
Turnsdirectoryinto an absolute directory name. Ifdirectoryis yet absolute, returndirectory, if not, prepend the project base directory.- Parameters:
directory- the directory (may be null or empty)- Returns:
- if
directoryisnull, empty, or absolute, returndirectory. Ifdirectoryis not absolute, prependMavenProject.getBasedir()fromproject.
-
validateDirectory
Validates the given string as existing directory.- Parameters:
directory- the directory to validate, may be null- Returns:
- if
directoryis null or not existing, return null elsedirectory
-
adjustOutputDir
Adjusts the output directory if necessary.- Parameters:
outputDir- the output directory- Returns:
- the adjusted output directory, by default just
outputDir
-
findGenParent
Returns the "gen" parent folder if it exists, if not justoutputDir.- Parameters:
outputDir- the output directory where to start finding the "gen" parent folder- Returns:
- the default gen parent folder or
outputDirif not found
-
modelNewerThanOut
Returns whethermodelDiris considered to be newer thanoutDir.- Parameters:
metaModelDir- the meta-model directorymodelDir- the model directoryoutDir- the output directory- Returns:
trueifmodelDiris considered to be newer thanoutDir,falseelse
-
isModelFile
Returns whetherfileis an IVML, VIL or VTL file.- Parameters:
file- the file to check- Returns:
truefor one of these files,falseelse
-
isNewer
Returns whetherartifactis newer thanhash.- Parameters:
artifact- the artifact filehash- the hash file- Returns:
- if
artifactis newer thanhash
-
enabled
Returns whether a list of files from hash checking enables further execution.- Parameters:
files- the files- Returns:
truefor enabled,falseelse
-
checkFilesByHash
Checks files by MD5 change hashes.- Parameters:
hashFile- the hash filemodelDir- the directory of files to analyzeinfo- logging information on the task- Returns:
- the changed files or null for unsure/none detected
-
getMaxLastModified
Returns the maximum modification time of the files indirfulfillingfilter.- Parameters:
dir- the directory to analyzefilter- filter on files found indir- Returns:
- the maximum modification time or
-1if no files were found
-
enableRun
Called byexecute()to figure out whether the instantiation shall take place. By default, instantiation will be enabled if IVML files inmodelDirare newer than files inoutput directoryor if output directory is empty or missing.- Parameters:
metaModelDir- the meta model directorymodelDir- the model directoryoutputDir- the output directory- Returns:
truefor instantiation,falsefor no instantiation
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Specified by:
executein interfaceorg.apache.maven.plugin.Mojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
adjustMavenHome
private void adjustMavenHome()IfProcessUnit.getMavenBinPath()is not set, try to set it viamavenHome. -
createExecutor
private de.iip_ecosphere.platform.configuration.cfg.PlatformInstantiation createExecutor()Creates an executor instance.- Returns:
- the instance
-
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.CallerReturns the maven session.- Specified by:
getSessionin interfaceDependencyResolver.Caller- Returns:
- the session
-
getProjectBuilder
public org.apache.maven.project.ProjectBuilder getProjectBuilder()Description copied from interface:DependencyResolver.CallerReturns the maven project builder.- Specified by:
getProjectBuilderin interfaceDependencyResolver.Caller- Returns:
- the builder
-
getRepoSystem
public org.eclipse.aether.RepositorySystem getRepoSystem()Description copied from interface:DependencyResolver.CallerReturns the maven repository system.- Specified by:
getRepoSystemin interfaceDependencyResolver.Caller- Returns:
- the repositories
-