org.ops4j.pax.construct.archetype
Class AbstractPaxArchetypeMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.ops4j.pax.construct.archetype.AbstractPaxArchetypeMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
OSGiBundleArchetypeMojo, OSGiProjectArchetypeMojo, OSGiWrapperArchetypeMojo

public abstract class AbstractPaxArchetypeMojo
extends org.apache.maven.plugin.AbstractMojo

Based on MavenArchetypeMojo, this abstract mojo adds support for additional archetype properties, needed to provide multi-module archetypes.


Field Summary
static java.lang.String PAX_CONSTRUCT_GROUP_ID
          Our local archetype group
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractPaxArchetypeMojo()
           
 
Method Summary
protected  void addTempFiles(java.lang.String pathExpression)
           
protected  void cacheOriginalFiles(java.io.File baseDir)
          Gives sub-classes the chance to cache the original files before custom archetypes run
protected  boolean createMoreArtifacts()
           
 void execute()
          
protected  java.lang.String getArchetypeProperty(java.lang.String name)
           
protected  java.lang.String getCompoundId(java.lang.String groupId, java.lang.String artifactId)
          Combine the groupId and artifactId, eliminating duplicate elements if compactNames is true
protected  org.apache.maven.artifact.factory.ArtifactFactory getFactory()
           
protected  java.util.Set getFinalFilenames()
           
protected  java.lang.String getInternalGroupId(java.lang.String bundleGroupId)
           
protected  org.apache.maven.artifact.repository.ArtifactRepository getLocalRepo()
           
protected abstract  java.lang.String getParentId()
           
protected  java.lang.String getPluginVersion()
           
protected  java.util.List getRemoteRepos()
           
protected  org.apache.maven.artifact.resolver.ArtifactResolver getResolver()
           
protected  org.apache.maven.artifact.metadata.ArtifactMetadataSource getSource()
           
protected  boolean hasCustomContent()
           
protected  void postProcess(PomUtils.Pom pom, BndUtils.Bnd bnd)
          Sub-class specific post-processing, which runs *after* custom archetypes are added
protected  void saveBndInstructions(BndUtils.Bnd bnd)
           
protected  void saveProjectModel(PomUtils.Pom pom)
           
protected  void scheduleArchetype(java.lang.String groupId, java.lang.String artifactId, java.lang.String version)
          Add a custom archetype to the list of archetypes to merge in once the main archetype has been applied
protected  void setArchetypeProperty(java.lang.String name, java.lang.String value)
           
protected  void setMainArchetype(java.lang.String archetypeArtifactId)
          Fill in archetype details for the selected Pax-Construct archetype
protected abstract  void updateExtensionFields()
          Set the remaining fields in the archetype mojo
 
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

PAX_CONSTRUCT_GROUP_ID

public static final java.lang.String PAX_CONSTRUCT_GROUP_ID
Our local archetype group

See Also:
Constant Field Values
Constructor Detail

AbstractPaxArchetypeMojo

public AbstractPaxArchetypeMojo()
Method Detail

getFactory

protected final org.apache.maven.artifact.factory.ArtifactFactory getFactory()
Returns:
component factory for Maven artifacts

getResolver

protected final org.apache.maven.artifact.resolver.ArtifactResolver getResolver()
Returns:
component for resolving Maven artifacts

getSource

protected final org.apache.maven.artifact.metadata.ArtifactMetadataSource getSource()
Returns:
component for resolving Maven metadata

getLocalRepo

protected final org.apache.maven.artifact.repository.ArtifactRepository getLocalRepo()
Returns:
local Maven repository

getRemoteRepos

protected final java.util.List getRemoteRepos()
Returns:
remote Maven repositories

hasCustomContent

protected final boolean hasCustomContent()
Returns:
true if the user has selected one or more custom archetypes

getInternalGroupId

protected final java.lang.String getInternalGroupId(java.lang.String bundleGroupId)
Parameters:
bundleGroupId - customized bundle groupId (may be null)
Returns:
the internal groupId for support artifacts belonging to the new project

getPluginVersion

protected final java.lang.String getPluginVersion()
Returns:
the version of the plugin

addTempFiles

protected final void addTempFiles(java.lang.String pathExpression)
Parameters:
pathExpression - Ant-style path expression, can include wildcards

execute

public final void execute()
                   throws org.apache.maven.plugin.MojoExecutionException

Throws:
org.apache.maven.plugin.MojoExecutionException

updateExtensionFields

protected abstract void updateExtensionFields()
                                       throws org.apache.maven.plugin.MojoExecutionException
Set the remaining fields in the archetype mojo

Throws:
org.apache.maven.plugin.MojoExecutionException

getParentId

protected abstract java.lang.String getParentId()
Returns:
The logical parent of the new project (use artifactId or groupId:artifactId)

cacheOriginalFiles

protected void cacheOriginalFiles(java.io.File baseDir)
Gives sub-classes the chance to cache the original files before custom archetypes run

Parameters:
baseDir - project base directory

postProcess

protected void postProcess(PomUtils.Pom pom,
                           BndUtils.Bnd bnd)
                    throws org.apache.maven.plugin.MojoExecutionException
Sub-class specific post-processing, which runs *after* custom archetypes are added

Parameters:
pom - working copy of Maven POM
bnd - working copy of Bnd instructions
Throws:
org.apache.maven.plugin.MojoExecutionException

createMoreArtifacts

protected boolean createMoreArtifacts()
Returns:
true to continue creating more projects, otherwise false

setMainArchetype

protected final void setMainArchetype(java.lang.String archetypeArtifactId)
Fill in archetype details for the selected Pax-Construct archetype

Parameters:
archetypeArtifactId - selected OSGi archetype

saveProjectModel

protected final void saveProjectModel(PomUtils.Pom pom)
                               throws java.io.IOException
Parameters:
pom - Maven project to merge with the latest file copy
Throws:
java.io.IOException

saveBndInstructions

protected final void saveBndInstructions(BndUtils.Bnd bnd)
                                  throws java.io.IOException
Parameters:
bnd - Bnd instructions to merge with the latest file copy
Throws:
java.io.IOException

getCompoundId

protected final java.lang.String getCompoundId(java.lang.String groupId,
                                               java.lang.String artifactId)
Combine the groupId and artifactId, eliminating duplicate elements if compactNames is true

Parameters:
groupId - project group id
artifactId - project artifact id
Returns:
the combined group and artifact sequence

scheduleArchetype

protected final void scheduleArchetype(java.lang.String groupId,
                                       java.lang.String artifactId,
                                       java.lang.String version)
Add a custom archetype to the list of archetypes to merge in once the main archetype has been applied

Parameters:
groupId - archetype group id
artifactId - archetype atifact id
version - archetype version

getFinalFilenames

protected final java.util.Set getFinalFilenames()
Returns:
set of filenames that will be left at the end of this archetype cycle

setArchetypeProperty

protected final void setArchetypeProperty(java.lang.String name,
                                          java.lang.String value)
Parameters:
name - property name
value - property value

getArchetypeProperty

protected final java.lang.String getArchetypeProperty(java.lang.String name)
Parameters:
name - property name
Returns:
property value


Copyright © 2007-2008 OPS4J. All Rights Reserved.