de.smartics.maven.plugin.buildmetadata
Class AbstractBuildMojo

Package class diagram package AbstractBuildMojo
java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by de.smartics.maven.plugin.buildmetadata.AbstractBuildMojo
All Implemented Interfaces:
ContextEnabled, Mojo
Direct Known Subclasses:
BuildMetaDataMojo, BuildPointMojo

public abstract class AbstractBuildMojo
     
     
extends AbstractMojo

Base implementation for all build mojos.

Author:
Robert Reiner

Field Summary
protected  boolean addToFilters
          Flag to indicate whether or not the generated properties file should be added to the projects filters.
protected  boolean createXmlReport
          Flag to choose whether (true) or not (false) the XML report should be created.
protected  MavenProject project
          The Maven project.
protected  List<Property> properties
          The list of a system properties or environment variables to be selected by the user to include into the build meta data properties.
protected  File propertiesOutputFile
          The name of the properties file to write.
protected  List<FileMapping> propertyOutputFileMapping
          Maps a packaging to a location for the build meta data properties file.
protected  List<Provider> providers
          The list of meta data providers to launch that contribute to the meta data.
protected  RuntimeInformation runtime
          The runtime information of the Maven instance being executed for the build.
protected  MavenSession session
          The Maven session instance.
protected  File xmlOutputFile
          The name of the XML report file to write.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractBuildMojo()
           
 
Method Summary
 void execute()
          
 MavenProject getProject()
          Returns the Maven project.
protected  void provideBuildMetaData(Properties buildMetaDataProperties, ScmInfo scmInfo, List<Provider> providers, boolean runAtEndOfBuild)
          Adds the information as build properties for each provider.
 void setProject(MavenProject project)
          Sets the Maven project.
 void setPropertiesOutputFile(File propertiesOutputFile)
          Sets the name of the properties file to write.
 void setSession(MavenSession session)
          Sets the Maven session.
protected  void updateMavenEnvironment(Properties buildMetaDataProperties, BuildPropertiesFileHelper helper)
          Updates the Maven runtime with build properties.
 
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 Detail

project

protected MavenProject project
The Maven project.

Since:
1.0

session

protected MavenSession session
The Maven session instance.


runtime

protected RuntimeInformation runtime
The runtime information of the Maven instance being executed for the build.

Since:
1.0

propertiesOutputFile

protected File propertiesOutputFile
The name of the properties file to write. Per default this value is overridden by packaging dependent locations. Please refer to activatePropertyOutputFileMapping for details.

Since:
1.0

propertyOutputFileMapping

protected List<FileMapping> propertyOutputFileMapping
Maps a packaging to a location for the build meta data properties file.

This mapping is especially useful for multi projects.

Since:
1.1

xmlOutputFile

protected File xmlOutputFile
The name of the XML report file to write. If you want to include the XML file in the artifact, use ${project.build.outputDirectory}/META-INF/buildmetadata.xml.

Since:
1.0

createXmlReport

protected boolean createXmlReport
Flag to choose whether ( true) or not ( false) the XML report should be created.

Since:
1.0

providers

protected List<Provider> providers
The list of meta data providers to launch that contribute to the meta data.


properties

protected List<Property> properties
The list of a system properties or environment variables to be selected by the user to include into the build meta data properties.

The name is the name of the property, the section is relevant for placing the property in one of the following sections:

If no valid section is given, the property is silently rendered in the build.misc section.

Since:
1.0

addToFilters

protected boolean addToFilters
Flag to indicate whether or not the generated properties file should be added to the projects filters.

Filters are only added temporarily (read in-memory during the build) and are not written to the POM.

Since:
1.0
Constructor Detail

AbstractBuildMojo

public AbstractBuildMojo()
Method Detail

getProject

public final MavenProject getProject()
Returns the Maven project.

Returns:
the Maven project.

setProject

public final void setProject(MavenProject project)
Sets the Maven project.

Parameters:
project - the Maven project.

setSession

public final void setSession(MavenSession session)
Sets the Maven session.

Used for testing.

Parameters:
session - the Maven session.

setPropertiesOutputFile

public final void setPropertiesOutputFile(File propertiesOutputFile)
Sets the name of the properties file to write.

Used for testing.

Parameters:
propertiesOutputFile - the name of the properties file to write.

execute

public void execute()
             throws MojoExecutionException,
                    MojoFailureException

Throws:
MojoExecutionException
MojoFailureException

provideBuildMetaData

protected final void provideBuildMetaData(Properties buildMetaDataProperties,
                                          ScmInfo scmInfo,
                                          List<Provider> providers,
                                          boolean runAtEndOfBuild)
                                   throws MojoExecutionException
Adds the information as build properties for each provider.

Parameters:
buildMetaDataProperties - the build meta data properties to add to.
scmInfo - the information for the SCM provided to the build plugin.
providers - the providers to iterate over.
runAtEndOfBuild - checks if the provider is configured to be run at the end of the build. If a provider matches this value, it is run.
Throws:
MojoExecutionException - on any problem running on the providers.

updateMavenEnvironment

protected final void updateMavenEnvironment(Properties buildMetaDataProperties,
                                            BuildPropertiesFileHelper helper)
Updates the Maven runtime with build properties.

Parameters:
buildMetaDataProperties - the properties to add to the Maven project properties.
helper - the project helper to use.


Copyright © 2006-2012 Kronseder & Reiner GmbH - smartics. All Rights Reserved.