You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ma...@apache.org on 2008/03/18 23:13:12 UTC
svn commit: r638606 - in /ant/ivy/core/trunk: ./
src/java/org/apache/ivy/ant/ src/java/org/apache/ivy/core/
src/java/org/apache/ivy/core/install/ src/java/org/apache/ivy/core/search/
src/java/org/apache/ivy/plugins/resolver/ test/java/org/apache/ivy/an...
Author: maartenc
Date: Tue Mar 18 15:13:04 2008
New Revision: 638606
URL: http://svn.apache.org/viewvc?rev=638606&view=rev
Log:
FIX: repreport task not working against a repository structured by branches (IVY-716)
Added:
ant/ivy/core/trunk/test/repositories/IVY-716/
ant/ivy/core/trunk/test/repositories/IVY-716/ivysettings.xml
ant/ivy/core/trunk/test/repositories/IVY-716/org1/
ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch1/
ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch1/mod1.1/
ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch1/mod1.1/1.0/
ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch1/mod1.1/1.0/ivy.xml.txt
ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch1/mod1.1/1.0/mod1.1.jar
ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch2/
ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch2/mod1.1/
ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch2/mod1.1/1.0/
ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch2/mod1.1/1.0/ivy.xml.txt
ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch2/mod1.1/1.0/mod1.1.jar
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRepositoryReport.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/install/InstallEngine.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/search/SearchEngine.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResourceResolver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java
ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyRepositoryReportTest.java
Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=638606&r1=638605&r2=638606&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Tue Mar 18 15:13:04 2008
@@ -73,6 +73,7 @@
- IMPROVEMENT: Parse description and home page from poms (IVY-767)
- IMPROVEMENT: Smarter determination if an expression is exact or not for RegexpPatternMatcher and GlobPatternMatcher
+- FIX: repreport task not working against a repository structured by branches (IVY-716)
- FIX: Ivy reports a conflict when the same file is supposed to be retrieved at the same location twice (or more) (IVY-743)
- FIX: StackOverflowError when configuration extends itself (IVY-696)
- FIX: XML schema ambiguity (IVY-750)
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRepositoryReport.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRepositoryReport.java?rev=638606&r1=638605&r2=638606&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRepositoryReport.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRepositoryReport.java Tue Mar 18 15:13:04 2008
@@ -20,12 +20,15 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import org.apache.ivy.Ivy;
import org.apache.ivy.core.cache.ResolutionCacheManager;
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.ResolveReport;
@@ -87,18 +90,24 @@
ModuleRevisionId mrid = ModuleRevisionId.newInstance(organisation, module, revision);
try {
- ModuleId[] mids = ivy.listModules(new ModuleId(organisation, module), settings
- .getMatcher(matcher));
- ModuleRevisionId[] mrids = new ModuleRevisionId[mids.length];
+ ModuleRevisionId criteria = null;
+
+ if ((revision == null) || settings.getVersionMatcher().isDynamic(mrid)) {
+ criteria = new ModuleRevisionId(new ModuleId(organisation, module), branch, "*");
+ } else {
+ criteria = new ModuleRevisionId(new ModuleId(organisation, module), branch, revision);
+ }
+
+ ModuleRevisionId[] mrids = ivy.listModules(criteria, settings.getMatcher(matcher));
+
+ // replace all found revisions with the original requested revision
+ Set modules = new HashSet();
for (int i = 0; i < mrids.length; i++) {
- if (branch != null) {
- mrids[i] = new ModuleRevisionId(mids[i], branch, revision);
- } else {
- mrids[i] = new ModuleRevisionId(mids[i], revision);
- }
+ modules.add(ModuleRevisionId.newInstance(mrids[i], revision));
}
- DefaultModuleDescriptor md = DefaultModuleDescriptor.newCallerInstance(mrids, true,
- false);
+
+ mrids = (ModuleRevisionId[]) modules.toArray(new ModuleRevisionId[modules.size()]);
+ ModuleDescriptor md = DefaultModuleDescriptor.newCallerInstance(mrids, true, false);
String resolveId = ResolveOptions.getDefaultResolveId(md);
ResolveReport report = ivy.resolve(md,
new ResolveOptions()
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java?rev=638606&r1=638605&r2=638606&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java Tue Mar 18 15:13:04 2008
@@ -457,4 +457,19 @@
return pattern.substring(0, index);
}
}
+
+ public static String getFirstToken(String pattern) {
+ if (pattern == null) {
+ return null;
+ }
+ int startIndex = pattern.indexOf('[');
+ if (startIndex == -1) {
+ return null;
+ }
+ int endIndex = pattern.indexOf(']', startIndex);
+ if (endIndex == -1) {
+ return null;
+ }
+ return pattern.substring(startIndex + 1, endIndex);
+ }
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/install/InstallEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/install/InstallEngine.java?rev=638606&r1=638605&r2=638606&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/install/InstallEngine.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/install/InstallEngine.java Tue Mar 18 15:13:04 2008
@@ -103,12 +103,11 @@
dd.addDependencyConfiguration("default", "*");
md.addDependency(dd);
} else {
- Collection mrids = searchEngine.findModuleRevisionIds(fromResolver, mrid, matcher);
+ ModuleRevisionId[] mrids = searchEngine.listModules(fromResolver, mrid, matcher);
- for (Iterator iter = mrids.iterator(); iter.hasNext();) {
- ModuleRevisionId foundMrid = (ModuleRevisionId) iter.next();
- Message.info("\tfound " + foundMrid + " to install: adding to the list");
- DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, foundMrid,
+ for (int i = 0; i < mrids.length; i++) {
+ Message.info("\tfound " + mrids[i] + " to install: adding to the list");
+ DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, mrids[i],
false, false, options.isTransitive());
dd.addDependencyConfiguration("default", "*");
md.addDependency(dd);
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/search/SearchEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/search/SearchEngine.java?rev=638606&r1=638605&r2=638606&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/search/SearchEngine.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/search/SearchEngine.java Tue Mar 18 15:13:04 2008
@@ -23,9 +23,9 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.ivy.core.IvyPatternHelper;
import org.apache.ivy.core.module.id.ModuleId;
@@ -55,90 +55,120 @@
* @return
*/
public String[] listTokenValues(String token, Map otherTokenValues) {
- Collection r = new LinkedHashSet();
+ Set entries = new HashSet();
+
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
- r.addAll(Arrays.asList(resolver.listTokenValues(token, otherTokenValues)));
+ Map[] values = resolver.listTokenValues(new String[] {token}, new HashMap());
+ for (int i = 0; i < values.length; i++) {
+ entries.add(values[i].get(token));
+ }
}
- return (String[]) r.toArray(new String[r.size()]);
+
+ return (String[]) entries.toArray(new String[entries.size()]);
}
public OrganisationEntry[] listOrganisationEntries() {
- List entries = new ArrayList();
+ Set entries = new HashSet();
+
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
- entries.addAll(Arrays.asList(resolver.listOrganisations()));
+ Map[] orgs = resolver.listTokenValues(new String[] {IvyPatternHelper.ORGANISATION_KEY}, new HashMap());
+ for (int i = 0; i < orgs.length; i++) {
+ String org = (String) orgs[i].get(IvyPatternHelper.ORGANISATION_KEY);
+ entries.add(new OrganisationEntry(resolver, org));
+ }
}
+
return (OrganisationEntry[]) entries.toArray(new OrganisationEntry[entries.size()]);
}
public String[] listOrganisations() {
- Collection orgs = new HashSet();
+ Set entries = new HashSet();
+
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
- OrganisationEntry[] entries = resolver.listOrganisations();
- if (entries != null) {
- for (int i = 0; i < entries.length; i++) {
- if (entries[i] != null) {
- orgs.add(entries[i].getOrganisation());
- }
- }
+ Map[] orgs = resolver.listTokenValues(new String[] {IvyPatternHelper.ORGANISATION_KEY}, new HashMap());
+ for (int i = 0; i < orgs.length; i++) {
+ entries.add(orgs[i].get(IvyPatternHelper.ORGANISATION_KEY));
}
}
- return (String[]) orgs.toArray(new String[orgs.size()]);
+
+ return (String[]) entries.toArray(new String[entries.size()]);
}
public ModuleEntry[] listModuleEntries(OrganisationEntry org) {
- List entries = new ArrayList();
+ Set entries = new HashSet();
+
+ Map tokenValues = new HashMap();
+ tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org.getOrganisation());
+
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
- entries.addAll(Arrays.asList(resolver.listModules(org)));
+ Map[] modules = resolver.listTokenValues(new String[] {IvyPatternHelper.MODULE_KEY}, tokenValues);
+ for (int i = 0; i < modules.length; i++) {
+ String module = (String) modules[i].get(IvyPatternHelper.MODULE_KEY);
+ entries.add(new ModuleEntry(org, module));
+ }
}
+
return (ModuleEntry[]) entries.toArray(new ModuleEntry[entries.size()]);
}
public String[] listModules(String org) {
- List mods = new ArrayList();
+ Set entries = new HashSet();
+
+ Map tokenValues = new HashMap();
+ tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org);
+
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
- ModuleEntry[] entries = resolver.listModules(new OrganisationEntry(resolver, org));
- if (entries != null) {
- for (int i = 0; i < entries.length; i++) {
- if (entries[i] != null) {
- mods.add(entries[i].getModule());
- }
- }
+ Map[] modules = resolver.listTokenValues(new String[] {IvyPatternHelper.MODULE_KEY}, tokenValues);
+ for (int i = 0; i < modules.length; i++) {
+ entries.add(modules[i].get(IvyPatternHelper.MODULE_KEY));
}
}
- return (String[]) mods.toArray(new String[mods.size()]);
- }
+ return (String[]) entries.toArray(new String[entries.size()]);
+ }
+
public RevisionEntry[] listRevisionEntries(ModuleEntry module) {
- List entries = new ArrayList();
+ Set entries = new HashSet();
+
+ Map tokenValues = new HashMap();
+ tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, module.getOrganisation());
+ tokenValues.put(IvyPatternHelper.MODULE_KEY, module.getModule());
+
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
- entries.addAll(Arrays.asList(resolver.listRevisions(module)));
+ Map[] revisions = resolver.listTokenValues(new String[] {IvyPatternHelper.REVISION_KEY}, tokenValues);
+ for (int i = 0; i < revisions.length; i++) {
+ String revision = (String) revisions[i].get(IvyPatternHelper.REVISION_KEY);
+ entries.add(new RevisionEntry(module, revision));
+ }
}
+
return (RevisionEntry[]) entries.toArray(new RevisionEntry[entries.size()]);
}
public String[] listRevisions(String org, String module) {
- List revs = new ArrayList();
+ Set entries = new HashSet();
+
+ Map tokenValues = new HashMap();
+ tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org);
+ tokenValues.put(IvyPatternHelper.MODULE_KEY, module);
+
for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
- RevisionEntry[] entries = resolver.listRevisions(new ModuleEntry(new OrganisationEntry(
- resolver, org), module));
- if (entries != null) {
- for (int i = 0; i < entries.length; i++) {
- if (entries[i] != null) {
- revs.add(entries[i].getRevision());
- }
- }
+ Map[] revisions = resolver.listTokenValues(new String[] {IvyPatternHelper.REVISION_KEY}, tokenValues);
+ for (int i = 0; i < revisions.length; i++) {
+ entries.add(revisions[i].get(IvyPatternHelper.REVISION_KEY));
}
}
- return (String[]) revs.toArray(new String[revs.size()]);
- }
+ return (String[]) entries.toArray(new String[entries.size()]);
+ }
+
/**
* List module ids of the module accessible through the current resolvers matching the given mid
* criteria according to the given matcher.
@@ -147,23 +177,26 @@
* @param matcher
* @return
*/
- public ModuleId[] listModules(ModuleId criteria, PatternMatcher matcher) {
+ public ModuleId[] listModules(ModuleId moduleCrit, PatternMatcher matcher) {
List ret = new ArrayList();
- Matcher orgMatcher = matcher.getMatcher(criteria.getOrganisation());
- Matcher modMatcher = matcher.getMatcher(criteria.getName());
- Map tokenValues = new HashMap();
- String[] orgs = listTokenValues(IvyPatternHelper.ORGANISATION_KEY, tokenValues);
- for (int i = 0; i < orgs.length; i++) {
- if (orgMatcher.matches(orgs[i])) {
- tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, orgs[i]);
- String[] mods = listTokenValues(IvyPatternHelper.MODULE_KEY, tokenValues);
- for (int j = 0; j < mods.length; j++) {
- if (modMatcher.matches(mods[j])) {
- ret.add(new ModuleId(orgs[i], mods[j]));
- }
- }
+
+ Map criteria = new HashMap();
+ addMatcher(matcher, moduleCrit.getOrganisation(), criteria, IvyPatternHelper.ORGANISATION_KEY);
+ addMatcher(matcher, moduleCrit.getName(), criteria, IvyPatternHelper.MODULE_KEY);
+
+ String[] tokensToList = new String[] {IvyPatternHelper.ORGANISATION_KEY, IvyPatternHelper.MODULE_KEY};
+
+ for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
+ DependencyResolver resolver = (DependencyResolver) iter.next();
+ Map[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
+ for (int i = 0; i < moduleIdAsMap.length; i++) {
+ String org = (String) moduleIdAsMap[i].get(IvyPatternHelper.ORGANISATION_KEY);
+ String name = (String) moduleIdAsMap[i].get(IvyPatternHelper.MODULE_KEY);
+ ModuleId modId = ModuleId.newInstance(org, name);
+ ret.add(modId);
}
}
+
return (ModuleId[]) ret.toArray(new ModuleId[ret.size()]);
}
@@ -175,50 +208,68 @@
* @param matcher
* @return
*/
- public ModuleRevisionId[] listModules(ModuleRevisionId criteria, PatternMatcher matcher) {
+ public ModuleRevisionId[] listModules(ModuleRevisionId moduleCrit, PatternMatcher matcher) {
List ret = new ArrayList();
- Matcher orgMatcher = matcher.getMatcher(criteria.getOrganisation());
- Matcher modMatcher = matcher.getMatcher(criteria.getName());
- Matcher branchMatcher = matcher.getMatcher(criteria.getBranch());
- Matcher revMatcher = matcher.getMatcher(criteria.getRevision());
- Map tokenValues = new HashMap();
- String[] orgs = listTokenValues(IvyPatternHelper.ORGANISATION_KEY, tokenValues);
- for (int i = 0; i < orgs.length; i++) {
- if (orgMatcher.matches(orgs[i])) {
- tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, orgs[i]);
- String[] mods = listTokenValues(IvyPatternHelper.MODULE_KEY, tokenValues);
- for (int j = 0; j < mods.length; j++) {
- if (modMatcher.matches(mods[j])) {
- tokenValues.put(IvyPatternHelper.MODULE_KEY, mods[j]);
- String[] branches = listTokenValues(IvyPatternHelper.BRANCH_KEY,
- tokenValues);
- if (branches == null || branches.length == 0) {
- branches = new String[] {settings.getDefaultBranch(new ModuleId(
- orgs[i], mods[j]))};
- }
- for (int k = 0; k < branches.length; k++) {
- if (branches[k] == null || branchMatcher.matches(branches[k])) {
- tokenValues.put(IvyPatternHelper.BRANCH_KEY, tokenValues);
- String[] revs = listTokenValues(IvyPatternHelper.REVISION_KEY,
- tokenValues);
- for (int l = 0; l < revs.length; l++) {
- if (revMatcher.matches(revs[l])) {
- ret.add(ModuleRevisionId.newInstance(orgs[i], mods[j],
- branches[k], revs[l]));
- }
- }
- tokenValues.remove(IvyPatternHelper.REVISION_KEY);
- }
- }
- tokenValues.remove(IvyPatternHelper.BRANCH_KEY);
- }
- }
- tokenValues.remove(IvyPatternHelper.MODULE_KEY);
+
+ Map criteria = new HashMap();
+ addMatcher(matcher, moduleCrit.getOrganisation(), criteria, IvyPatternHelper.ORGANISATION_KEY);
+ addMatcher(matcher, moduleCrit.getName(), criteria, IvyPatternHelper.MODULE_KEY);
+ addMatcher(matcher, moduleCrit.getBranch(), criteria, IvyPatternHelper.BRANCH_KEY);
+ addMatcher(matcher, moduleCrit.getRevision(), criteria, IvyPatternHelper.REVISION_KEY);
+
+ String[] tokensToList = new String[] {IvyPatternHelper.ORGANISATION_KEY, IvyPatternHelper.MODULE_KEY, IvyPatternHelper.BRANCH_KEY, IvyPatternHelper.REVISION_KEY};
+
+ for (Iterator iter = settings.getResolvers().iterator(); iter.hasNext();) {
+ DependencyResolver resolver = (DependencyResolver) iter.next();
+ Map[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
+ for (int i = 0; i < moduleIdAsMap.length; i++) {
+ String org = (String) moduleIdAsMap[i].get(IvyPatternHelper.ORGANISATION_KEY);
+ String name = (String) moduleIdAsMap[i].get(IvyPatternHelper.MODULE_KEY);
+ String branch = (String) moduleIdAsMap[i].get(IvyPatternHelper.BRANCH_KEY);
+ String rev = (String) moduleIdAsMap[i].get(IvyPatternHelper.REVISION_KEY);
+ ModuleRevisionId modRevId = ModuleRevisionId.newInstance(org, name, branch, rev);
+ ret.add(modRevId);
}
}
+
return (ModuleRevisionId[]) ret.toArray(new ModuleRevisionId[ret.size()]);
}
+ public ModuleRevisionId[] listModules(DependencyResolver resolver, ModuleRevisionId moduleCrit, PatternMatcher matcher) {
+ Map criteria = new HashMap();
+ addMatcher(matcher, moduleCrit.getOrganisation(), criteria, IvyPatternHelper.ORGANISATION_KEY);
+ addMatcher(matcher, moduleCrit.getName(), criteria, IvyPatternHelper.MODULE_KEY);
+ addMatcher(matcher, moduleCrit.getBranch(), criteria, IvyPatternHelper.BRANCH_KEY);
+ addMatcher(matcher, moduleCrit.getRevision(), criteria, IvyPatternHelper.REVISION_KEY);
+
+ String[] tokensToList = new String[] {IvyPatternHelper.ORGANISATION_KEY, IvyPatternHelper.MODULE_KEY, IvyPatternHelper.BRANCH_KEY, IvyPatternHelper.REVISION_KEY};
+
+ Map[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
+ ModuleRevisionId[] result = new ModuleRevisionId[moduleIdAsMap.length];
+ for (int i = 0; i < moduleIdAsMap.length; i++) {
+ String org = (String) moduleIdAsMap[i].get(IvyPatternHelper.ORGANISATION_KEY);
+ String name = (String) moduleIdAsMap[i].get(IvyPatternHelper.MODULE_KEY);
+ String branch = (String) moduleIdAsMap[i].get(IvyPatternHelper.BRANCH_KEY);
+ String rev = (String) moduleIdAsMap[i].get(IvyPatternHelper.REVISION_KEY);
+ result[i] = ModuleRevisionId.newInstance(org, name, branch, rev);
+ }
+
+ return result;
+ }
+
+ private void addMatcher(PatternMatcher patternMatcher, String expression, Map criteria, String key) {
+ if (expression == null) {
+ return;
+ }
+
+ Matcher matcher = patternMatcher.getMatcher(expression);
+ if (matcher.isExact()) {
+ criteria.put(key, expression);
+ } else {
+ criteria.put(key, matcher);
+ }
+ }
+
public Collection findModuleRevisionIds(DependencyResolver resolver, ModuleRevisionId pattern,
PatternMatcher matcher) {
Collection mrids = new ArrayList();
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java?rev=638606&r1=638605&r2=638606&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java Tue Mar 18 15:13:04 2008
@@ -155,6 +155,10 @@
return new String[0];
}
+ public Map[] listTokenValues(String[] tokens, Map criteria) {
+ return new Map[0];
+ }
+
public OrganisationEntry[] listOrganisations() {
return new OrganisationEntry[0];
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResourceResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResourceResolver.java?rev=638606&r1=638605&r2=638606&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResourceResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResourceResolver.java Tue Mar 18 15:13:04 2008
@@ -18,6 +18,7 @@
package org.apache.ivy.plugins.resolver;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
@@ -28,6 +29,7 @@
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
+import java.util.Map.Entry;
import org.apache.ivy.core.IvyContext;
import org.apache.ivy.core.IvyPatternHelper;
@@ -40,6 +42,7 @@
import org.apache.ivy.core.resolve.ResolveData;
import org.apache.ivy.core.settings.IvyPattern;
import org.apache.ivy.plugins.conflict.ConflictManager;
+import org.apache.ivy.plugins.matcher.Matcher;
import org.apache.ivy.plugins.resolver.util.MDResolvedResource;
import org.apache.ivy.plugins.resolver.util.ResolvedResource;
import org.apache.ivy.plugins.resolver.util.ResourceMDParser;
@@ -238,6 +241,99 @@
filterNames(names);
return names;
}
+
+ public Map[] listTokenValues(String[] tokens, Map criteria) {
+ Set result = new HashSet();
+
+ // use ivy patterns
+ List ivyPatterns = getIvyPatterns();
+ Map tokenValues = new HashMap(criteria);
+ tokenValues.put(IvyPatternHelper.TYPE_KEY, "ivy");
+ tokenValues.put(IvyPatternHelper.EXT_KEY, "xml");
+ for (Iterator it = ivyPatterns.iterator(); it.hasNext(); ) {
+ String ivyPattern = (String) it.next();
+ result.addAll(resolveTokenValues(tokens, ivyPattern, tokenValues, false));
+ }
+
+ if (isAllownomd()) {
+ List artifactPatterns = getArtifactPatterns();
+ tokenValues = new HashMap(criteria);
+ tokenValues.put(IvyPatternHelper.TYPE_KEY, "jar");
+ tokenValues.put(IvyPatternHelper.EXT_KEY, "jar");
+ for (Iterator it = artifactPatterns.iterator(); it.hasNext(); ) {
+ String artifactPattern = (String) it.next();
+ result.addAll(resolveTokenValues(tokens, artifactPattern, tokenValues, true));
+ }
+ }
+
+ return (Map[]) result.toArray(new Map[result.size()]);
+ }
+
+ private Set resolveTokenValues(String[] tokens, String pattern, Map criteria, boolean noMd) {
+ Set result = new HashSet();
+ Set tokenSet = new HashSet(Arrays.asList(tokens));
+
+ Map tokenValues = new HashMap();
+ for (Iterator it = criteria.entrySet().iterator(); it.hasNext(); ) {
+ Map.Entry entry = (Entry) it.next();
+ Object key = entry.getKey();
+ Object value = entry.getValue();
+ if (value instanceof String) {
+ tokenValues.put(key, value);
+ }
+ }
+
+ if (tokenSet.isEmpty()) {
+ // no more tokens to resolve
+ result.add(tokenValues);
+ return result;
+ }
+
+ String partiallyResolvedPattern = IvyPatternHelper.substituteTokens(pattern, tokenValues);
+ String token = IvyPatternHelper.getFirstToken(partiallyResolvedPattern);
+ if ((token == null) && exist(partiallyResolvedPattern)) {
+ // no more tokens to resolve
+ result.add(tokenValues);
+ return result;
+ }
+
+ tokenSet.remove(token);
+
+ Matcher matcher = null;
+ Object criteriaForToken = criteria.get(token);
+ if (criteriaForToken instanceof Matcher) {
+ matcher = (Matcher) criteriaForToken;
+ }
+
+ String[] values = listTokenValues(partiallyResolvedPattern, token);
+ if (values == null) {
+ return result;
+ }
+
+ for (int i = 0; i < values.length; i++) {
+ if ((matcher != null) && !matcher.matches(values[i])) {
+ continue;
+ }
+
+ tokenValues.put(token, values[i]);
+ String moreResolvedPattern = IvyPatternHelper.substituteTokens(partiallyResolvedPattern, tokenValues);
+
+ Map newCriteria = new HashMap(criteria);
+ newCriteria.put(token, values[i]);
+ if (noMd && "artifact".equals(token)) {
+ newCriteria.put("module", values[i]);
+ } else if (noMd && "module".equals(token)) {
+ newCriteria.put("artifact", values[i]);
+ }
+ result.addAll(resolveTokenValues((String[]) tokenSet.toArray(new String[tokenSet.size()]), moreResolvedPattern, newCriteria, noMd));
+ }
+
+ return result;
+ }
+
+ protected abstract String[] listTokenValues(String pattern, String token);
+
+ protected abstract boolean exist(String path);
/**
* Filters names before returning them in the findXXXNames or findTokenValues method.
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java?rev=638606&r1=638605&r2=638606&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java Tue Mar 18 15:13:04 2008
@@ -104,13 +104,15 @@
* bar from the org foo.
*/
String[] listTokenValues(String token, Map otherTokenValues);
+
+ Map[] listTokenValues(String[] tokens, Map criteria);
OrganisationEntry[] listOrganisations();
ModuleEntry[] listModules(OrganisationEntry org);
RevisionEntry[] listRevisions(ModuleEntry module);
-
+
void dumpSettings();
void setSettings(ResolverSettings settings);
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java?rev=638606&r1=638605&r2=638606&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java Tue Mar 18 15:13:04 2008
@@ -230,6 +230,19 @@
}
}
}
+
+ protected String[] listTokenValues(String pattern, String token) {
+ return ResolverHelper.listTokenValues(repository, pattern, token);
+ }
+
+ protected boolean exist(String path) {
+ try {
+ Resource resource = repository.getResource(path);
+ return resource.exists();
+ } catch (IOException e) {
+ return false;
+ }
+ }
public String getTypeName() {
return "repository";
Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyRepositoryReportTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyRepositoryReportTest.java?rev=638606&r1=638605&r2=638606&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyRepositoryReportTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyRepositoryReportTest.java Tue Mar 18 15:13:04 2008
@@ -17,10 +17,13 @@
*/
package org.apache.ivy.ant;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.FileReader;
import junit.framework.TestCase;
+import org.apache.ivy.util.FileUtil;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Delete;
@@ -55,36 +58,56 @@
del.execute();
}
- public void test() {
+ public void testSimple() throws Exception {
+ report.setOrganisation("org1");
+ report.setOutputname("testsimple");
+ report.setTodir(cache);
+ report.execute();
+
+ File reportFile = new File(cache, "testsimple.xml");
+ assertTrue(reportFile.exists());
+ String g = FileUtil.readEntirely(new BufferedReader(new FileReader(reportFile)));
+
+ // check presence of the modules
+ assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.1\"") != -1);
+ assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.2\"") != -1);
+ assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.3\"") != -1);
+ assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.4\"") != -1);
+ assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.5\"") != -1);
+ assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.6\"") != -1);
+ }
+
+ public void testBranchBeforeModule() throws Exception {
+ report.getProject().setProperty("ivy.settings.file", "test/repositories/IVY-716/ivysettings.xml");
+ report.setOutputname("testbranch");
+ report.setTodir(cache);
+ report.execute();
+
+ File reportFile = new File(cache, "testbranch.xml");
+ assertTrue(reportFile.exists());
+ String g = FileUtil.readEntirely(new BufferedReader(new FileReader(reportFile)));
+
+ // check presence of the modules
+ assertTrue(g.indexOf("<module organisation=\"org1\" name=\"mod1.1\"") != -1);
+
+ // check presence of the branches
+ assertTrue(g.indexOf("<revision name=\"1.0\" branch=\"branch1\"") != -1);
+ assertTrue(g.indexOf("<revision name=\"1.0\" branch=\"branch2\"") != -1);
+ }
+
+ public void testPatternWithoutOrganisation() throws Exception {
+ report.getProject().setProperty("ivy.settings.file", "test/repositories/IVY-729/ivysettings.xml");
+ report.setOutputname("test-no-org");
+ report.setTodir(cache);
+ report.execute();
+
+ File reportFile = new File(cache, "test-no-org.xml");
+ assertTrue(reportFile.exists());
+ String g = FileUtil.readEntirely(new BufferedReader(new FileReader(reportFile)));
+
+ // check presence of the modules
+ assertTrue(g.indexOf("<module organisation=\"null\" name=\"a\"") != -1);
+ assertTrue(g.indexOf("<module organisation=\"null\" name=\"b\"") != -1);
+ assertTrue(g.indexOf("<module organisation=\"null\" name=\"c\"") != -1);
}
-
- // no xslt transformation is possible in the junit test on our continuous integration server for
- // the moment...
- // public void testGraph() throws Exception {
- // _report.setOrganisation("org1");
- // _report.setXml(false);
- // _report.setGraph(true);
- // _report.setTodir(_cache);
- // _report.setOutputname("test-graph");
- // _report.execute();
- // File graphml = new File(_cache, "test-graph.graphml");
- // assertTrue(graphml.exists());
- // String g = FileUtil.readEntirely(new BufferedReader(new FileReader(graphml)));
- // assertFalse(g.indexOf("caller") != -1);
- // assertTrue(g.indexOf("mod1.1") != -1);
- // }
- //
- // public void testDot() throws Exception {
- // _report.setOrganisation("org1");
- // _report.setXml(false);
- // _report.setDot(true);
- // _report.setTodir(_cache);
- // _report.setOutputname("test-graph");
- // _report.execute();
- // File dot = new File(_cache, "test-graph.dot");
- // assertTrue(dot.exists());
- // String g = FileUtil.readEntirely(new BufferedReader(new FileReader(dot)));
- // assertFalse(g.indexOf("caller") != -1);
- // assertTrue(g.indexOf("mod1.1") != -1);
- // }
}
Added: ant/ivy/core/trunk/test/repositories/IVY-716/ivysettings.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-716/ivysettings.xml?rev=638606&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-716/ivysettings.xml (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-716/ivysettings.xml Tue Mar 18 15:13:04 2008
@@ -0,0 +1,27 @@
+<!--
+ 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.
+-->
+<ivysettings>
+ <settings defaultResolver="myresolver"/>
+ <resolvers>
+ <filesystem name="myresolver">
+ <ivy pattern="${ivy.settings.dir}/[organisation]/[branch]/[module]/[revision]/ivy.xml" />
+ <artifact pattern="${ivy.settings.dir}/[organisation]/[branch]/[module]/[revision]/[artifact].[ext]" />
+ </filesystem>
+ </resolvers>
+</ivysettings>
Added: ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch1/mod1.1/1.0/ivy.xml.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch1/mod1.1/1.0/ivy.xml.txt?rev=638606&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch1/mod1.1/1.0/ivy.xml.txt (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch1/mod1.1/1.0/ivy.xml.txt Tue Mar 18 15:13:04 2008
@@ -0,0 +1,30 @@
+<!--
+ 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.
+-->
+<ivy-module version="1.0">
+ <info organisation="org1"
+ module="mod1.1"
+ revision="1.0"
+ branch="branch1"
+ status="integration"
+ publication="20041101110000"
+ />
+ <dependencies>
+ <dependency name="mod1.2" rev="2.0"/>
+ </dependencies>
+</ivy-module>
Added: ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch1/mod1.1/1.0/mod1.1.jar
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch1/mod1.1/1.0/mod1.1.jar?rev=638606&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch1/mod1.1/1.0/mod1.1.jar (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch1/mod1.1/1.0/mod1.1.jar Tue Mar 18 15:13:04 2008
@@ -0,0 +1 @@
+
Added: ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch2/mod1.1/1.0/ivy.xml.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch2/mod1.1/1.0/ivy.xml.txt?rev=638606&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch2/mod1.1/1.0/ivy.xml.txt (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch2/mod1.1/1.0/ivy.xml.txt Tue Mar 18 15:13:04 2008
@@ -0,0 +1,30 @@
+<!--
+ 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.
+-->
+<ivy-module version="1.0">
+ <info organisation="org1"
+ module="mod1.1"
+ revision="1.0"
+ branch="branch2"
+ status="integration"
+ publication="20041101110000"
+ />
+ <dependencies>
+ <dependency name="mod1.2" rev="2.0"/>
+ </dependencies>
+</ivy-module>
Added: ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch2/mod1.1/1.0/mod1.1.jar
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch2/mod1.1/1.0/mod1.1.jar?rev=638606&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch2/mod1.1/1.0/mod1.1.jar (added)
+++ ant/ivy/core/trunk/test/repositories/IVY-716/org1/branch2/mod1.1/1.0/mod1.1.jar Tue Mar 18 15:13:04 2008
@@ -0,0 +1 @@
+