org.ops4j.pax.construct.util
Class XppPom

java.lang.Object
  extended by org.ops4j.pax.construct.util.XppPom
All Implemented Interfaces:
PomUtils.Pom

public class XppPom
extends java.lang.Object
implements PomUtils.Pom

Support round-trip editing of Maven POMs, preserving comments and formatting as much as possible


Constructor Summary
XppPom(java.io.File pomFile)
          Read Maven project details from existing file
XppPom(java.io.File pomFile, java.lang.String groupId, java.lang.String artifactId)
          Create blank Maven project module
 
Method Summary
 void addDependency(org.apache.maven.model.Dependency dependency, boolean overwrite)
          
 void addExclusion(java.lang.String groupId, java.lang.String artifactId, boolean overwrite)
          
 void addModule(java.lang.String module, boolean overwrite)
          
 void addRepository(org.apache.maven.model.Repository repository, boolean snapshots, boolean releases, boolean overwrite, boolean pluginRepo)
          
 boolean equals(java.lang.Object obj)
          
 java.lang.String getArtifactId()
          
 java.io.File getBasedir()
          
 java.lang.String getBundleSymbolicName()
          
 PomUtils.Pom getContainingPom()
          
 java.io.File getFile()
          
 java.lang.String getGroupId()
          
 java.lang.String getId()
          
 java.util.List getModuleNames()
          
 PomUtils.Pom getModulePom(java.lang.String name)
          
 java.lang.String getPackaging()
          
 java.lang.String getParentId()
          
 java.util.Properties getProperties()
          
 java.lang.String getVersion()
          
 int hashCode()
          
 boolean isBundleProject()
          
 void mergeSection(PomUtils.Pom pom, java.lang.String fromSection, java.lang.String toSection, boolean append)
          Merge a section of XML from another Maven project POM
 void overlayDetails(PomUtils.Pom pom)
          Overlay POM template with detail from another Maven project POM
 boolean removeDependency(org.apache.maven.model.Dependency dependency)
          
 boolean removeExclusion(java.lang.String groupId, java.lang.String artifactId)
          
 boolean removeModule(java.lang.String module)
          
 void setGroupId(java.lang.String newGroupId)
          
 void setParent(org.apache.maven.project.MavenProject project, java.lang.String relativePath, boolean overwrite)
          
 void setParent(PomUtils.Pom pom, java.lang.String relativePath, boolean overwrite)
          
 void setProperty(java.lang.String key, java.lang.String value)
          
 void setVersion(java.lang.String newVersion)
          
 java.lang.String toString()
          
 boolean updateDependencyGroup(org.apache.maven.model.Dependency dependency, java.lang.String newGroupId)
          
 boolean updatePluginVersion(java.lang.String groupId, java.lang.String artifactId, java.lang.String newVersion)
          
 void write()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XppPom

public XppPom(java.io.File pomFile)
       throws java.io.IOException
Read Maven project details from existing file

Parameters:
pomFile - XML file containing Maven project model
Throws:
java.io.IOException

XppPom

public XppPom(java.io.File pomFile,
              java.lang.String groupId,
              java.lang.String artifactId)
Create blank Maven project module

Parameters:
pomFile - XML file, may or may not exist
groupId - project group id
artifactId - project artifact id
Method Detail

getId

public java.lang.String getId()

Specified by:
getId in interface PomUtils.Pom
Returns:
unique project identifier

getParentId

public java.lang.String getParentId()

Specified by:
getParentId in interface PomUtils.Pom
Returns:
parents' unique project identifier

getGroupId

public java.lang.String getGroupId()

Specified by:
getGroupId in interface PomUtils.Pom
Returns:
project group id

getArtifactId

public java.lang.String getArtifactId()

Specified by:
getArtifactId in interface PomUtils.Pom
Returns:
project artifact id

getVersion

public java.lang.String getVersion()

Specified by:
getVersion in interface PomUtils.Pom
Returns:
project version

getPackaging

public java.lang.String getPackaging()

Specified by:
getPackaging in interface PomUtils.Pom
Returns:
project packaging

getModuleNames

public java.util.List getModuleNames()

Specified by:
getModuleNames in interface PomUtils.Pom
Returns:
names of modules contained in this project

getContainingPom

public PomUtils.Pom getContainingPom()

Specified by:
getContainingPom in interface PomUtils.Pom
Returns:
the physical parent project

getModulePom

public PomUtils.Pom getModulePom(java.lang.String name)

Specified by:
getModulePom in interface PomUtils.Pom
Parameters:
name - name of a module in this project
Returns:
the module POM, null if it doesn't exist

getFile

public java.io.File getFile()

Specified by:
getFile in interface PomUtils.Pom
Returns:
the underlying Maven POM file

getBasedir

public java.io.File getBasedir()

Specified by:
getBasedir in interface PomUtils.Pom
Returns:
the directory containing this Maven project

isBundleProject

public boolean isBundleProject()

Specified by:
isBundleProject in interface PomUtils.Pom
Returns:
true if this is an OSGi bundle project, otherwise false

getBundleSymbolicName

public java.lang.String getBundleSymbolicName()

Specified by:
getBundleSymbolicName in interface PomUtils.Pom
Returns:
the symbolic name for this project, null if it doesn't define one

setParent

public void setParent(PomUtils.Pom pom,
                      java.lang.String relativePath,
                      boolean overwrite)
               throws PomUtils.ExistingElementException

