commit: a8b7bf3afb383ba515d32e921dd4412b5991bd8e Author: Benda Xu <heroxbd <AT> gentoo <DOT> org> AuthorDate: Mon Jan 9 10:59:42 2017 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Mon Jan 9 11:09:39 2017 +0000 URL: https://gitweb.gentoo.org/proj/java-ebuilder.git/commit/?id=a8b7bf3a
MavenVersion.java: parse version range. http://maven.apache.org/components/enforcer/enforcer-rules/versionRanges.html https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm .../java/org/gentoo/java/ebuilder/portage/MavenVersion.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/gentoo/java/ebuilder/portage/MavenVersion.java b/src/main/java/org/gentoo/java/ebuilder/portage/MavenVersion.java index 5192abc..e2bf46f 100644 --- a/src/main/java/org/gentoo/java/ebuilder/portage/MavenVersion.java +++ b/src/main/java/org/gentoo/java/ebuilder/portage/MavenVersion.java @@ -15,6 +15,10 @@ public class MavenVersion implements Comparable<MavenVersion> { */ private static final Pattern PATTERN_VERSION = Pattern.compile( "^v?(\\d+)(?:\\.(\\d+))?(?:(?:\\.|b|beta)(\\d+))?(?:[\\.-](.*))?$"); + /** + * Pattern for parsing maven version range. + */ + private static final Pattern p_VERSION_RANGE = Pattern.compile("\\[.*, ?(.*?)\\]"); /** * Incremental version number. */ @@ -37,7 +41,11 @@ public class MavenVersion implements Comparable<MavenVersion> { * * @param version version string */ - public MavenVersion(final String version) { + public MavenVersion(String version) { + Matcher m_RANGE = p_VERSION_RANGE.matcher(version); + if (m_RANGE.matches()) { + version = m_RANGE.group(1); + } final Matcher matcher = PATTERN_VERSION.matcher(version); if (!matcher.matches()) {