public class PomHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
APACHE_MAVEN_PLUGINS_GROUPID |
| Constructor and Description |
|---|
PomHelper() |
| Modifier and Type | Method and Description |
|---|---|
static void |
debugModules(org.apache.maven.plugin.logging.Log logger,
String message,
Collection modules)
Outputs a debug message with a list of modules.
|
static String |
evaluate(String expr,
Map<String,String> properties)
A lightweight expression evaluation function.
|
static Set |
getAllChildModules(org.apache.maven.project.MavenProject project,
org.apache.maven.plugin.logging.Log logger)
Returns a set of all child modules for a project, including any defined in profiles (ignoring profile
activation).
|
static Set<String> |
getAllChildModules(org.apache.maven.model.Model model,
org.apache.maven.plugin.logging.Log logger)
Returns a set of all child modules for a project, including any defined in profiles (ignoring profile
activation).
|
static String |
getArtifactId(org.apache.maven.model.Model model)
Extracts the artifactId from a raw model, interpolating from the parent if necessary.
|
static Map<String,org.apache.maven.model.Model> |
getChildModels(Map<String,org.apache.maven.model.Model> reactor,
String groupId,
String artifactId)
Returns all the models that have a specified groupId and artifactId as parent.
|
static String |
getGroupId(org.apache.maven.model.Model model)
Extracts the groupId from a raw model, interpolating from the parent if necessary.
|
static org.apache.maven.project.MavenProject |
getLocalRoot(org.apache.maven.project.MavenProjectBuilder builder,
org.apache.maven.project.MavenProject project,
org.apache.maven.artifact.repository.ArtifactRepository localRepository,
org.apache.maven.profiles.ProfileManager globalProfileManager,
org.apache.maven.plugin.logging.Log logger)
Finds the local root of the specified project.
|
static org.apache.maven.model.Model |
getModel(Map<String,org.apache.maven.model.Model> reactor,
String groupId,
String artifactId)
Returns the model that has the specified groupId and artifactId or
null if no such model exists. |
static org.apache.maven.artifact.Artifact |
getProjectParent(ModifiedPomXMLEventReader pom,
VersionsHelper helper)
Gets the parent artifact from the pom.
|
static String |
getProjectVersion(ModifiedPomXMLEventReader pom)
Retrieves the project version from the pom.
|
static org.codehaus.mojo.versions.api.PropertyVersionsBuilder[] |
getPropertyVersionsBuilders(VersionsHelper helper,
org.apache.maven.project.MavenProject project)
Examines the project to find any properties which are associated with versions of artifacts in the project.
|
static org.apache.maven.model.Model |
getRawModel(File moduleProjectFile)
Gets the raw model before any interpolation what-so-ever.
|
static org.apache.maven.model.Model |
getRawModel(org.apache.maven.project.MavenProject project)
Gets the raw model before any interpolation what-so-ever.
|
static org.apache.maven.model.Model |
getRawModel(ModifiedPomXMLEventReader modifiedPomXMLEventReader)
Gets the current raw model before any interpolation what-so-ever.
|
static Map<String,org.apache.maven.model.Model> |
getReactorModels(org.apache.maven.project.MavenProject project,
org.apache.maven.plugin.logging.Log logger)
Builds a map of raw models keyed by module path.
|
static int |
getReactorParentCount(Map<String,org.apache.maven.model.Model> reactor,
org.apache.maven.model.Model model)
Returns a count of how many parents a model has in the reactor.
|
static String |
getVersion(org.apache.maven.model.Model model)
Extracts the version from a raw model, interpolating from the parent if necessary.
|
static boolean |
isExplicitVersion(org.apache.maven.model.Model model)
Checks to see if the model contains an explicitly specified version.
|
static boolean |
isVersionOverlap(String leftVersionOrRange,
String rightVersionOrRange)
Checks if two versions or ranges have an overlap.
|
static StringBuilder |
readXmlFile(File outFile)
Reads a file into a String.
|
static void |
removeMissingChildModules(org.apache.maven.plugin.logging.Log logger,
File basedir,
Collection<String> childModules)
Modifies the collection of child modules removing those which cannot be found relative to the parent.
|
static void |
removeMissingChildModules(org.apache.maven.plugin.logging.Log logger,
org.apache.maven.project.MavenProject project,
Collection<String> childModules)
Modifies the collection of child modules removing those which cannot be found relative to the parent.
|
static boolean |
setDependencyVersion(ModifiedPomXMLEventReader pom,
String groupId,
String artifactId,
String oldVersion,
String newVersion)
Searches the pom re-defining the specified dependency to the specified version.
|
static boolean |
setPluginVersion(ModifiedPomXMLEventReader pom,
String groupId,
String artifactId,
String oldVersion,
String newVersion)
Searches the pom re-defining the specified plugin to the specified version.
|
static boolean |
setProjectParentVersion(ModifiedPomXMLEventReader pom,
String value)
Searches the pom re-defining the project version to the specified version.
|
static boolean |
setProjectVersion(ModifiedPomXMLEventReader pom,
String value)
Searches the pom re-defining the project version to the specified version.
|
static boolean |
setPropertyVersion(ModifiedPomXMLEventReader pom,
String profileId,
String property,
String value)
Searches the pom re-defining the specified property to the specified version.
|
public static final String APACHE_MAVEN_PLUGINS_GROUPID
public static org.apache.maven.model.Model getRawModel(org.apache.maven.project.MavenProject project)
throws IOException
project - The project to get the raw model for.IOException - if the file is not found or if the file does not parse.public static org.apache.maven.model.Model getRawModel(File moduleProjectFile) throws IOException
moduleProjectFile - The project file to get the raw model for.IOException - if the file is not found or if the file does not parse.public static org.apache.maven.model.Model getRawModel(ModifiedPomXMLEventReader modifiedPomXMLEventReader) throws IOException
modifiedPomXMLEventReader - The ModifiedPomXMLEventReader to get the raw model for.IOException - if the file is not found or if the file does not parse.public static boolean setPropertyVersion(ModifiedPomXMLEventReader pom, String profileId, String property, String value) throws XMLStreamException
pom - The pom to modify.profileId - The profile in which to modify the property.property - The property to modify.value - The new value of the property.true if a replacement was made.XMLStreamException - if somethinh went wrong.public static boolean setProjectVersion(ModifiedPomXMLEventReader pom, String value) throws XMLStreamException
pom - The pom to modify.value - The new value of the property.true if a replacement was made.XMLStreamException - if somethinh went wrong.public static String getProjectVersion(ModifiedPomXMLEventReader pom) throws XMLStreamException
pom - The pom.null if the project version is not defined (i.e. inherited from parent version).XMLStreamException - if something went wrong.public static boolean setProjectParentVersion(ModifiedPomXMLEventReader pom, String value) throws XMLStreamException
pom - The pom to modify.value - The new value of the property.true if a replacement was made.XMLStreamException - if somethinh went wrong.public static org.apache.maven.artifact.Artifact getProjectParent(ModifiedPomXMLEventReader pom, VersionsHelper helper) throws XMLStreamException
pom - The pom.helper - The helper (used to create the artifact).null if no parent is specified.XMLStreamException - if something went wrong.public static boolean setDependencyVersion(ModifiedPomXMLEventReader pom, String groupId, String artifactId, String oldVersion, String newVersion) throws XMLStreamException
pom - The pom to modify.groupId - The groupId of the dependency.artifactId - The artifactId of the dependency.oldVersion - The old version of the dependency.newVersion - The new version of the dependency.true if a replacement was made.XMLStreamException - if somethinh went wrong.public static String evaluate(String expr, Map<String,String> properties)
expr - The expression to evaluate.properties - The properties to substitute.public static boolean isVersionOverlap(String leftVersionOrRange, String rightVersionOrRange) throws org.apache.maven.artifact.versioning.InvalidVersionSpecificationException
leftVersionOrRange - the 1st version number or range to testrightVersionOrRange - the 2nd version number or range to testorg.apache.maven.artifact.versioning.InvalidVersionSpecificationException - if the versions can't be parsed to a rangepublic static boolean setPluginVersion(ModifiedPomXMLEventReader pom, String groupId, String artifactId, String oldVersion, String newVersion) throws XMLStreamException
pom - The pom to modify.groupId - The groupId of the dependency.artifactId - The artifactId of the dependency.oldVersion - The old version of the dependency.newVersion - The new version of the dependency.true if a replacement was made.XMLStreamException - if somethinh went wrong.public static org.codehaus.mojo.versions.api.PropertyVersionsBuilder[] getPropertyVersionsBuilders(VersionsHelper helper, org.apache.maven.project.MavenProject project) throws org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException, IOException
helper - Our versions helper.project - The project to examine.org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException - if an expression cannot be evaluated.IOException - if the project's pom file cannot be parsed.public static Set getAllChildModules(org.apache.maven.project.MavenProject project, org.apache.maven.plugin.logging.Log logger)
project - The project.logger - The logger to use.public static Set<String> getAllChildModules(org.apache.maven.model.Model model, org.apache.maven.plugin.logging.Log logger)
model - The project model.logger - The logger to use.public static void debugModules(org.apache.maven.plugin.logging.Log logger,
String message,
Collection modules)
logger - The logger to log to.message - The message to display.modules - The modules to append to the message.public static void removeMissingChildModules(org.apache.maven.plugin.logging.Log logger,
org.apache.maven.project.MavenProject project,
Collection<String> childModules)
logger - The logger to log to.project - the project.childModules - the child modules.public static void removeMissingChildModules(org.apache.maven.plugin.logging.Log logger,
File basedir,
Collection<String> childModules)
logger - The logger to log to.basedir - the project basedir.childModules - the child modules.public static String getVersion(org.apache.maven.model.Model model)
model - The model.public static boolean isExplicitVersion(org.apache.maven.model.Model model)
model - The model.true if the model explicitly specifies the project version, i.e. /project/versionpublic static String getArtifactId(org.apache.maven.model.Model model)
model - The model.public static String getGroupId(org.apache.maven.model.Model model)
model - The model.public static org.apache.maven.project.MavenProject getLocalRoot(org.apache.maven.project.MavenProjectBuilder builder,
org.apache.maven.project.MavenProject project,
org.apache.maven.artifact.repository.ArtifactRepository localRepository,
org.apache.maven.profiles.ProfileManager globalProfileManager,
org.apache.maven.plugin.logging.Log logger)
project - The project to find the local root for.localRepository - the local repo.globalProfileManager - the global profile manager.logger - The logger to log to.public static Map<String,org.apache.maven.model.Model> getReactorModels(org.apache.maven.project.MavenProject project, org.apache.maven.plugin.logging.Log logger) throws IOException
project - The project to build from.logger - The logger for logging.IOException - if things go wrong.public static Map<String,org.apache.maven.model.Model> getChildModels(Map<String,org.apache.maven.model.Model> reactor, String groupId, String artifactId)
reactor - The map of models keyed by path.groupId - The groupId of the parent.artifactId - The artifactId of the parent.public static org.apache.maven.model.Model getModel(Map<String,org.apache.maven.model.Model> reactor, String groupId, String artifactId)
null if no such model exists.reactor - The map of models keyed by path.groupId - The groupId to match.artifactId - The artifactId to match.null if the model was not in the reactor.public static int getReactorParentCount(Map<String,org.apache.maven.model.Model> reactor, org.apache.maven.model.Model model)
reactor - The map of models keyed by path.model - The model.public static StringBuilder readXmlFile(File outFile) throws IOException
outFile - The file to read.IOException - when things go wrong.Copyright © 2008-2014. All Rights Reserved.