[ 
https://issues.apache.org/jira/browse/IVY-871?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16268633#comment-16268633
 ] 

jaikiran pai edited comment on IVY-871 at 11/28/17 12:01 PM:
-------------------------------------------------------------

[~martinm82], thank you for adding those details. I have to admit, the 
documentation around this matcher needs a bit more work to make it clear what 
it does. I had to go back and check the code to understand what it's doing.

In short, what it does is (using your snippet as an example), when it sees that 
there's a matcher configured for something called {{latestRel}}, during 
dependency resolution, it checks if the revision being asked for, via a 
dependency matches the {{revision}} attribute of the {{matcher}} configured. If 
it does, then it uses that configured matcher to see if it can resolve a 
version for this dependency. While doing so, the matcher can (optionally) be 
passed "arguments", a list of which is configured on the matcher through the 
{{args}} attribute. So in your case, you are expecting {{release}} as an 
argument to the matcher. The dependency (in your ivy.xml) passes a value for 
this argument. In your case, you are passing {{17.4}} as an argument to that 
matcher. The matcher can be configured (as you have done in your case) to use 
the (substituted value) of the argument(s) in the {{pattern}} attribute. So in 
your case, this now translates to the {{pattern}} attribute value being 
{{\d+\.\d+\.\d+-17.4\.*}}.

 This value of the {{pattern}} attribute is then used for matching/resolving 
the versions for the dependency. How that {{pattern}} value is semantically 
interpreted is decided by the {{matcher}} attribute and in this case you have 
configured it to be a {{regex}}. So your pattern value 
{{\d+\.\d+\.\d+-17.4\.*}} will now be used as a regular expression while 
evaluating the dependency version {{latestRel(17.4)}} asked for as an ivy 
dependency. I hope that makes it clear on what it does. I'll add this (with 
some changes maybe) to our documentation this week.





was (Author: jaikiran):
[~martinm82], thank you for adding those details. I have to admit, the 
documentation around this matcher needs a bit more work to make it clear what 
it does. I had to go back and check the code to understand what it's doing.

In short, what it does is (using your snippet as an example), when it sees that 
there's a matcher configured for something called {{latestRel}}, during 
dependency resolution, it checks if the revision being asked for, via a 
dependency matches the {{revision}} attribute of the {{matcher}} configured. If 
it does, then it uses that configured matcher to see if it can resolve a 
version for this dependency. While doing so, the matcher can (optionally) be 
passed "arguments", a list of which is configured on the matcher through the 
{{args}} attribute. So in your case, you are expecting {{release}} as an 
argument to the matcher. The dependency (in your ivy.xml) passes a value for 
this argument. In your case, you are passing {{17.4}} as an argument to that 
matcher. The matcher can be configured (as you have done in your case) to use 
the (substituted value) of the argument(s) in the {{pattern}} attribute. So in 
your case, this now translates to the {{pattern}} attribute value being 
{{\d+\.\d+\.\d+-17.4\.*}}. This value of the {{pattern}} attribute is then used 
for matching/resolving the versions for the dependency. How that {{pattern}} 
value is semantically interpreted is decided by the {{matcher}} attribute and 
in this case you have configured it to be a {{regex}}. So your pattern value 
{{\d+\.\d+\.\d+-17.4\.*}} will now be used as a regular expression while 
evaluating the dependency version {{latestRel(17.4)}} asked for as an ivy 
dependency. I hope that makes it clear on what it does. I'll add this (with 
some changes maybe) to our documentation this week.




> test and document PatternVersionMatcher
> ---------------------------------------
>
>                 Key: IVY-871
>                 URL: https://issues.apache.org/jira/browse/IVY-871
>             Project: Ivy
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Xavier Hanin
>            Assignee: Maarten Coene
>             Fix For: 2.1.0-RC2
>
>         Attachments: patch.txt
>
>
> There is a powerful version matcher in Ivy code base called 
> PatternVersionMatcher. Unfortunately, this matcher is not documented, not 
> tested, and not declared in the default typedef.properties. Nobody remembers 
> where it comes from, but code analysis should be enough to understand how it 
> works and what it can achieve.
> Here's what I understand from a quick analysis:
> {code:title=settings.xml}
> <pattern-vm>
>   <match revision="micro" pattern="${major}\.${minor}\.\d+" args="major, 
> minor" matcher="regexp" />
> </pattern-vm>
> {code}
> {code:title=ivy.xml}
> <dependency org="acme" name="foo" rev="micro(1, 3)" />
> {code}
> If I understand correctly the code, this will match any revision like 
> 1.3.<any number>.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to