Return-Path: Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: (qmail 8636 invoked from network); 30 Jun 2009 21:03:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Jun 2009 21:03:51 -0000 Received: (qmail 32596 invoked by uid 500); 30 Jun 2009 21:04:02 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 32536 invoked by uid 500); 30 Jun 2009 21:04:02 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 32527 invoked by uid 99); 30 Jun 2009 21:04:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Jun 2009 21:04:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Jun 2009 21:03:58 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 865C823888CD; Tue, 30 Jun 2009 21:03:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r789952 - in /ant/ivy/core/trunk: CHANGES.txt doc/settings/version-matchers.html src/java/org/apache/ivy/core/settings/typedef.properties test/java/org/apache/ivy/plugins/version/PatternVersionMatcherTest.java Date: Tue, 30 Jun 2009 21:03:38 -0000 To: notifications@ant.apache.org From: maartenc@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090630210338.865C823888CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: maartenc Date: Tue Jun 30 21:03:37 2009 New Revision: 789952 URL: http://svn.apache.org/viewvc?rev=789952&view=rev Log: - NEW: added built-in versionmatcher: 'Version Pattern Matcher' (IVY-871) - DOCUMENTATION: missing documentation for the 'Version Pattern Matcher' (IVY-871) (thanks to Jon Schneider) Added: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/version/PatternVersionMatcherTest.java (with props) Modified: ant/ivy/core/trunk/CHANGES.txt ant/ivy/core/trunk/doc/settings/version-matchers.html ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/typedef.properties Modified: ant/ivy/core/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=789952&r1=789951&r2=789952&view=diff ============================================================================== --- ant/ivy/core/trunk/CHANGES.txt (original) +++ ant/ivy/core/trunk/CHANGES.txt Tue Jun 30 21:03:37 2009 @@ -90,10 +90,12 @@ trunk ===================================== -- DOCUMENTATION: not all attirubtes of publish task are documented (IVY-963) (thanks to Jon Schneider) +- DOCUMENTATION: not all attributes of publish task are documented (IVY-963) (thanks to Jon Schneider) +- DOCUMENTATION: missing documentation for the 'Version Pattern Matcher' (IVY-871) (thanks to Jon Schneider) - NEW: configuration intersections (IVY-1093) - NEW: configuration groups (IVY-1097) +- NEW: added built-in versionmatcher: 'Version Pattern Matcher' (IVY-871) - IMPROVEMENT: Added support for NTLM authentication (IVY-1094) (thanks to Mathieu Anquetin) - IMPROVEMENT: Standalone runner should accept all the same parameters as ant tasks (IVY-1090) Modified: ant/ivy/core/trunk/doc/settings/version-matchers.html URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/settings/version-matchers.html?rev=789952&r1=789951&r2=789952&view=diff ============================================================================== --- ant/ivy/core/trunk/doc/settings/version-matchers.html (original) +++ ant/ivy/core/trunk/doc/settings/version-matchers.html Tue Jun 30 21:03:37 2009 @@ -32,8 +32,6 @@ A version matcher is used to evaluate if a a dependency version contraint matches a dependency version. -See dependency doc for details about built-in version matchers. -

Child elements

@@ -45,7 +43,86 @@
- +

Built-in Version Matchers

+

Exact Revesion Matcher

+A matcher that matches a dependency revision id to the module revision id using simple string equality. + +

Sub Revision Matcher

+A matcher that matches all revisions starting with a specific prefix. The syntax is: [prefix]+ + + + + + + + + + +
RevisionMatches
1.0.+all revisions starting with '1.0.', like 1.0.1, 1.0.5, 1.0.a
1.1+all revisions starting with '1.1', like 1.1, 1.1.5, but also 1.10, 1.11
+ +

Latest (Status) Matcher

+ +A matcher that can matches versions based on their status. The predefined statuses in Ivy are 'release', 'milestone' and 'integration'. It's possible to define your own statuses, see [[settings/statuses]] for more detais. + + + + + + + + + + + +
RevisionMatches
latest.integrationall versions
latest.milestoneall modules having at least 'milestone' as status
latest.releaseall modules having at least 'release' as status
latest.[any status]all modules having at least the specified status
+ +

Version Range Matcher

