- java.lang.Object
-
- org.scijava.meta.XML
-
- org.scijava.meta.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 static List<POM>allPOMs()Gets all available Maven POMs on the class path.StringartifactId()Gets the POM's artifactId.StringciManagementSystem()Gets the CI management system.StringciManagementURL()Gets the CI management URL.intcompareTo(POM pom)static intcompareVersions(String v1, String v2)Compares two version strings.StringgroupId()Gets the POM's groupId.StringissueManagementSystem()Gets the issue management system.StringissueManagementURL()Gets the issue management URL.StringorganizationName()Gets the organization name.StringorganizationURL()Gets the organization URL.StringparentArtifactId()Gets the POM's parent artifactId.StringparentGroupId()Gets the POM's parent groupId.StringparentVersion()Gets the POM's parent artifactId.static POMpom(Class<?> c)Gets the Maven POM associated with the given class.static POMpom(Class<?> c, String groupId, String artifactId)Gets the Maven POM associated with the given class.StringprojectDescription()Gets the project description.StringprojectInceptionYear()Gets the project inception year.StringprojectName()Gets the project name.StringprojectURL()Gets the project URL.StringscmConnection()Gets the SCM connection string.StringscmDeveloperConnection()Gets the SCM developerConnection string.StringscmTag()Gets the SCM tag.StringscmURL()Gets the SCM URL.Stringversion()Gets the POM's version.
-
-
-
Constructor Detail
-
POM
public POM(File file) throws IOException
Parses a POM from the given file.- Throws:
IOException
-
POM
public POM(URL url) throws IOException
Parses a POM from the given URL.- Throws:
IOException
-
POM
public POM(InputStream in) throws IOException
Parses a POM from the given input stream.- Throws:
IOException
-
POM
public POM(String s) throws IOException
Parses a POM from the given string.- Throws:
IOException
-
-
Method Detail
-
parentGroupId
public String parentGroupId()
Gets the POM's parent groupId.
-
parentArtifactId
public String parentArtifactId()
Gets the POM's parent artifactId.
-
parentVersion
public String parentVersion()
Gets the POM's parent artifactId.
-
groupId
public String groupId()
Gets the POM's groupId.
-
artifactId
public String artifactId()
Gets the POM's artifactId.
-
projectName
public String projectName()
Gets the project name.
-
projectDescription
public String projectDescription()
Gets the project description.
-
projectURL
public String projectURL()
Gets the project URL.
-
projectInceptionYear
public String projectInceptionYear()
Gets the project inception year.
-
organizationName
public String organizationName()
Gets the organization name.
-
organizationURL
public String organizationURL()
Gets the organization URL.
-
scmConnection
public String scmConnection()
Gets the SCM connection string.
-
scmDeveloperConnection
public String scmDeveloperConnection()
Gets the SCM developerConnection string.
-
scmTag
public String scmTag()
Gets the SCM tag.
-
scmURL
public String scmURL()
Gets the SCM URL.
-
issueManagementSystem
public String issueManagementSystem()
Gets the issue management system.
-
issueManagementURL
public String issueManagementURL()
Gets the issue management URL.
-
ciManagementSystem
public String ciManagementSystem()
Gets the CI management system.
-
ciManagementURL
public String ciManagementURL()
Gets the CI management URL.
-
compareTo
public int compareTo(POM pom)
- Specified by:
compareToin interfaceComparable<POM>
-
version
public String version()
Gets the POM's version.
-
pom
public static POM pom(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.
-
pom
public static POM pom(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 "pre-release" 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)
-
-