ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maart...@apache.org
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 GMT
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 <a href="../ivyfile/dependency.html">dependency</a> doc for details about
built-in version matchers.
-
 <h1>Child elements</h1>
 <table class="ivy-children">
 <thead>
@@ -45,7 +43,86 @@
 </tbody>
 </table>
 
-	</textarea>
+<h1>Built-in Version Matchers</h1>
+<h2>Exact Revesion Matcher</h2>
+A matcher that matches a dependency revision id to the module revision id using simple string
equality.
+
+<h2>Sub Revision Matcher</h2>
+A matcher that matches all revisions starting with a specific prefix. The syntax is: [prefix]+
+
+<table class="ivy-children">
+<thead>
+    <tr><th class="ivy-chld">Revision</th><th class="ivy-chld-desc">Matches</th></tr>
+</thead>
+<tbody>
+
+<tr><td>1.0.+</td><td>all revisions starting with '1.0.', like 1.0.1,
1.0.5, 1.0.a</td></tr>
+<tr><td>1.1+</td><td>all revisions starting with '1.1', like 1.1,
1.1.5, but also 1.10, 1.11</td></tr>
+</table>
+
+<h2>Latest (Status) Matcher</h2>
+
+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.
+
+<table class="ivy-children">
+<thead>
+    <tr><th class="ivy-chld">Revision</th><th class="ivy-chld-desc">Matches</th></tr>
+</thead>
+<tbody>
+
+<tr><td>latest.integration</td><td>all versions</td></tr>
+<tr><td>latest.milestone</td><td>all modules having at least 'milestone'
as status</td></tr>
+<tr><td>latest.release</td><td>all modules having at least 'release'
as status</td></tr>
+<tr><td>latest.[any status]</td><td>all modules having at least the
specified status</td></tr>
+</table>
+
+<h2>Version Range Matcher</h2>
+
+Range types are exhaustively listed by example in the table below.
+
+<table class="ivy-children">
+<thead>
+    <tr><th class="ivy-chld">Revision</th><th class="ivy-chld-desc">Matches</th></tr>
+</thead>
+<tbody>
+
+<tr><td> [1.0,2.0] </td><td> all versions greater or equal to 1.0
and lower or equal to 2.0</td></tr>
+
+<tr><td> [1.0,2.0[ </td><td> all versions greater or equal to 1.0
and lower than 2.0</td></tr>
+
+<tr><td> ]1.0,2.0] </td><td> all versions greater than 1.0 and lower
or equal to 2.0<tr>
+
+<tr><td> ]1.0,2.0[ </td><td> all versions greater than 1.0 and lower
than 2.0</td></tr>
+
+<tr><td> [1.0,) </td><td> all versions greater or equal to 1.0 </td></tr>
+
+<tr><td> ]1.0,) </td><td> all versions greater than 1.0</td></tr>
+
+<tr><td> (,2.0] </td><td> all versions lower or equal to 2.0</td></tr>
+
+<tr><td> (,2.0[ </td><td> all versions lower than 2.0 </td></tr>
+
+</tbody>
+</table>
+
+<h2>Version Pattern Matcher</h2>
+
+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.
+
+<h3>Settings.xml</h3>
+<code type="xml">
+<pattern-vm>
+  <match revision="foo" pattern="${major}\.${minor}\.\d+" args="major, minor" matcher="regexp"
/>
+</pattern-vm>
+</code>
+
+<h3>Ivy.xml</h3>
+<code type="xml">
+<dependency org="acme" name="tool" rev="foo(1, 3)" />
+</code>
+
+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.</textarea>
 <script type="text/javascript">xooki.postProcess();</script>
 </body>
 </html>

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:
+     * <match revision="foo" pattern="${major}\.${minor}\.\d+" args="major, minor" matcher="regexp"
/>
+     * @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:
+     * <match revision="foo" pattern="${major}\.${minor}" args="major, minor" matcher="regexp"
/>
+     * @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



Mime
View raw message