Specified by:
setParent in interface PomUtils.Pom
Parameters:
pom - the new logical parent project
relativePath - the relative path from this POM to its new parent
overwrite - overwrite element if true, otherwise throw PomUtils.ExistingElementException
Throws:
PomUtils.ExistingElementException

setParent

public void setParent(org.apache.maven.project.MavenProject project,
                      java.lang.String relativePath,
                      boolean overwrite)
               throws PomUtils.ExistingElementException

Specified by:
setParent in interface PomUtils.Pom
Parameters:
project - the new logical parent project
relativePath - the relative path from this POM to the parent
overwrite - overwrite element if true, otherwise throw PomUtils.ExistingElementException
Throws:
PomUtils.ExistingElementException

setGroupId

public void setGroupId(java.lang.String newGroupId)

Specified by:
setGroupId in interface PomUtils.Pom
Parameters:
newGroupId - the new project group id

setVersion

public void setVersion(java.lang.String newVersion)

Specified by:
setVersion in interface PomUtils.Pom
Parameters:
newVersion - the new project version

addRepository

public void addRepository(org.apache.maven.model.Repository repository,
                          boolean snapshots,
                          boolean releases,
                          boolean overwrite,
                          boolean pluginRepo)
                   throws PomUtils.ExistingElementException

Specified by:
addRepository in interface PomUtils.Pom
Parameters:
repository - a Maven repository
snapshots - enable snapshots for this repository
releases - enable releases for this repository
overwrite - overwrite element if true, otherwise throw PomUtils.ExistingElementException
pluginRepo - treat as plugin repository if true, otherwise assume normal repository
Throws:
PomUtils.ExistingElementException

addModule

public void addModule(java.lang.String module,
                      boolean overwrite)
               throws PomUtils.ExistingElementException

Specified by:
addModule in interface PomUtils.Pom
Parameters:
module - module name
overwrite - overwrite element if true, otherwise throw PomUtils.ExistingElementException
Throws:
PomUtils.ExistingElementException

removeModule

public boolean removeModule(java.lang.String module)

Specified by:
removeModule in interface PomUtils.Pom
Parameters:
module - module name
Returns:
true if module was removed from the project, otherwise false

addDependency

public void addDependency(org.apache.maven.model.Dependency dependency,
                          boolean overwrite)
                   throws PomUtils.ExistingElementException

Specified by:
addDependency in interface PomUtils.Pom
Parameters:
dependency - project dependency
overwrite - overwrite element if true, otherwise throw PomUtils.ExistingElementException
Throws:
PomUtils.ExistingElementException

updateDependencyGroup

public boolean updateDependencyGroup(org.apache.maven.model.Dependency dependency,
                                     java.lang.String newGroupId)

Specified by:
updateDependencyGroup in interface PomUtils.Pom
Parameters:
dependency - project dependency
newGroupId - updated dependency group id
Returns:
true if the dependency was updated

removeDependency

public boolean removeDependency(org.apache.maven.model.Dependency dependency)

Specified by:
removeDependency in interface PomUtils.Pom
Parameters:
dependency - project dependency
Returns:
true if dependency was removed from the project, otherwise false

addExclusion

public void addExclusion(java.lang.String groupId,
                         java.lang.String artifactId,
                         boolean overwrite)
                  throws PomUtils.ExistingElementException

Specified by:
addExclusion in interface PomUtils.Pom
Parameters:
groupId - dependency exclusion group id
artifactId - dependency exclusion artifact id
overwrite - overwrite element if true, otherwise throw PomUtils.ExistingElementException
Throws:
PomUtils.ExistingElementException

removeExclusion

public boolean removeExclusion(java.lang.String groupId,
                               java.lang.String artifactId)

Specified by:
removeExclusion in interface PomUtils.Pom
Parameters:
groupId - dependency exclusion group id
artifactId - dependency exclusion artifact id
Returns:
true if dependency exclusion was removed from the project, otherwise false

getProperties

public java.util.Properties getProperties()

Specified by:
getProperties in interface PomUtils.Pom
Returns:
properties defined by the current project

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)

Specified by:
setProperty in interface PomUtils.Pom
Parameters:
key - property key
value - property value

updatePluginVersion

public boolean updatePluginVersion(java.lang.String groupId,
                                   java.lang.String artifactId,
                                   java.lang.String newVersion)

Specified by:
updatePluginVersion in interface PomUtils.Pom
Parameters:
groupId - plugin group id
artifactId - plugin artifact id
newVersion - new plugin version
Returns:
true if the plugin was updated

mergeSection

public void mergeSection(PomUtils.Pom pom,
                         java.lang.String fromSection,
                         java.lang.String toSection,
                         boolean append)
Merge a section of XML from another Maven project POM

Specified by:
mergeSection in interface PomUtils.Pom
Parameters:
pom - another Maven project
fromSection - path to XML section to merge from
toSection - path to XML section to merge into
append - when true, append instead of merging

overlayDetails

public void overlayDetails(PomUtils.Pom pom)
Overlay POM template with detail from another Maven project POM

Specified by:
overlayDetails in interface PomUtils.Pom
Parameters:
pom - another Maven project

write

public void write()
           throws java.io.IOException

Specified by:
write in interface PomUtils.Pom
Throws:
java.io.IOException

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object


Copyright © 2007-2008 OPS4J. All Rights Reserved.