+ +Range types are exhaustively listed by example in the table below. + + + + + + + + + + + + + + + + + + + + + + + + +
RevisionMatches
[1.0,2.0] all versions greater or equal to 1.0 and lower or equal to 2.0
[1.0,2.0[ all versions greater or equal to 1.0 and lower than 2.0
]1.0,2.0] all versions greater than 1.0 and lower or equal to 2.0
]1.0,2.0[ all versions greater than 1.0 and lower than 2.0
[1.0,) all versions greater or equal to 1.0
]1.0,) all versions greater than 1.0
(,2.0] all versions lower or equal to 2.0
(,2.0[ all versions lower than 2.0
+ +

Version Pattern Matcher

+ +The version pattern matcher allows for more flexibility in pattern matching at the cost of adding a matcher declaration in Ivy settings. A simple example is given below. + +

Settings.xml

+ + + + + + +

Ivy.xml

+ + + + +The version pattern matcher may contain more than one match element. The matcher will attempt to match a dependency revision against each match in sequence, checking the revision tag (e.g. foo(..)) and then the pattern. +Matcher types may be one of "regexp", "exact", "glob", or "exactOrRegexp". Glob pattern matching requires Apache ORO 2.0.8 or higher to be on the classpath. Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/typedef.properties URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/typedef.properties?rev=789952&r1=789951&r2=789952&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/typedef.properties (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/typedef.properties Tue Jun 30 21:03:37 2009 @@ -48,6 +48,7 @@ latest-vm = org.apache.ivy.plugins.version.LatestVersionMatcher sub-vm = org.apache.ivy.plugins.version.SubVersionMatcher range-vm = org.apache.ivy.plugins.version.VersionRangeMatcher +pattern-vm = org.apache.ivy.plugins.version.PatternVersionMatcher ant-build = org.apache.ivy.ant.AntBuildTrigger ant-call = org.apache.ivy.ant.AntCallTrigger Added: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/version/PatternVersionMatcherTest.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/version/PatternVersionMatcherTest.java?rev=789952&view=auto ============================================================================== --- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/version/PatternVersionMatcherTest.java (added) +++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/version/PatternVersionMatcherTest.java Tue Jun 30 21:03:37 2009 @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.ivy.plugins.version; + +import org.apache.ivy.core.module.id.ModuleRevisionId; + +import junit.framework.TestCase; + +public class PatternVersionMatcherTest extends TestCase { + public void testSingleMatch() { + PatternVersionMatcher pvm = new PatternVersionMatcher(); + pvm.addMatch(generateRegexpMatch1()); + + assertAccept(pvm, "foo(1,3)", "1.4.1", false); + assertAccept(pvm, "foo(1,3)", "1.3", false); + assertAccept(pvm, "foo(1,3)", "2.3.1", false); + + assertAccept(pvm, "foo(1,3)", "1.3.1", true); + } + + public void testMultipleMatchEqualRevisions() { + PatternVersionMatcher pvm = new PatternVersionMatcher(); + pvm.addMatch(generateRegexpMatch1()); + pvm.addMatch(generateRegexpMatch2()); + + assertAccept(pvm, "foo(1,3)", "1.3", true); + assertAccept(pvm, "foo(1,3)", "1.3.1", true); + } + + public void testMultipleMatchNonEqualRevisions() { + PatternVersionMatcher pvm = new PatternVersionMatcher(); + pvm.addMatch(generateRegexpMatch1()); + pvm.addMatch(generateRegexpMatch3()); + + assertAccept(pvm, "foo(1,3)", "1.3", false); + assertAccept(pvm, "bar(1,3)", "1.3", true); + assertAccept(pvm, "foo(1,3)", "1.3.1", true); + } + + /** + * Generates a Match instance that has the following xml representation: + * + * @return + */ + private Match generateRegexpMatch1() { + Match match = new Match(); + match.setRevision("foo"); + match.setPattern("${major}\\.${minor}\\.\\d+"); + match.setArgs("major, minor"); + match.setMatcher("regexp"); + + return match; + } + + /** + * Generates a Match instance that has the following xml representation: + * + * @return + */ + private Match generateRegexpMatch2() { + Match match = new Match(); + match.setRevision("foo"); + match.setPattern("${major}\\.${minor}"); + match.setArgs("major, minor"); + match.setMatcher("regexp"); + + return match; + } + + private Match generateRegexpMatch3() { + Match match = new Match(); + match.setRevision("bar"); + match.setPattern("${major}\\.${minor}"); + match.setArgs("major, minor"); + match.setMatcher("regexp"); + + return match; + } + + + private void assertAccept(PatternVersionMatcher matcher, String askedVersion, + String depVersion, boolean b) { + assertEquals(b, matcher.accept(ModuleRevisionId.newInstance("org", "name", askedVersion), + ModuleRevisionId.newInstance("org", "name", depVersion))); + } +} Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/version/PatternVersionMatcherTest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain