You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by xa...@apache.org on 2007/06/05 12:02:43 UTC
svn commit: r544459 [24/36] - in /incubator/ivy/core/trunk:
src/java/org/apache/ivy/ src/java/org/apache/ivy/ant/
src/java/org/apache/ivy/core/ src/java/org/apache/ivy/core/cache/
src/java/org/apache/ivy/core/check/ src/java/org/apache/ivy/core/deliver...
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/ResolverHelper.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/ResolverHelper.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/ResolverHelper.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/ResolverHelper.java Tue Jun 5 05:02:27 2007
@@ -34,7 +34,6 @@
import org.apache.ivy.plugins.repository.Resource;
import org.apache.ivy.util.Message;
-
public class ResolverHelper {
// lists all the values a token can take in a pattern, as listed by a given url lister
public static String[] listTokenValues(Repository rep, String pattern, String token) {
@@ -43,11 +42,12 @@
String tokenString = IvyPatternHelper.getTokenString(token);
int index = pattern.indexOf(tokenString);
if (index == -1) {
- Message.verbose("unable to list "+token+" in "+pattern+": token not found in pattern");
+ Message.verbose("unable to list " + token + " in " + pattern
+ + ": token not found in pattern");
return null;
}
- if (((pattern.length() <= index + tokenString.length())
- || fileSep.equals(pattern.substring(index + tokenString.length(), index + tokenString.length() + 1)))
+ if (((pattern.length() <= index + tokenString.length()) || fileSep.equals(pattern
+ .substring(index + tokenString.length(), index + tokenString.length() + 1)))
&& (index == 0 || fileSep.equals(pattern.substring(index - 1, index)))) {
// the searched token is a whole name
String root = pattern.substring(0, index);
@@ -55,157 +55,180 @@
} else {
int slashIndex = pattern.substring(0, index).lastIndexOf(fileSep);
String root = slashIndex == -1 ? "" : pattern.substring(0, slashIndex);
-
+
try {
- Message.debug("\tusing "+rep+" to list all in "+root);
+ Message.debug("\tusing " + rep + " to list all in " + root);
List all = rep.list(root);
if (all != null) {
- Message.debug("\t\tfound "+all.size()+" urls");
+ Message.debug("\t\tfound " + all.size() + " urls");
List ret = new ArrayList(all.size());
int endNameIndex = pattern.indexOf(fileSep, slashIndex + 1);
String namePattern;
if (endNameIndex != -1) {
- namePattern = pattern.substring(slashIndex+1, endNameIndex);
+ namePattern = pattern.substring(slashIndex + 1, endNameIndex);
} else {
namePattern = pattern.substring(slashIndex + 1);
}
- String acceptNamePattern = ".*"+IvyPatternHelper.substituteToken(namePattern, token, "([^"+fileSep+"]+)")+".*";
+ String acceptNamePattern = ".*"
+ + IvyPatternHelper.substituteToken(namePattern, token, "([^" + fileSep
+ + "]+)") + ".*";
Pattern p = Pattern.compile(acceptNamePattern.toString());
for (Iterator iter = all.iterator(); iter.hasNext();) {
- String path = (String)iter.next();
+ String path = (String) iter.next();
Matcher m = p.matcher(path);
if (m.matches()) {
String value = m.group(1);
ret.add(value);
}
}
- Message.debug("\t\t"+ret.size()+" matched "+pattern);
- return (String[])ret.toArray(new String[ret.size()]);
+ Message.debug("\t\t" + ret.size() + " matched " + pattern);
+ return (String[]) ret.toArray(new String[ret.size()]);
} else {
return null;
}
} catch (Exception e) {
- Message.warn("problem while listing resources in "+root+" with "+rep+":");
- Message.warn(" "+e.getClass().getName()+" "+e.getMessage());
+ Message.warn("problem while listing resources in " + root + " with " + rep + ":");
+ Message.warn(" " + e.getClass().getName() + " " + e.getMessage());
return null;
}
}
}
-
+
public static String[] listAll(Repository rep, String parent) {
try {
String fileSep = rep.getFileSeparator();
- Message.debug("\tusing "+rep+" to list all in "+parent);
+ Message.debug("\tusing " + rep + " to list all in " + parent);
List all = rep.list(parent);
if (all != null) {
- Message.debug("\t\tfound "+all.size()+" resources");
+ Message.debug("\t\tfound " + all.size() + " resources");
List names = new ArrayList(all.size());
for (Iterator iter = all.iterator(); iter.hasNext();) {
- String path = (String)iter.next();
- if (path.endsWith(fileSep)) {
+ String path = (String) iter.next();
+ if (path.endsWith(fileSep)) {
path = path.substring(0, path.length() - 1);
}
int slashIndex = path.lastIndexOf(fileSep);
- names.add(path.substring(slashIndex +1));
+ names.add(path.substring(slashIndex + 1));
}
- return (String[])names.toArray(new String[names.size()]);
+ return (String[]) names.toArray(new String[names.size()]);
} else {
Message.debug("\t\tno resources found");
return null;
}
} catch (Exception e) {
- Message.warn("problem while listing resources in "+parent+" with "+rep+":");
- Message.warn(" "+e.getClass().getName()+" "+e.getMessage());
+ Message.warn("problem while listing resources in " + parent + " with " + rep + ":");
+ Message.warn(" " + e.getClass().getName() + " " + e.getMessage());
return null;
- }
+ }
}
-
- public static ResolvedResource[] findAll(Repository rep, ModuleRevisionId mrid, String pattern, Artifact artifact) {
+
+ public static ResolvedResource[] findAll(Repository rep, ModuleRevisionId mrid, String pattern,
+ Artifact artifact) {
// substitute all but revision
- String partiallyResolvedPattern = IvyPatternHelper.substitute(pattern, ModuleRevisionId.newInstance(mrid, IvyPatternHelper.getTokenString(IvyPatternHelper.REVISION_KEY)), artifact);
- Message.debug("\tlisting all in "+partiallyResolvedPattern);
-
- String[] revs = listTokenValues(rep, partiallyResolvedPattern, IvyPatternHelper.REVISION_KEY);
+ String partiallyResolvedPattern = IvyPatternHelper.substitute(pattern, ModuleRevisionId
+ .newInstance(mrid, IvyPatternHelper.getTokenString(IvyPatternHelper.REVISION_KEY)),
+ artifact);
+ Message.debug("\tlisting all in " + partiallyResolvedPattern);
+
+ String[] revs = listTokenValues(rep, partiallyResolvedPattern,
+ IvyPatternHelper.REVISION_KEY);
if (revs != null) {
- Message.debug("\tfound revs: "+Arrays.asList(revs));
+ Message.debug("\tfound revs: " + Arrays.asList(revs));
List ret = new ArrayList(revs.length);
for (int i = 0; i < revs.length; i++) {
- String rres = IvyPatternHelper.substituteToken(partiallyResolvedPattern, IvyPatternHelper.REVISION_KEY, revs[i]);
+ String rres = IvyPatternHelper.substituteToken(partiallyResolvedPattern,
+ IvyPatternHelper.REVISION_KEY, revs[i]);
try {
- ret.add(new ResolvedResource(rep.getResource(rres), revs[i]));
- } catch (IOException e) {
- Message.warn("impossible to get resource from name listed by repository: "+rres+": "+e.getMessage());
- }
+ ret.add(new ResolvedResource(rep.getResource(rres), revs[i]));
+ } catch (IOException e) {
+ Message.warn("impossible to get resource from name listed by repository: "
+ + rres + ": " + e.getMessage());
+ }
}
if (revs.length != ret.size()) {
- Message.debug("\tfound resolved res: "+ret);
+ Message.debug("\tfound resolved res: " + ret);
}
- return (ResolvedResource[])ret.toArray(new ResolvedResource[ret.size()]);
- } else if (partiallyResolvedPattern.indexOf("["+IvyPatternHelper.REVISION_KEY+"]") == -1) {
+ return (ResolvedResource[]) ret.toArray(new ResolvedResource[ret.size()]);
+ } else if (partiallyResolvedPattern.indexOf("[" + IvyPatternHelper.REVISION_KEY + "]") == -1) {
// the partially resolved pattern is completely resolved, check the resource
try {
Resource res = rep.getResource(partiallyResolvedPattern);
if (res.exists()) {
- Message.debug("\tonly one resource found without real listing: using and defining it as working@"+rep.getName()+" revision: "+res.getName());
- return new ResolvedResource[] {new ResolvedResource(res, "working@"+rep.getName())};
+ Message
+ .debug("\tonly one resource found without real listing: using and defining it as working@"
+ + rep.getName() + " revision: " + res.getName());
+ return new ResolvedResource[] {new ResolvedResource(res, "working@"
+ + rep.getName())};
}
} catch (IOException e) {
- Message.debug("\timpossible to get resource from name listed by repository: "+partiallyResolvedPattern+": "+e.getMessage());
+ Message.debug("\timpossible to get resource from name listed by repository: "
+ + partiallyResolvedPattern + ": " + e.getMessage());
}
Message.debug("\tno revision found");
}
return null;
}
-// public static ResolvedResource[] findAll(Repository rep, ModuleRevisionId mrid, String pattern, Artifact artifact, VersionMatcher versionMatcher, ResourceMDParser mdParser) {
-// // substitute all but revision
-// String partiallyResolvedPattern = IvyPatternHelper.substitute(pattern, new ModuleRevisionId(mrid.getModuleId(), IvyPatternHelper.getTokenString(IvyPatternHelper.REVISION_KEY), mrid.getExtraAttributes()), artifact);
-// Message.debug("\tlisting all in "+partiallyResolvedPattern);
-//
-// String[] revs = listTokenValues(rep, partiallyResolvedPattern, IvyPatternHelper.REVISION_KEY);
-// if (revs != null) {
-// Message.debug("\tfound revs: "+Arrays.asList(revs));
-// List ret = new ArrayList(revs.length);
-// String rres = null;
-// for (int i = 0; i < revs.length; i++) {
-// ModuleRevisionId foundMrid = new ModuleRevisionId(mrid.getModuleId(), revs[i], mrid.getExtraAttributes());
-// if (versionMatcher.accept(mrid, foundMrid)) {
-// rres = IvyPatternHelper.substituteToken(partiallyResolvedPattern, IvyPatternHelper.REVISION_KEY, revs[i]);
-// try {
-// ResolvedResource resolvedResource;
-// if (versionMatcher.needModuleDescriptor(mrid, foundMrid)) {
-// resolvedResource = mdParser.parse(rep.getResource(rres), revs[i]);
-// if (!versionMatcher.accept(mrid, ((MDResolvedResource)resolvedResource).getResolvedModuleRevision().getDescriptor())) {
-// continue;
-// }
-// } else {
-// resolvedResource = new ResolvedResource(rep.getResource(rres), revs[i]);
-// }
-// ret.add(resolvedResource);
-// } catch (IOException e) {
-// Message.warn("impossible to get resource from name listed by repository: "+rres+": "+e.getMessage());
-// }
-// }
-// }
-// if (revs.length != ret.size()) {
-// Message.debug("\tfound resolved res: "+ret);
-// }
-// return (ResolvedResource[])ret.toArray(new ResolvedResource[ret.size()]);
-// } else {
-// // maybe the partially resolved pattern is completely resolved ?
-// try {
-// Resource res = rep.getResource(partiallyResolvedPattern);
-// if (res.exists()) {
-// Message.debug("\tonly one resource found without real listing: using and defining it as working@"+rep.getName()+" revision: "+res.getName());
-// return new ResolvedResource[] {new ResolvedResource(res, "working@"+rep.getName())};
-// }
-// } catch (IOException e) {
-// Message.debug("\timpossible to get resource from name listed by repository: "+partiallyResolvedPattern+": "+e.getMessage());
-// }
-// Message.debug("\tno revision found");
-// }
-// return null;
-// }
+ // public static ResolvedResource[] findAll(Repository rep, ModuleRevisionId mrid, String
+ // pattern, Artifact artifact, VersionMatcher versionMatcher, ResourceMDParser mdParser) {
+ // // substitute all but revision
+ // String partiallyResolvedPattern = IvyPatternHelper.substitute(pattern, new
+ // ModuleRevisionId(mrid.getModuleId(),
+ // IvyPatternHelper.getTokenString(IvyPatternHelper.REVISION_KEY), mrid.getExtraAttributes()),
+ // artifact);
+ // Message.debug("\tlisting all in "+partiallyResolvedPattern);
+ //
+ // String[] revs = listTokenValues(rep, partiallyResolvedPattern,
+ // IvyPatternHelper.REVISION_KEY);
+ // if (revs != null) {
+ // Message.debug("\tfound revs: "+Arrays.asList(revs));
+ // List ret = new ArrayList(revs.length);
+ // String rres = null;
+ // for (int i = 0; i < revs.length; i++) {
+ // ModuleRevisionId foundMrid = new ModuleRevisionId(mrid.getModuleId(), revs[i],
+ // mrid.getExtraAttributes());
+ // if (versionMatcher.accept(mrid, foundMrid)) {
+ // rres = IvyPatternHelper.substituteToken(partiallyResolvedPattern,
+ // IvyPatternHelper.REVISION_KEY, revs[i]);
+ // try {
+ // ResolvedResource resolvedResource;
+ // if (versionMatcher.needModuleDescriptor(mrid, foundMrid)) {
+ // resolvedResource = mdParser.parse(rep.getResource(rres), revs[i]);
+ // if (!versionMatcher.accept(mrid,
+ // ((MDResolvedResource)resolvedResource).getResolvedModuleRevision().getDescriptor())) {
+ // continue;
+ // }
+ // } else {
+ // resolvedResource = new ResolvedResource(rep.getResource(rres), revs[i]);
+ // }
+ // ret.add(resolvedResource);
+ // } catch (IOException e) {
+ // Message.warn("impossible to get resource from name listed by repository: "+rres+":
+ // "+e.getMessage());
+ // }
+ // }
+ // }
+ // if (revs.length != ret.size()) {
+ // Message.debug("\tfound resolved res: "+ret);
+ // }
+ // return (ResolvedResource[])ret.toArray(new ResolvedResource[ret.size()]);
+ // } else {
+ // // maybe the partially resolved pattern is completely resolved ?
+ // try {
+ // Resource res = rep.getResource(partiallyResolvedPattern);
+ // if (res.exists()) {
+ // Message.debug("\tonly one resource found without real listing: using and defining it as
+ // working@"+rep.getName()+" revision: "+res.getName());
+ // return new ResolvedResource[] {new ResolvedResource(res, "working@"+rep.getName())};
+ // }
+ // } catch (IOException e) {
+ // Message.debug("\timpossible to get resource from name listed by repository:
+ // "+partiallyResolvedPattern+": "+e.getMessage());
+ // }
+ // Message.debug("\tno revision found");
+ // }
+ // return null;
+ // }
// lists all the values a token can take in a pattern, as listed by a given url lister
public static String[] listTokenValues(URLLister lister, String pattern, String token) {
@@ -214,18 +237,21 @@
String tokenString = IvyPatternHelper.getTokenString(token);
int index = pattern.indexOf(tokenString);
if (index == -1) {
- Message.verbose("unable to list "+token+" in "+pattern+": token not found in pattern");
+ Message.verbose("unable to list " + token + " in " + pattern
+ + ": token not found in pattern");
return null;
}
- if (((pattern.length() <= index + tokenString.length())
- || "/".equals(pattern.substring(index + tokenString.length(), index + tokenString.length() + 1)))
+ if (((pattern.length() <= index + tokenString.length()) || "/".equals(pattern
+ .substring(index + tokenString.length(), index + tokenString.length() + 1)))
&& (index == 0 || "/".equals(pattern.substring(index - 1, index)))) {
// the searched token is a whole name
String root = pattern.substring(0, index);
try {
return listAll(lister, new URL(root));
} catch (MalformedURLException e) {
- Message.warn("malformed url from pattern root: "+root+": "+e.getMessage());
+ Message
+ .warn("malformed url from pattern root: " + root + ": "
+ + e.getMessage());
return null;
}
} else {
@@ -233,21 +259,23 @@
String root = slashIndex == -1 ? "" : pattern.substring(0, slashIndex);
try {
- Message.debug("\tusing "+lister+" to list all in "+root);
+ Message.debug("\tusing " + lister + " to list all in " + root);
List all = lister.listAll(new URL(root));
- Message.debug("\t\tfound "+all.size()+" urls");
+ Message.debug("\t\tfound " + all.size() + " urls");
List ret = new ArrayList(all.size());
int endNameIndex = pattern.indexOf('/', slashIndex + 1);
String namePattern;
if (endNameIndex != -1) {
- namePattern = pattern.substring(slashIndex+1, endNameIndex);
+ namePattern = pattern.substring(slashIndex + 1, endNameIndex);
} else {
namePattern = pattern.substring(slashIndex + 1);
}
- String acceptNamePattern = ".*"+IvyPatternHelper.substituteToken(namePattern, token, "([^/]+)")+".*";
+ String acceptNamePattern = ".*"
+ + IvyPatternHelper.substituteToken(namePattern, token, "([^/]+)")
+ + ".*";
Pattern p = Pattern.compile(acceptNamePattern.toString());
for (Iterator iter = all.iterator(); iter.hasNext();) {
- URL url = (URL)iter.next();
+ URL url = (URL) iter.next();
String path = standardize(url.getPath());
Matcher m = p.matcher(path);
if (m.matches()) {
@@ -255,17 +283,18 @@
ret.add(value);
}
}
- Message.debug("\t\t"+ret.size()+" matched "+pattern);
- return (String[])ret.toArray(new String[ret.size()]);
+ Message.debug("\t\t" + ret.size() + " matched " + pattern);
+ return (String[]) ret.toArray(new String[ret.size()]);
} catch (Exception e) {
- Message.warn("problem while listing files in "+root+": "+e.getClass()+" "+e.getMessage());
+ Message.warn("problem while listing files in " + root + ": " + e.getClass()
+ + " " + e.getMessage());
return null;
}
}
}
return null;
}
-
+
private static String standardize(String path) {
return path.replace('\\', '/');
}
@@ -273,25 +302,26 @@
public static String[] listAll(URLLister lister, URL root) {
try {
if (lister.accept(root.toExternalForm())) {
- Message.debug("\tusing "+lister+" to list all in "+root);
+ Message.debug("\tusing " + lister + " to list all in " + root);
List all = lister.listAll(root);
- Message.debug("\t\tfound "+all.size()+" urls");
+ Message.debug("\t\tfound " + all.size() + " urls");
List names = new ArrayList(all.size());
for (Iterator iter = all.iterator(); iter.hasNext();) {
- URL dir = (URL)iter.next();
+ URL dir = (URL) iter.next();
String path = dir.getPath();
if (path.endsWith("/")) {
path = path.substring(0, path.length() - 1);
}
int slashIndex = path.lastIndexOf('/');
- names.add(path.substring(slashIndex +1));
+ names.add(path.substring(slashIndex + 1));
}
- return (String[])names.toArray(new String[names.size()]);
+ return (String[]) names.toArray(new String[names.size()]);
}
return null;
} catch (Exception e) {
- Message.warn("problem while listing directories in "+root+": "+e.getClass()+" "+e.getMessage());
+ Message.warn("problem while listing directories in " + root + ": " + e.getClass() + " "
+ + e.getMessage());
return null;
- }
+ }
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/ResourceMDParser.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/ResourceMDParser.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/ResourceMDParser.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/ResourceMDParser.java Tue Jun 5 05:02:27 2007
@@ -20,5 +20,5 @@
import org.apache.ivy.plugins.repository.Resource;
public interface ResourceMDParser {
- MDResolvedResource parse(Resource resource, String rev);
+ MDResolvedResource parse(Resource resource, String rev);
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/URLLister.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/URLLister.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/URLLister.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/URLLister.java Tue Jun 5 05:02:27 2007
@@ -23,12 +23,13 @@
public interface URLLister {
/**
- * Indicates if this lister is able to list urls with the given pattern.
- * In general, only protocol is used.
+ * Indicates if this lister is able to list urls with the given pattern. In general, only
+ * protocol is used.
+ *
* @param pattern
* @return
*/
boolean accept(String pattern);
-
+
List listAll(URL url) throws IOException;
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/trigger/AbstractTrigger.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/trigger/AbstractTrigger.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/trigger/AbstractTrigger.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/trigger/AbstractTrigger.java Tue Jun 5 05:02:27 2007
@@ -25,62 +25,59 @@
import org.apache.ivy.util.filter.Filter;
/**
- * Base class for easy trigger implementation.
- *
- * This base class takes of the event filtering part, the only method to implement in subclasses
- * is {@link IvyListener#progress(IvyEvent)} which should do whatever the trigger needs to do when
- * the event occurs. This method will only be called when an event matching the trigger filter occurs.
- *
- *
+ * Base class for easy trigger implementation. This base class takes of the event filtering part,
+ * the only method to implement in subclasses is {@link IvyListener#progress(IvyEvent)} which should
+ * do whatever the trigger needs to do when the event occurs. This method will only be called when
+ * an event matching the trigger filter occurs.
*
* @since 1.4
- *
*/
public abstract class AbstractTrigger implements Trigger {
- private Filter _filter;
-
- private String _event;
- private String _filterExpression;
- private String _matcher = PatternMatcher.EXACT;
-
- public Filter getEventFilter() {
- if (_filter == null) {
- _filter = createFilter();
- }
- return _filter;
- }
-
- private Filter createFilter() {
- return new IvyEventFilter(getEvent(), getFilter(), getPatternMatcher());
- }
-
- private PatternMatcher getPatternMatcher() {
- return IvyContext.getContext().getSettings().getMatcher(_matcher);
- }
-
- public String getEvent() {
- return _event;
- }
-
- public void setEvent(String event) {
- _event = event;
- }
-
- public String getFilter() {
- return _filterExpression;
- }
-
- public void setFilter(String filterExpression) {
- _filterExpression = filterExpression;
- }
-
- public String getMatcher() {
- return _matcher;
- }
-
- public void setMatcher(String matcher) {
- _matcher = matcher;
- }
+ private Filter _filter;
+
+ private String _event;
+
+ private String _filterExpression;
+
+ private String _matcher = PatternMatcher.EXACT;
+
+ public Filter getEventFilter() {
+ if (_filter == null) {
+ _filter = createFilter();
+ }
+ return _filter;
+ }
+
+ private Filter createFilter() {
+ return new IvyEventFilter(getEvent(), getFilter(), getPatternMatcher());
+ }
+
+ private PatternMatcher getPatternMatcher() {
+ return IvyContext.getContext().getSettings().getMatcher(_matcher);
+ }
+
+ public String getEvent() {
+ return _event;
+ }
+
+ public void setEvent(String event) {
+ _event = event;
+ }
+
+ public String getFilter() {
+ return _filterExpression;
+ }
+
+ public void setFilter(String filterExpression) {
+ _filterExpression = filterExpression;
+ }
+
+ public String getMatcher() {
+ return _matcher;
+ }
+ public void setMatcher(String matcher) {
+ _matcher = matcher;
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/trigger/Trigger.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/trigger/Trigger.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/trigger/Trigger.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/trigger/Trigger.java Tue Jun 5 05:02:27 2007
@@ -21,5 +21,5 @@
import org.apache.ivy.util.filter.Filter;
public interface Trigger extends IvyListener {
- Filter getEventFilter();
+ Filter getEventFilter();
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/AbstractVersionMatcher.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/AbstractVersionMatcher.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/AbstractVersionMatcher.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/AbstractVersionMatcher.java Tue Jun 5 05:02:27 2007
@@ -26,24 +26,24 @@
import org.apache.ivy.util.Checks;
public abstract class AbstractVersionMatcher implements VersionMatcher, IvySettingsAware {
- private String _name;
- private IvySettings settings;
-
- public AbstractVersionMatcher() {
- }
-
- public AbstractVersionMatcher(String name) {
- _name = name;
- }
-
- public String getName() {
- return _name;
- }
-
- public void setName(String name) {
- _name = name;
- }
+ private String _name;
+ private IvySettings settings;
+
+ public AbstractVersionMatcher() {
+ }
+
+ public AbstractVersionMatcher(String name) {
+ _name = name;
+ }
+
+ public String getName() {
+ return _name;
+ }
+
+ public void setName(String name) {
+ _name = name;
+ }
public boolean needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) {
return false;
@@ -52,26 +52,27 @@
public boolean accept(ModuleRevisionId askedMrid, ModuleDescriptor foundMD) {
return accept(askedMrid, foundMD.getResolvedModuleRevisionId());
}
-
+
/**
- * This method should be overriden in most cases, because it uses the default contract
- * to return 1 when it's not possible to know which revision is greater.
+ * This method should be overriden in most cases, because it uses the default contract to return
+ * 1 when it's not possible to know which revision is greater.
*/
- public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid, Comparator staticComparator) {
- return 0;
+ public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid,
+ Comparator staticComparator) {
+ return 0;
}
-
+
public String toString() {
- return getName();
+ return getName();
}
- public IvySettings getSettings() {
- return settings;
- }
+ public IvySettings getSettings() {
+ return settings;
+ }
- public void setSettings(IvySettings settings) {
- Checks.checkNotNull(settings, "settings");
- this.settings = settings;
- }
+ public void setSettings(IvySettings settings) {
+ Checks.checkNotNull(settings, "settings");
+ this.settings = settings;
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/ChainVersionMatcher.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/ChainVersionMatcher.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/ChainVersionMatcher.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/ChainVersionMatcher.java Tue Jun 5 05:02:27 2007
@@ -30,73 +30,71 @@
import org.apache.ivy.util.Checks;
/**
- * An implementation of {@link VersionMatcher} chaining several
- * version matchers, and implemeting the {@link VersionMatcher}
- * interface by returning results from the first matcher in the chain
- * accepting the version.
+ * An implementation of {@link VersionMatcher} chaining several version matchers, and implemeting
+ * the {@link VersionMatcher} interface by returning results from the first matcher in the chain
+ * accepting the version.
*/
public class ChainVersionMatcher extends AbstractVersionMatcher {
- /**
- * The list of version matchers in the chain.
- * This list will be queried in order, so the last matcher
- * will be used only if no other matcher accept the revision
- * before.
- */
- private List/*<VersionMatcher>*/ matchers = new LinkedList();
-
+ /**
+ * The list of version matchers in the chain. This list will be queried in order, so the last
+ * matcher will be used only if no other matcher accept the revision before.
+ */
+ private List/* <VersionMatcher> */matchers = new LinkedList();
+
/**
* Unique Constructor.
*/
public ChainVersionMatcher() {
- super("chain");
+ super("chain");
}
/**
* Adds a {@link VersionMatcher} to the chain.
*
- * @param matcher the version matcher to add. Must not be null
+ * @param matcher
+ * the version matcher to add. Must not be null
*/
public void add(VersionMatcher matcher) {
- Checks.checkNotNull(matcher, "matcher");
+ Checks.checkNotNull(matcher, "matcher");
matchers.add(0, matcher);
- if (getSettings() != null && matcher instanceof IvySettingsAware) {
- ((IvySettingsAware) matcher).setSettings(getSettings());
- }
+ if (getSettings() != null && matcher instanceof IvySettingsAware) {
+ ((IvySettingsAware) matcher).setSettings(getSettings());
+ }
}
-
+
/**
- * Sets the settings this matcher will use, and set to the matcher in the chain
- * which implements {@link IvySettingsAware}.
+ * Sets the settings this matcher will use, and set to the matcher in the chain which implements
+ * {@link IvySettingsAware}.
*
- * @param settings the settings to use in the whole chain. Must not be null.
+ * @param settings
+ * the settings to use in the whole chain. Must not be null.
*/
public void setSettings(IvySettings settings) {
- super.setSettings(settings);
- for (Iterator iter = matchers.iterator(); iter.hasNext();) {
- VersionMatcher matcher = (VersionMatcher) iter.next();
- if (matcher instanceof IvySettingsAware) {
- ((IvySettingsAware) matcher).setSettings(settings);
- }
- }
+ super.setSettings(settings);
+ for (Iterator iter = matchers.iterator(); iter.hasNext();) {
+ VersionMatcher matcher = (VersionMatcher) iter.next();
+ if (matcher instanceof IvySettingsAware) {
+ ((IvySettingsAware) matcher).setSettings(settings);
+ }
+ }
}
-
+
/**
* Returns the list of matchers in the chain.
* <p>
- * The list is returned as an unmodifiable view on the actual list of matchers,
- * and will thus reflect futher changes made in the chain.
+ * The list is returned as an unmodifiable view on the actual list of matchers, and will thus
+ * reflect futher changes made in the chain.
*
* @return the list of matchers in the chain. Is never null.
*/
public List getMatchers() {
- return Collections.unmodifiableList(matchers);
+ return Collections.unmodifiableList(matchers);
}
-
public boolean isDynamic(ModuleRevisionId askedMrid) {
- Checks.checkNotNull(askedMrid, "askedMrid");
+ Checks.checkNotNull(askedMrid, "askedMrid");
for (Iterator iter = matchers.iterator(); iter.hasNext();) {
- VersionMatcher matcher = (VersionMatcher)iter.next();
+ VersionMatcher matcher = (VersionMatcher) iter.next();
if (matcher.isDynamic(askedMrid)) {
return true;
}
@@ -104,24 +102,26 @@
return false;
}
- public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid, Comparator staticComparator) {
- Checks.checkNotNull(askedMrid, "askedMrid");
- Checks.checkNotNull(foundMrid, "foundMrid");
- Checks.checkNotNull(staticComparator, "staticComparator");
- for (Iterator iter = matchers.iterator(); iter.hasNext();) {
- VersionMatcher matcher = (VersionMatcher)iter.next();
- if (matcher.isDynamic(askedMrid)) {
- return matcher.compare(askedMrid, foundMrid, staticComparator);
- }
- }
- throw new IllegalArgumentException("impossible to compare revisions: askedMrid is not dynamic: "+askedMrid);
+ public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid,
+ Comparator staticComparator) {
+ Checks.checkNotNull(askedMrid, "askedMrid");
+ Checks.checkNotNull(foundMrid, "foundMrid");
+ Checks.checkNotNull(staticComparator, "staticComparator");
+ for (Iterator iter = matchers.iterator(); iter.hasNext();) {
+ VersionMatcher matcher = (VersionMatcher) iter.next();
+ if (matcher.isDynamic(askedMrid)) {
+ return matcher.compare(askedMrid, foundMrid, staticComparator);
+ }
+ }
+ throw new IllegalArgumentException(
+ "impossible to compare revisions: askedMrid is not dynamic: " + askedMrid);
}
public boolean accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) {
- Checks.checkNotNull(askedMrid, "askedMrid");
- Checks.checkNotNull(foundMrid, "foundMrid");
+ Checks.checkNotNull(askedMrid, "askedMrid");
+ Checks.checkNotNull(foundMrid, "foundMrid");
for (Iterator iter = matchers.iterator(); iter.hasNext();) {
- VersionMatcher matcher = (VersionMatcher)iter.next();
+ VersionMatcher matcher = (VersionMatcher) iter.next();
if (!iter.hasNext() || matcher.isDynamic(askedMrid)) {
return matcher.accept(askedMrid, foundMrid);
}
@@ -130,10 +130,10 @@
}
public boolean needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) {
- Checks.checkNotNull(askedMrid, "askedMrid");
- Checks.checkNotNull(foundMrid, "foundMrid");
+ Checks.checkNotNull(askedMrid, "askedMrid");
+ Checks.checkNotNull(foundMrid, "foundMrid");
for (Iterator iter = matchers.iterator(); iter.hasNext();) {
- VersionMatcher matcher = (VersionMatcher)iter.next();
+ VersionMatcher matcher = (VersionMatcher) iter.next();
if (!iter.hasNext() || matcher.isDynamic(askedMrid)) {
return matcher.needModuleDescriptor(askedMrid, foundMrid);
}
@@ -142,10 +142,10 @@
}
public boolean accept(ModuleRevisionId askedMrid, ModuleDescriptor foundMD) {
- Checks.checkNotNull(askedMrid, "askedMrid");
- Checks.checkNotNull(foundMD, "foundMD");
+ Checks.checkNotNull(askedMrid, "askedMrid");
+ Checks.checkNotNull(foundMD, "foundMD");
for (Iterator iter = matchers.iterator(); iter.hasNext();) {
- VersionMatcher matcher = (VersionMatcher)iter.next();
+ VersionMatcher matcher = (VersionMatcher) iter.next();
if (!iter.hasNext() || matcher.isDynamic(askedMrid)) {
return matcher.accept(askedMrid, foundMD);
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/ExactVersionMatcher.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/ExactVersionMatcher.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/ExactVersionMatcher.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/ExactVersionMatcher.java Tue Jun 5 05:02:27 2007
@@ -21,10 +21,10 @@
public class ExactVersionMatcher extends AbstractVersionMatcher {
- public ExactVersionMatcher() {
- super("exact");
- }
-
+ public ExactVersionMatcher() {
+ super("exact");
+ }
+
public boolean isDynamic(ModuleRevisionId askedMrid) {
return false;
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/LatestVersionMatcher.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/LatestVersionMatcher.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/LatestVersionMatcher.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/LatestVersionMatcher.java Tue Jun 5 05:02:27 2007
@@ -23,11 +23,11 @@
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.module.status.StatusManager;
-public class LatestVersionMatcher extends AbstractVersionMatcher {
- public LatestVersionMatcher() {
- super("latest");
- }
-
+public class LatestVersionMatcher extends AbstractVersionMatcher {
+ public LatestVersionMatcher() {
+ super("latest");
+ }
+
public boolean isDynamic(ModuleRevisionId askedMrid) {
return askedMrid.getRevision().startsWith("latest.");
}
@@ -42,15 +42,16 @@
public boolean accept(ModuleRevisionId askedMrid, ModuleDescriptor foundMD) {
String askedStatus = askedMrid.getRevision().substring("latest.".length());
- return StatusManager.getCurrent().getPriority(askedStatus) >= StatusManager.getCurrent().getPriority(foundMD.getStatus());
+ return StatusManager.getCurrent().getPriority(askedStatus) >= StatusManager.getCurrent()
+ .getPriority(foundMD.getStatus());
}
-
+
/**
- * If we don't need a module descriptor we can consider the dynamic revision
- * to be greater. If we need a module descriptor then we can't know which one
- * is greater and return 0.
+ * If we don't need a module descriptor we can consider the dynamic revision to be greater. If
+ * we need a module descriptor then we can't know which one is greater and return 0.
*/
- public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid, Comparator staticComparator) {
- return needModuleDescriptor(askedMrid, foundMrid)?0:1;
+ public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid,
+ Comparator staticComparator) {
+ return needModuleDescriptor(askedMrid, foundMrid) ? 0 : 1;
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/Match.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/Match.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/Match.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/Match.java Tue Jun 5 05:02:27 2007
@@ -29,106 +29,108 @@
import org.apache.ivy.plugins.matcher.Matcher;
import org.apache.ivy.plugins.matcher.PatternMatcher;
-
-
/**
*
*/
public class Match {
- private String _revision;
- private String _pattern;
- private String _args;
- private String _matcher;
-
- public String getArgs() {
- return _args;
- }
-
- public void setArgs(String args) {
- this._args = args;
- }
-
- public String getMatcher() {
- return _matcher;
- }
-
- public void setMatcher(String matcher) {
- this._matcher = matcher;
- }
-
- public String getPattern() {
- return _pattern;
- }
-
- public void setPattern(String pattern) {
- this._pattern = pattern;
- }
-
- public String getRevision() {
- return _revision;
- }
-
- public void setRevision(String revision) {
- this._revision = revision;
- }
-
- public Matcher getPatternMatcher(ModuleRevisionId askedMrid) {
- String revision = askedMrid.getRevision();
-
- String[] args = split(getArgs());
- String[] argValues = getRevisionArgs(revision);
-
- if (args.length != argValues.length) {
- return new NoMatchMatcher();
- }
-
- Map variables = new HashMap();
- for (int i = 0; i < args.length; i++) {
- variables.put(args[i], argValues[i]);
- }
-
- String pattern = getPattern();
- pattern = IvyPatternHelper.substituteVariables(pattern, variables);
-
- PatternMatcher pMatcher = IvyContext.getContext().getSettings().getMatcher(_matcher);
- return pMatcher.getMatcher(pattern);
- }
-
- private String[] getRevisionArgs(String revision) {
- int bracketStartIndex = revision.indexOf('(');
- if (bracketStartIndex == -1) {
- return new String[0];
- }
-
- int bracketEndIndex = revision.indexOf(')');
- if (bracketEndIndex <= (bracketStartIndex + 1)) {
- return new String[0];
- }
-
- String args = revision.substring(bracketStartIndex + 1, bracketEndIndex);
- return split(args);
- }
-
- private static String[] split(String string) {
- if (string == null) {
- return new String[0];
- }
-
- StringTokenizer tokenizer = new StringTokenizer(string, ", ");
- List tokens = new ArrayList();
- while (tokenizer.hasMoreTokens()) {
- tokens.add(tokenizer.nextToken());
- }
-
- return (String[]) tokens.toArray(new String[tokens.size()]);
- }
-
- private static class NoMatchMatcher implements Matcher {
- public boolean isExact() {
- return false;
- }
- public boolean matches(String str) {
- return false;
- }
- }
+ private String _revision;
+
+ private String _pattern;
+
+ private String _args;
+
+ private String _matcher;
+
+ public String getArgs() {
+ return _args;
+ }
+
+ public void setArgs(String args) {
+ this._args = args;
+ }
+
+ public String getMatcher() {
+ return _matcher;
+ }
+
+ public void setMatcher(String matcher) {
+ this._matcher = matcher;
+ }
+
+ public String getPattern() {
+ return _pattern;
+ }
+
+ public void setPattern(String pattern) {
+ this._pattern = pattern;
+ }
+
+ public String getRevision() {
+ return _revision;
+ }
+
+ public void setRevision(String revision) {
+ this._revision = revision;
+ }
+
+ public Matcher getPatternMatcher(ModuleRevisionId askedMrid) {
+ String revision = askedMrid.getRevision();
+
+ String[] args = split(getArgs());
+ String[] argValues = getRevisionArgs(revision);
+
+ if (args.length != argValues.length) {
+ return new NoMatchMatcher();
+ }
+
+ Map variables = new HashMap();
+ for (int i = 0; i < args.length; i++) {
+ variables.put(args[i], argValues[i]);
+ }
+
+ String pattern = getPattern();
+ pattern = IvyPatternHelper.substituteVariables(pattern, variables);
+
+ PatternMatcher pMatcher = IvyContext.getContext().getSettings().getMatcher(_matcher);
+ return pMatcher.getMatcher(pattern);
+ }
+
+ private String[] getRevisionArgs(String revision) {
+ int bracketStartIndex = revision.indexOf('(');
+ if (bracketStartIndex == -1) {
+ return new String[0];
+ }
+
+ int bracketEndIndex = revision.indexOf(')');
+ if (bracketEndIndex <= (bracketStartIndex + 1)) {
+ return new String[0];
+ }
+
+ String args = revision.substring(bracketStartIndex + 1, bracketEndIndex);
+ return split(args);
+ }
+
+ private static String[] split(String string) {
+ if (string == null) {
+ return new String[0];
+ }
+
+ StringTokenizer tokenizer = new StringTokenizer(string, ", ");
+ List tokens = new ArrayList();
+ while (tokenizer.hasMoreTokens()) {
+ tokens.add(tokenizer.nextToken());
+ }
+
+ return (String[]) tokens.toArray(new String[tokens.size()]);
+ }
+
+ private static class NoMatchMatcher implements Matcher {
+ public boolean isExact() {
+ return false;
+ }
+
+ public boolean matches(String str) {
+ return false;
+ }
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/PatternVersionMatcher.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/PatternVersionMatcher.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/PatternVersionMatcher.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/PatternVersionMatcher.java Tue Jun 5 05:02:27 2007
@@ -26,73 +26,74 @@
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.plugins.matcher.Matcher;
-
/**
*
*/
public class PatternVersionMatcher extends AbstractVersionMatcher {
- private List _matches = new ArrayList();
- private Map _revisionMatches = new HashMap(); // revision -> list of Match instances
- private boolean _init = false;
-
- public void addMatch(Match match) {
- _matches.add(match);
- }
-
- private void init() {
- if (!_init) {
- for (Iterator it = _matches.iterator(); it.hasNext(); ) {
- Match match = (Match) it.next();
- List matches = (List) _revisionMatches.get(match.getRevision());
- if (matches == null) {
- matches = new ArrayList();
- _revisionMatches.put(match.getRevision(), matches);
- }
- matches.add(match);
- }
- _init = true;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) {
- init();
- boolean accept = false;
-
- String revision = askedMrid.getRevision();
- int bracketIndex = revision.indexOf('(');
- if (bracketIndex > 0) {
- revision = revision.substring(0, bracketIndex);
- }
-
- List matches = (List) _revisionMatches.get(revision);
-
- if (matches != null) {
- Iterator it = matches.iterator();
- while (!accept && it.hasNext()) {
- Match match = (Match) it.next();
- Matcher matcher = match.getPatternMatcher(askedMrid);
- accept = matcher.matches(foundMrid.getRevision());
- }
- }
-
- return accept;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isDynamic(ModuleRevisionId askedMrid) {
- init();
- String revision = askedMrid.getRevision();
- int bracketIndex = revision.indexOf('(');
- if (bracketIndex > 0) {
- revision = revision.substring(0, bracketIndex);
- }
- return _revisionMatches.containsKey(revision);
- }
+ private List _matches = new ArrayList();
+
+ private Map _revisionMatches = new HashMap(); // revision -> list of Match instances
+
+ private boolean _init = false;
+
+ public void addMatch(Match match) {
+ _matches.add(match);
+ }
+
+ private void init() {
+ if (!_init) {
+ for (Iterator it = _matches.iterator(); it.hasNext();) {
+ Match match = (Match) it.next();
+ List matches = (List) _revisionMatches.get(match.getRevision());
+ if (matches == null) {
+ matches = new ArrayList();
+ _revisionMatches.put(match.getRevision(), matches);
+ }
+ matches.add(match);
+ }
+ _init = true;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) {
+ init();
+ boolean accept = false;
+
+ String revision = askedMrid.getRevision();
+ int bracketIndex = revision.indexOf('(');
+ if (bracketIndex > 0) {
+ revision = revision.substring(0, bracketIndex);
+ }
+
+ List matches = (List) _revisionMatches.get(revision);
+
+ if (matches != null) {
+ Iterator it = matches.iterator();
+ while (!accept && it.hasNext()) {
+ Match match = (Match) it.next();
+ Matcher matcher = match.getPatternMatcher(askedMrid);
+ accept = matcher.matches(foundMrid.getRevision());
+ }
+ }
+
+ return accept;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isDynamic(ModuleRevisionId askedMrid) {
+ init();
+ String revision = askedMrid.getRevision();
+ int bracketIndex = revision.indexOf('(');
+ if (bracketIndex > 0) {
+ revision = revision.substring(0, bracketIndex);
+ }
+ return _revisionMatches.containsKey(revision);
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/SubVersionMatcher.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/SubVersionMatcher.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/SubVersionMatcher.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/SubVersionMatcher.java Tue Jun 5 05:02:27 2007
@@ -21,10 +21,10 @@
import org.apache.ivy.core.module.id.ModuleRevisionId;
-public class SubVersionMatcher extends AbstractVersionMatcher {
- public SubVersionMatcher() {
- super("sub-version");
- }
+public class SubVersionMatcher extends AbstractVersionMatcher {
+ public SubVersionMatcher() {
+ super("sub-version");
+ }
public boolean isDynamic(ModuleRevisionId askedMrid) {
return askedMrid.getRevision().endsWith("+");
@@ -34,11 +34,13 @@
String prefix = askedMrid.getRevision().substring(0, askedMrid.getRevision().length() - 1);
return foundMrid.getRevision().startsWith(prefix);
}
-
- public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid, Comparator staticComparator) {
- if (foundMrid.getRevision().startsWith(askedMrid.getRevision().substring(0, askedMrid.getRevision().length() - 1))) {
- return 1;
- }
- return staticComparator.compare(askedMrid, foundMrid);
+
+ public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid,
+ Comparator staticComparator) {
+ if (foundMrid.getRevision().startsWith(
+ askedMrid.getRevision().substring(0, askedMrid.getRevision().length() - 1))) {
+ return 1;
+ }
+ return staticComparator.compare(askedMrid, foundMrid);
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/VersionMatcher.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/VersionMatcher.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/VersionMatcher.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/VersionMatcher.java Tue Jun 5 05:02:27 2007
@@ -23,75 +23,81 @@
import org.apache.ivy.core.module.id.ModuleRevisionId;
/**
- * This interface defines a version matcher, i.e. a class able to tell if the revision
- * asked by a module for a dependency is dynamic (i.e. need to find all revisions to find the good one among them)
- * and if a found revision matches the asked one.
- *
- * Two ways of matching are possible:
- * - based on the module revision only (known as ModuleRevisionId)
- * - based on the parsed module descriptor
- *
- * The second being much more time consuming than the first, the version matcher should tell if it needs such parsing
- * or not using the needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) method. Anyway, the first way is always used, and if a revision is not accepted using the first
- * method, the module descriptor won't be parsed.
- *
- * Therefore if a version matcher uses only module descriptors to accept a revision or not it should always return true
- * to needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) and accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid).
- *
+ * This interface defines a version matcher, i.e. a class able to tell if the revision asked by a
+ * module for a dependency is dynamic (i.e. need to find all revisions to find the good one among
+ * them) and if a found revision matches the asked one. Two ways of matching are possible: - based
+ * on the module revision only (known as ModuleRevisionId) - based on the parsed module descriptor
+ * The second being much more time consuming than the first, the version matcher should tell if it
+ * needs such parsing or not using the needModuleDescriptor(ModuleRevisionId askedMrid,
+ * ModuleRevisionId foundMrid) method. Anyway, the first way is always used, and if a revision is
+ * not accepted using the first method, the module descriptor won't be parsed. Therefore if a
+ * version matcher uses only module descriptors to accept a revision or not it should always return
+ * true to needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) and
+ * accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid).
*/
public interface VersionMatcher {
/**
- * Indicates if the given asked ModuleRevisionId should be considered as dynamic for
- * the current VersionMatcher or not.
- * @param askedMrid the dependency module revision id as asked by a module
+ * Indicates if the given asked ModuleRevisionId should be considered as dynamic for the current
+ * VersionMatcher or not.
+ *
+ * @param askedMrid
+ * the dependency module revision id as asked by a module
* @return true if this revision is considered as a dynamic one, false otherwise
*/
public boolean isDynamic(ModuleRevisionId askedMrid);
+
/**
- * Indicates if this version matcher considers that the module revision found matches the asked one.
+ * Indicates if this version matcher considers that the module revision found matches the asked
+ * one.
+ *
* @param askedMrid
* @param foundMrid
* @return
*/
public boolean accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid);
+
/**
- * Indicates if this VersionMatcher needs module descriptors to determine if a module revision
- * matches the asked one.
- * Note that returning true in this method may imply big performance issues.
+ * Indicates if this VersionMatcher needs module descriptors to determine if a module revision
+ * matches the asked one. Note that returning true in this method may imply big performance
+ * issues.
+ *
* @return
*/
public boolean needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid);
+
/**
- * Indicates if this version matcher considers that the module found matches the asked one.
- * This method can be called even needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid)
- * returns false, so it is required to implement it in any case, a usual default implementation being:
- *
- * return accept(askedMrid, foundMD.getResolvedModuleRevisionId());
+ * Indicates if this version matcher considers that the module found matches the asked one. This
+ * method can be called even needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId
+ * foundMrid) returns false, so it is required to implement it in any case, a usual default
+ * implementation being: return accept(askedMrid, foundMD.getResolvedModuleRevisionId());
*
* @param askedMrid
* @param foundMD
* @return
*/
public boolean accept(ModuleRevisionId askedMrid, ModuleDescriptor foundMD);
-
+
/**
- * Compares a dynamic revision (askedMrid) with a static one (foundMrid)
- * to indicate which one should be considered the greater.
- * If there is not enough information to know which one is the greater,
- * the dynamic one should be considered greater and this method should return 0.
- *
- * This method should never be called with a askdeMrid for which isDynamic
- * returns false.
- *
- * @param askedMrid the dynamic revision to compare
- * @param foundMrid the static revision to compare
- * @param staticComparator a comparator which can be used to compare static revisions
- * @return 0 if it's not possible to know which one is greater, greater than 0 if askedMrid should be considered greater, lower than 0 if it can't be consider greater
+ * Compares a dynamic revision (askedMrid) with a static one (foundMrid) to indicate which one
+ * should be considered the greater. If there is not enough information to know which one is the
+ * greater, the dynamic one should be considered greater and this method should return 0. This
+ * method should never be called with a askdeMrid for which isDynamic returns false.
+ *
+ * @param askedMrid
+ * the dynamic revision to compare
+ * @param foundMrid
+ * the static revision to compare
+ * @param staticComparator
+ * a comparator which can be used to compare static revisions
+ * @return 0 if it's not possible to know which one is greater, greater than 0 if askedMrid
+ * should be considered greater, lower than 0 if it can't be consider greater
*/
- public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid, Comparator staticComparator);
+ public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid,
+ Comparator staticComparator);
/**
* Returns the version matcher name identifying this version matcher
+ *
* @return the version matcher name identifying this version matcher
*/
public String getName();
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/VersionRangeMatcher.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/VersionRangeMatcher.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/VersionRangeMatcher.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/version/VersionRangeMatcher.java Tue Jun 5 05:02:27 2007
@@ -25,190 +25,216 @@
import org.apache.ivy.plugins.latest.ArtifactInfo;
import org.apache.ivy.plugins.latest.LatestStrategy;
-
/**
- * Matches version ranges:
- * [1.0,2.0] matches all versions greater or equal to 1.0 and lower or equal to 2.0
- * [1.0,2.0[ matches all versions greater or equal to 1.0 and lower than 2.0
- * ]1.0,2.0] matches all versions greater than 1.0 and lower or equal to 2.0
- * ]1.0,2.0[ matches all versions greater than 1.0 and lower than 2.0
- * [1.0,) matches all versions greater or equal to 1.0
- * ]1.0,) matches all versions greater than 1.0
- * (,2.0] matches all versions lower or equal to 2.0
- * (,2.0[ matches all versions lower than 2.0
- *
- * This class uses a latest strategy to compare revisions.
- * If none is set, it uses the default one of the ivy instance set through setIvy().
- * If neither a latest strategy nor a ivy instance is set, an IllegalStateException
- * will be thrown when calling accept().
- *
- * Note that it can't work with latest time strategy, cause no time is known for the limits of the range.
- * Therefore only purely revision based LatestStrategy can be used.
- *
- *
+ * Matches version ranges: [1.0,2.0] matches all versions greater or equal to 1.0 and lower or equal
+ * to 2.0 [1.0,2.0[ matches all versions greater or equal to 1.0 and lower than 2.0 ]1.0,2.0]
+ * matches all versions greater than 1.0 and lower or equal to 2.0 ]1.0,2.0[ matches all versions
+ * greater than 1.0 and lower than 2.0 [1.0,) matches all versions greater or equal to 1.0 ]1.0,)
+ * matches all versions greater than 1.0 (,2.0] matches all versions lower or equal to 2.0 (,2.0[
+ * matches all versions lower than 2.0 This class uses a latest strategy to compare revisions. If
+ * none is set, it uses the default one of the ivy instance set through setIvy(). If neither a
+ * latest strategy nor a ivy instance is set, an IllegalStateException will be thrown when calling
+ * accept(). Note that it can't work with latest time strategy, cause no time is known for the
+ * limits of the range. Therefore only purely revision based LatestStrategy can be used.
*/
-public class VersionRangeMatcher extends AbstractVersionMatcher {
- // todo: check these constants
- private final static String OPEN_INC = "[";
- private final static String OPEN_EXC = "]";
- private final static String CLOSE_INC = "]";
- private final static String CLOSE_EXC = "[";
- private final static String LOWER_INFINITE = "(";
- private final static String UPPER_INFINITE = ")";
- private final static String SEPARATOR = ",";
-
- // following patterns are built upon constants above and should not be modified
- private final static String OPEN_INC_PATTERN = "\\"+OPEN_INC;
- private final static String OPEN_EXC_PATTERN = "\\"+OPEN_EXC;
- private final static String CLOSE_INC_PATTERN = "\\"+CLOSE_INC;
- private final static String CLOSE_EXC_PATTERN = "\\"+CLOSE_EXC;
- private final static String LI_PATTERN = "\\"+LOWER_INFINITE;
- private final static String UI_PATTERN = "\\"+UPPER_INFINITE;
- private final static String SEP_PATTERN = "\\"+SEPARATOR;
-
- private final static String OPEN_PATTERN = "["+OPEN_INC_PATTERN+OPEN_EXC_PATTERN+"]";
- private final static String CLOSE_PATTERN = "["+CLOSE_INC_PATTERN+CLOSE_EXC_PATTERN+"]";
- private final static String ANY_NON_SPECIAL_PATTERN = "[^"+SEP_PATTERN+OPEN_INC_PATTERN+OPEN_EXC_PATTERN+CLOSE_INC_PATTERN+CLOSE_EXC_PATTERN+LI_PATTERN+UI_PATTERN+"]";
-
- private final static String FINITE_PATTERN = OPEN_PATTERN+"("+ANY_NON_SPECIAL_PATTERN+"+)"+SEP_PATTERN+"("+ANY_NON_SPECIAL_PATTERN+"+)"+CLOSE_PATTERN;
- private final static String LOWER_INFINITE_PATTERN = LI_PATTERN+"\\,("+ANY_NON_SPECIAL_PATTERN+"+)"+CLOSE_PATTERN;
- private final static String UPPER_INFINITE_PATTERN = OPEN_PATTERN+"("+ANY_NON_SPECIAL_PATTERN+"+)\\,"+UI_PATTERN;
-
- private final static Pattern FINITE_RANGE = Pattern.compile(FINITE_PATTERN);
- private final static Pattern LOWER_INFINITE_RANGE = Pattern.compile(LOWER_INFINITE_PATTERN);
- private final static Pattern UPPER_INFINITE_RANGE = Pattern.compile(UPPER_INFINITE_PATTERN);
- private final static Pattern ALL_RANGE = Pattern.compile(FINITE_PATTERN+"|"+LOWER_INFINITE_PATTERN+"|"+UPPER_INFINITE_PATTERN);
-
- private final class MRIDArtifactInfo implements ArtifactInfo {
- private ModuleRevisionId _mrid;
-
- public MRIDArtifactInfo(ModuleRevisionId id) {
- _mrid = id;
- }
-
- public long getLastModified() {
- return 0;
- }
-
- public String getRevision() {
- return _mrid.getRevision();
- }
- }
-
- private final Comparator COMPARATOR = new Comparator() {
- public int compare(Object o1, Object o2) {
- if (o1.equals(o2)) {
- return 0;
- }
- ArtifactInfo art1 = new MRIDArtifactInfo((ModuleRevisionId)o1);
- ArtifactInfo art2 = new MRIDArtifactInfo((ModuleRevisionId)o2);
- ArtifactInfo art = getLatestStrategy().findLatest(new ArtifactInfo[] {art1,art2}, null);
- return art == art1 ? -1 : 1;
- }
- };
-
-
- private LatestStrategy _latestStrategy;
-
- private String _latestStrategyName = "default";
-
- public VersionRangeMatcher() {
- super("version-range");
- }
-
- public VersionRangeMatcher(String name) {
- super(name);
- }
-
- public VersionRangeMatcher(String name, LatestStrategy strategy) {
- super(name);
- _latestStrategy = strategy;
- }
-
- public boolean isDynamic(ModuleRevisionId askedMrid) {
- String revision = askedMrid.getRevision();
- return ALL_RANGE.matcher(revision).matches();
- }
-
- public boolean accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) {
- String revision = askedMrid.getRevision();
- Matcher m;
- m = FINITE_RANGE.matcher(revision);
- if (m.matches()) {
- String lower = m.group(1);
- String upper = m.group(2);
- return isUpper(askedMrid, lower, foundMrid, revision.startsWith(OPEN_INC))
- && isLower(askedMrid, upper, foundMrid, revision.endsWith(CLOSE_INC));
- }
- m = LOWER_INFINITE_RANGE.matcher(revision);
- if (m.matches()) {
- String upper = m.group(1);
- return isLower(askedMrid, upper, foundMrid, revision.endsWith(CLOSE_INC));
- }
- m = UPPER_INFINITE_RANGE.matcher(revision);
- if (m.matches()) {
- String lower = m.group(1);
- return isUpper(askedMrid, lower, foundMrid, revision.startsWith(OPEN_INC));
- }
- return false;
- }
-
- private boolean isLower(ModuleRevisionId askedMrid, String revision, ModuleRevisionId foundMrid, boolean inclusive) {
- return COMPARATOR.compare(ModuleRevisionId.newInstance(askedMrid, revision), foundMrid) <= (inclusive ? 0 : -1);
- }
-
- private boolean isUpper(ModuleRevisionId askedMrid, String revision, ModuleRevisionId foundMrid, boolean inclusive) {
- return COMPARATOR.compare(ModuleRevisionId.newInstance(askedMrid, revision), foundMrid) >= (inclusive ? 0 : 1);
- }
-
- public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid, Comparator staticComparator) {
- String revision = askedMrid.getRevision();
- Matcher m;
- m = UPPER_INFINITE_RANGE.matcher(revision);
- if (m.matches()) {
- // no upper limit, the dynamic revision can always be considered greater
- return 1;
- }
- String upper;
- m = FINITE_RANGE.matcher(revision);
- if (m.matches()) {
- upper = m.group(2);
- } else {
- m = LOWER_INFINITE_RANGE.matcher(revision);
- if (m.matches()) {
- upper = m.group(1);
- } else {
- throw new IllegalArgumentException("impossible to compare: askedMrid is not a dynamic revision: "+askedMrid);
- }
- }
- int c = staticComparator.compare(ModuleRevisionId.newInstance(askedMrid, upper), foundMrid);
- // if the comparison consider them equal, we must return -1, because we can't consider the
- // dynamic revision to be greater. Otherwise we can safeely return the result of the static comparison
- return c == 0?-1:c;
- }
-
- public LatestStrategy getLatestStrategy() {
- if (_latestStrategy == null) {
- if (getSettings() == null) {
- throw new IllegalStateException("no ivy instance nor latest strategy configured in version range matcher "+this);
- }
- if (_latestStrategyName == null) {
- throw new IllegalStateException("null latest strategy defined in version range matcher "+this);
- }
- _latestStrategy = getSettings().getLatestStrategy(_latestStrategyName);
- if (_latestStrategy == null) {
- throw new IllegalStateException("unknown latest strategy '"+_latestStrategyName+"' configured in version range matcher "+this);
- }
- }
- return _latestStrategy;
- }
-
- public void setLatestStrategy(LatestStrategy latestStrategy) {
- _latestStrategy = latestStrategy;
- }
-
- public void setLatest(String latestStrategyName) {
- _latestStrategyName = latestStrategyName;
- }
+public class VersionRangeMatcher extends AbstractVersionMatcher {
+ // todo: check these constants
+ private final static String OPEN_INC = "[";
+
+ private final static String OPEN_EXC = "]";
+
+ private final static String CLOSE_INC = "]";
+
+ private final static String CLOSE_EXC = "[";
+
+ private final static String LOWER_INFINITE = "(";
+
+ private final static String UPPER_INFINITE = ")";
+
+ private final static String SEPARATOR = ",";
+
+ // following patterns are built upon constants above and should not be modified
+ private final static String OPEN_INC_PATTERN = "\\" + OPEN_INC;
+
+ private final static String OPEN_EXC_PATTERN = "\\" + OPEN_EXC;
+
+ private final static String CLOSE_INC_PATTERN = "\\" + CLOSE_INC;
+
+ private final static String CLOSE_EXC_PATTERN = "\\" + CLOSE_EXC;
+
+ private final static String LI_PATTERN = "\\" + LOWER_INFINITE;
+
+ private final static String UI_PATTERN = "\\" + UPPER_INFINITE;
+
+ private final static String SEP_PATTERN = "\\" + SEPARATOR;
+
+ private final static String OPEN_PATTERN = "[" + OPEN_INC_PATTERN + OPEN_EXC_PATTERN + "]";
+
+ private final static String CLOSE_PATTERN = "[" + CLOSE_INC_PATTERN + CLOSE_EXC_PATTERN + "]";
+
+ private final static String ANY_NON_SPECIAL_PATTERN = "[^" + SEP_PATTERN + OPEN_INC_PATTERN
+ + OPEN_EXC_PATTERN + CLOSE_INC_PATTERN + CLOSE_EXC_PATTERN + LI_PATTERN + UI_PATTERN
+ + "]";
+
+ private final static String FINITE_PATTERN = OPEN_PATTERN + "(" + ANY_NON_SPECIAL_PATTERN
+ + "+)" + SEP_PATTERN + "(" + ANY_NON_SPECIAL_PATTERN + "+)" + CLOSE_PATTERN;
+
+ private final static String LOWER_INFINITE_PATTERN = LI_PATTERN + "\\,("
+ + ANY_NON_SPECIAL_PATTERN + "+)" + CLOSE_PATTERN;
+
+ private final static String UPPER_INFINITE_PATTERN = OPEN_PATTERN + "("
+ + ANY_NON_SPECIAL_PATTERN + "+)\\," + UI_PATTERN;
+
+ private final static Pattern FINITE_RANGE = Pattern.compile(FINITE_PATTERN);
+
+ private final static Pattern LOWER_INFINITE_RANGE = Pattern.compile(LOWER_INFINITE_PATTERN);
+
+ private final static Pattern UPPER_INFINITE_RANGE = Pattern.compile(UPPER_INFINITE_PATTERN);
+
+ private final static Pattern ALL_RANGE = Pattern.compile(FINITE_PATTERN + "|"
+ + LOWER_INFINITE_PATTERN + "|" + UPPER_INFINITE_PATTERN);
+
+ private final class MRIDArtifactInfo implements ArtifactInfo {
+ private ModuleRevisionId _mrid;
+
+ public MRIDArtifactInfo(ModuleRevisionId id) {
+ _mrid = id;
+ }
+
+ public long getLastModified() {
+ return 0;
+ }
+
+ public String getRevision() {
+ return _mrid.getRevision();
+ }
+ }
+
+ private final Comparator COMPARATOR = new Comparator() {
+ public int compare(Object o1, Object o2) {
+ if (o1.equals(o2)) {
+ return 0;
+ }
+ ArtifactInfo art1 = new MRIDArtifactInfo((ModuleRevisionId) o1);
+ ArtifactInfo art2 = new MRIDArtifactInfo((ModuleRevisionId) o2);
+ ArtifactInfo art = getLatestStrategy()
+ .findLatest(new ArtifactInfo[] {art1, art2}, null);
+ return art == art1 ? -1 : 1;
+ }
+ };
+
+ private LatestStrategy _latestStrategy;
+
+ private String _latestStrategyName = "default";
+
+ public VersionRangeMatcher() {
+ super("version-range");
+ }
+
+ public VersionRangeMatcher(String name) {
+ super(name);
+ }
+
+ public VersionRangeMatcher(String name, LatestStrategy strategy) {
+ super(name);
+ _latestStrategy = strategy;
+ }
+
+ public boolean isDynamic(ModuleRevisionId askedMrid) {
+ String revision = askedMrid.getRevision();
+ return ALL_RANGE.matcher(revision).matches();
+ }
+
+ public boolean accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) {
+ String revision = askedMrid.getRevision();
+ Matcher m;
+ m = FINITE_RANGE.matcher(revision);
+ if (m.matches()) {
+ String lower = m.group(1);
+ String upper = m.group(2);
+ return isUpper(askedMrid, lower, foundMrid, revision.startsWith(OPEN_INC))
+ && isLower(askedMrid, upper, foundMrid, revision.endsWith(CLOSE_INC));
+ }
+ m = LOWER_INFINITE_RANGE.matcher(revision);
+ if (m.matches()) {
+ String upper = m.group(1);
+ return isLower(askedMrid, upper, foundMrid, revision.endsWith(CLOSE_INC));
+ }
+ m = UPPER_INFINITE_RANGE.matcher(revision);
+ if (m.matches()) {
+ String lower = m.group(1);
+ return isUpper(askedMrid, lower, foundMrid, revision.startsWith(OPEN_INC));
+ }
+ return false;
+ }
+
+ private boolean isLower(ModuleRevisionId askedMrid, String revision,
+ ModuleRevisionId foundMrid, boolean inclusive) {
+ return COMPARATOR.compare(ModuleRevisionId.newInstance(askedMrid, revision), foundMrid) <= (inclusive ? 0
+ : -1);
+ }
+
+ private boolean isUpper(ModuleRevisionId askedMrid, String revision,
+ ModuleRevisionId foundMrid, boolean inclusive) {
+ return COMPARATOR.compare(ModuleRevisionId.newInstance(askedMrid, revision), foundMrid) >= (inclusive ? 0
+ : 1);
+ }
+
+ public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid,
+ Comparator staticComparator) {
+ String revision = askedMrid.getRevision();
+ Matcher m;
+ m = UPPER_INFINITE_RANGE.matcher(revision);
+ if (m.matches()) {
+ // no upper limit, the dynamic revision can always be considered greater
+ return 1;
+ }
+ String upper;
+ m = FINITE_RANGE.matcher(revision);
+ if (m.matches()) {
+ upper = m.group(2);
+ } else {
+ m = LOWER_INFINITE_RANGE.matcher(revision);
+ if (m.matches()) {
+ upper = m.group(1);
+ } else {
+ throw new IllegalArgumentException(
+ "impossible to compare: askedMrid is not a dynamic revision: " + askedMrid);
+ }
+ }
+ int c = staticComparator.compare(ModuleRevisionId.newInstance(askedMrid, upper), foundMrid);
+ // if the comparison consider them equal, we must return -1, because we can't consider the
+ // dynamic revision to be greater. Otherwise we can safeely return the result of the static
+ // comparison
+ return c == 0 ? -1 : c;
+ }
+
+ public LatestStrategy getLatestStrategy() {
+ if (_latestStrategy == null) {
+ if (getSettings() == null) {
+ throw new IllegalStateException(
+ "no ivy instance nor latest strategy configured in version range matcher "
+ + this);
+ }
+ if (_latestStrategyName == null) {
+ throw new IllegalStateException(
+ "null latest strategy defined in version range matcher " + this);
+ }
+ _latestStrategy = getSettings().getLatestStrategy(_latestStrategyName);
+ if (_latestStrategy == null) {
+ throw new IllegalStateException("unknown latest strategy '" + _latestStrategyName
+ + "' configured in version range matcher " + this);
+ }
+ }
+ return _latestStrategy;
+ }
+
+ public void setLatestStrategy(LatestStrategy latestStrategy) {
+ _latestStrategy = latestStrategy;
+ }
+
+ public void setLatest(String latestStrategyName) {
+ _latestStrategyName = latestStrategyName;
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/DependencyAnalyser.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/DependencyAnalyser.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/DependencyAnalyser.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/DependencyAnalyser.java Tue Jun 5 05:02:27 2007
@@ -20,5 +20,5 @@
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
public interface DependencyAnalyser {
- public ModuleDescriptor[] analyze(JarModule[] modules);
+ public ModuleDescriptor[] analyze(JarModule[] modules);
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/JarJarDependencyAnalyser.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/JarJarDependencyAnalyser.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/JarJarDependencyAnalyser.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/JarJarDependencyAnalyser.java Tue Jun 5 05:02:27 2007
@@ -30,63 +30,67 @@
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.util.Message;
-
public class JarJarDependencyAnalyser implements DependencyAnalyser {
- private File _jarjarjarLocation;
-
- public JarJarDependencyAnalyser(File jarjarjarLocation) {
- _jarjarjarLocation = jarjarjarLocation;
- }
-
-
- public ModuleDescriptor[] analyze(JarModule[] modules) {
-
- StringBuffer jarjarCmd = new StringBuffer("java -jar \"").append(_jarjarjarLocation.getAbsolutePath()).append("\" --find --level=jar ");
- Map jarModulesMap = new HashMap();
- Map mds = new HashMap();
-
- for (int i = 0; i < modules.length; i++) {
- jarModulesMap.put(modules[i].getJar().getAbsolutePath(), modules[i]);
- DefaultModuleDescriptor md = DefaultModuleDescriptor.newBasicInstance(modules[i].getMrid(), new Date(modules[i].getJar().lastModified()));
- mds.put(modules[i].getMrid(), md);
- jarjarCmd.append("\"").append(modules[i].getJar().getAbsolutePath()).append("\"");
- if (i+1 < modules.length) {
- jarjarCmd.append(File.pathSeparator);
- }
- }
-
- Message.verbose("jarjar command: "+jarjarCmd);
-
- try {
- Process p = Runtime.getRuntime().exec(jarjarCmd.toString());
- BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
- String line;
- while ((line = r.readLine()) != null) {
- String[] deps = line.split(" -> ");
- JarModule module = (JarModule) jarModulesMap.get(deps[0]);
- JarModule dependency = (JarModule) jarModulesMap.get(deps[1]);
-
- if (module.getMrid().getModuleId().equals(dependency.getMrid().getModuleId())) {
- continue;
- }
- Message.verbose(module.getMrid() + " depends on " + dependency.getMrid());
-
- DefaultModuleDescriptor md = (DefaultModuleDescriptor) mds.get(module.getMrid());
-
- DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md,dependency.getMrid(), false, false, true);
- dd.addDependencyConfiguration(ModuleDescriptor.DEFAULT_CONFIGURATION, ModuleDescriptor.DEFAULT_CONFIGURATION);
- md.addDependency(dd);
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return (ModuleDescriptor[]) mds.values().toArray(new ModuleDescriptor[mds.values().size()]);
- }
-
-
- public static void main(String[] args) {
- JarJarDependencyAnalyser a = new JarJarDependencyAnalyser(new File("D:/temp/test2/jarjar-0.7.jar"));
- a.analyze(new JarModuleFinder("D:/temp/test2/ivyrep/[organisation]/[module]/[revision]/[artifact].[ext]").findJarModules());
- }
+ private File _jarjarjarLocation;
+
+ public JarJarDependencyAnalyser(File jarjarjarLocation) {
+ _jarjarjarLocation = jarjarjarLocation;
+ }
+
+ public ModuleDescriptor[] analyze(JarModule[] modules) {
+
+ StringBuffer jarjarCmd = new StringBuffer("java -jar \"").append(
+ _jarjarjarLocation.getAbsolutePath()).append("\" --find --level=jar ");
+ Map jarModulesMap = new HashMap();
+ Map mds = new HashMap();
+
+ for (int i = 0; i < modules.length; i++) {
+ jarModulesMap.put(modules[i].getJar().getAbsolutePath(), modules[i]);
+ DefaultModuleDescriptor md = DefaultModuleDescriptor.newBasicInstance(modules[i]
+ .getMrid(), new Date(modules[i].getJar().lastModified()));
+ mds.put(modules[i].getMrid(), md);
+ jarjarCmd.append("\"").append(modules[i].getJar().getAbsolutePath()).append("\"");
+ if (i + 1 < modules.length) {
+ jarjarCmd.append(File.pathSeparator);
+ }
+ }
+
+ Message.verbose("jarjar command: " + jarjarCmd);
+
+ try {
+ Process p = Runtime.getRuntime().exec(jarjarCmd.toString());
+ BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ String line;
+ while ((line = r.readLine()) != null) {
+ String[] deps = line.split(" -> ");
+ JarModule module = (JarModule) jarModulesMap.get(deps[0]);
+ JarModule dependency = (JarModule) jarModulesMap.get(deps[1]);
+
+ if (module.getMrid().getModuleId().equals(dependency.getMrid().getModuleId())) {
+ continue;
+ }
+ Message.verbose(module.getMrid() + " depends on " + dependency.getMrid());
+
+ DefaultModuleDescriptor md = (DefaultModuleDescriptor) mds.get(module.getMrid());
+
+ DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, dependency
+ .getMrid(), false, false, true);
+ dd.addDependencyConfiguration(ModuleDescriptor.DEFAULT_CONFIGURATION,
+ ModuleDescriptor.DEFAULT_CONFIGURATION);
+ md.addDependency(dd);
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return (ModuleDescriptor[]) mds.values().toArray(new ModuleDescriptor[mds.values().size()]);
+ }
+
+ public static void main(String[] args) {
+ JarJarDependencyAnalyser a = new JarJarDependencyAnalyser(new File(
+ "D:/temp/test2/jarjar-0.7.jar"));
+ a.analyze(new JarModuleFinder(
+ "D:/temp/test2/ivyrep/[organisation]/[module]/[revision]/[artifact].[ext]")
+ .findJarModules());
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/JarModule.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/JarModule.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/JarModule.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/tools/analyser/JarModule.java Tue Jun 5 05:02:27 2007
@@ -21,26 +21,26 @@
import org.apache.ivy.core.module.id.ModuleRevisionId;
-
public class JarModule {
- private ModuleRevisionId _mrid;
- private File _jar;
-
- public JarModule(ModuleRevisionId mrid, File jar) {
- _mrid = mrid;
- _jar = jar;
- }
-
- public File getJar() {
- return _jar;
- }
-
- public ModuleRevisionId getMrid() {
- return _mrid;
- }
-
- public String toString() {
- return _jar + " " + _mrid;
- }
-
+ private ModuleRevisionId _mrid;
+
+ private File _jar;
+
+ public JarModule(ModuleRevisionId mrid, File jar) {
+ _mrid = mrid;
+ _jar = jar;
+ }
+
+ public File getJar() {
+ return _jar;
+ }
+
+ public ModuleRevisionId getMrid() {
+ return _mrid;
+ }
+
+ public String toString() {
+ return _jar + " " + _mrid;
+ }
+
}