Package org.scijava.util
Class POM
- java.lang.Object
-
- org.scijava.util.XML
-
- org.scijava.util.POM
-
- All Implemented Interfaces:
Comparable<POM>,Versioned
public class POM extends XML implements Comparable<POM>, Versioned
Helper class for working with Maven POMs.- Author:
- Curtis Rueden
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(POM pom)static intcompareVersions(String v1, String v2)Compares two version strings.static List<POM>getAllPOMs()Gets all available Maven POMs on the class path.StringgetArtifactId()Gets the POM's artifactId.StringgetCIManagementSystem()Gets the CI management system.StringgetCIManagementURL()Gets the CI management URL.StringgetGroupId()Gets the POM's groupId.StringgetIssueManagementSystem()Gets the issue management system.StringgetIssueManagementURL()Gets the issue management URL.StringgetOrganizationName()Gets the organization name.StringgetOrganizationURL()Gets the organization URL.StringgetParentArtifactId()Gets the POM's parent artifactId.StringgetParentGroupId()Gets the POM's parent groupId.StringgetParentVersion()Gets the POM's parent artifactId.static POMgetPOM(Class<?> c)Gets the Maven POM associated with the given class.static POMgetPOM(Class<?> c, String groupId, String artifactId)Gets the Maven POM associated with the given class.StringgetProjectDescription()Gets the project description.StringgetProjectInceptionYear()Gets the project inception year.StringgetProjectName()Gets the project name.StringgetProjectURL()Gets the project URL.StringgetSCMConnection()Gets the SCM connection string.StringgetSCMDeveloperConnection()Gets the SCM developerConnection string.StringgetSCMTag()Gets the SCM tag.StringgetSCMURL()Gets the SCM URL.StringgetVersion()Gets the POM's version.
-
-
-
Constructor Detail
-
POM
public POM(File file) throws ParserConfigurationException, SAXException, IOException
Parses a POM from the given file.
-
POM
public POM(URL url) throws ParserConfigurationException, SAXException, IOException
Parses a POM from the given URL.
-
POM
public POM(InputStream in) throws ParserConfigurationException, SAXException, IOException
Parses a POM from the given input stream.
-
POM
public POM(String s) throws ParserConfigurationException, SAXException, IOException
Parses a POM from the given string.
-
-
Method Detail
-
getParentGroupId
public String getParentGroupId()
Gets the POM's parent groupId.
-
getParentArtifactId
public String getParentArtifactId()
Gets the POM's parent artifactId.
-
getParentVersion
public String getParentVersion()
Gets the POM's parent artifactId.
-
getGroupId
public String getGroupId()
Gets the POM's groupId.
-
getArtifactId
public String getArtifactId()
Gets the POM's artifactId.
-
getProjectName
public String getProjectName()
Gets the project name.
-
getProjectDescription
public String getProjectDescription()
Gets the project description.
-
getProjectURL
public String getProjectURL()
Gets the project URL.
-
getProjectInceptionYear
public String getProjectInceptionYear()
Gets the project inception year.
-
getOrganizationName
public String getOrganizationName()
Gets the organization name.
-
getOrganizationURL
public String getOrganizationURL()
Gets the organization URL.
-
getSCMConnection
public String getSCMConnection()
Gets the SCM connection string.
-
getSCMDeveloperConnection
public String getSCMDeveloperConnection()
Gets the SCM developerConnection string.
-
getSCMTag
public String getSCMTag()
Gets the SCM tag.
-
getSCMURL
public String getSCMURL()
Gets the SCM URL.
-
getIssueManagementSystem
public String getIssueManagementSystem()
Gets the issue management system.
-
getIssueManagementURL
public String getIssueManagementURL()
Gets the issue management URL.
-
getCIManagementSystem
public String getCIManagementSystem()
Gets the CI management system.
-
getCIManagementURL
public String getCIManagementURL()
Gets the CI management URL.
-
compareTo
public int compareTo(POM pom)
- Specified by:
compareToin interfaceComparable<POM>
-
getVersion
public String getVersion()
Gets the POM's version.- Specified by:
getVersionin interfaceVersioned
-
getPOM
public static POM getPOM(Class<?> c)
Gets the Maven POM associated with the given class.- Parameters:
c- The class to use as a base when searching for a pom.xml.- Returns:
POMobject representing the discovered POM, or null if no POM could be found.
-
getPOM
public static POM getPOM(Class<?> c, String groupId, String artifactId)
Gets the Maven POM associated with the given class.- Parameters:
c- The class to use as a base when searching for a pom.xml.groupId- The Maven groupId of the desired POM.artifactId- The Maven artifactId of the desired POM.- Returns:
POMobject representing the discovered POM, or null if no POM could be found.
-
compareVersions
public static int compareVersions(String v1, String v2)
Compares two version strings.Given the variation between versioning styles, there is no single comparison method that can possibly be correct 100% of the time. So this method works on a "best effort" basis; YMMV.
The algorithm is as follows:
- Split on non-alphameric characters.
- Compare each token one by one.
- Comparison is numerical when possible (i.e., when an integer can be parsed from the token), and lexicographic otherwise.
- If one version string runs out of tokens, the version with additional tokens remaining is considered greater than the version without additional tokens.
- There is one exception: if two version strings are identical except
that one has a suffix beginning with a dash (
-), the version with suffix will be considered less than the one without a suffix. The reason for this is to accommodate the SemVer versioning scheme's usage of "prerelease" version suffixes. For example,2.0.0will compare greater than2.0.0-beta-1, whereas2.0.0will compare less than2.0.0.1.
- Returns:
- a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
- See Also:
Comparator.compare(Object, Object)
-
-