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 2009/07/03 23:41:36 UTC
svn commit: r791026 [2/3] - in /ant/ivy/core/branches/2.1.x: ./ doc/
doc/dev/ doc/ivyfile/ doc/settings/ doc/use/ 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/apach...
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/descriptor/DefaultDependencyDescriptor.java Fri Jul 3 21:41:32 2009
@@ -21,6 +21,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@@ -45,9 +46,9 @@
* method.
*/
public class DefaultDependencyDescriptor implements DependencyDescriptor {
- private static final Pattern SELF_FALLBACK_PATTERN = Pattern.compile("@(\\(.*\\))?");
+ private static final Pattern SELF_FALLBACK_PATTERN = Pattern.compile("@(\\+[^\\(]+)?(\\(.*\\))?");
- private static final Pattern THIS_FALLBACK_PATTERN = Pattern.compile("#(\\(.*\\))?");
+ private static final Pattern THIS_FALLBACK_PATTERN = Pattern.compile("#(\\+[^\\(]+)?(\\(.*\\))?");
/**
* Transforms the given dependency descriptor of the given namespace and return a new dependency
@@ -123,7 +124,7 @@
private ModuleRevisionId dynamicRevId;
- private Map confs = new LinkedHashMap();
+ private Map/*<String,List<String>>*/ confs = new LinkedHashMap();
// Map (String masterConf -> Collection(DependencyArtifactDescriptor))
private Map dependencyArtifacts; // initialized on demand only for memory consumption reason
@@ -244,6 +245,100 @@
*/
public String[] getDependencyConfigurations(String moduleConfiguration,
String requestedConfiguration) {
+ if (md != null) {
+ Configuration c = md.getConfiguration(moduleConfiguration);
+ if (c instanceof ConfigurationIntersection) {
+ ConfigurationIntersection intersection = (ConfigurationIntersection) c;
+ Set /*<String>*/ intersectedDepConfs = new HashSet();
+ String[] intersected = intersection.getIntersectedConfigurationNames();
+ for (int i = 0; i < intersected.length; i++) {
+ Collection depConfs =
+ getDependencyConfigurationsIncludingExtending(
+ intersected[i], requestedConfiguration);
+ if (intersectedDepConfs.isEmpty()) {
+ intersectedDepConfs.addAll(depConfs);
+ } else {
+ if (intersectedDepConfs.contains("*")) {
+ intersectedDepConfs.remove("*");
+ intersectedDepConfs.addAll(depConfs);
+ } else if (depConfs.contains("*")) {
+ // nothing to do, intersection of 'something'
+ // with 'everything' is 'something'
+ } else {
+ Set /*<String>*/ intersectedDepConfsCopy = intersectedDepConfs;
+ intersectedDepConfs = new HashSet();
+ for (Iterator it = intersectedDepConfsCopy.iterator(); it.hasNext();) {
+ String intersectedDepConf = (String) it.next();
+ if (depConfs.contains(intersectedDepConf)) {
+ // the conf is present in both sets,
+ // so it is in the intersection
+ intersectedDepConfs.add(intersectedDepConf);
+ continue;
+ }
+ /*
+ we do not handle special confs like *!sg or [cond]* in right hand
+ confs yet: it would require supporting parenthesis grouping in
+ configurations intersection interpretation
+
+ for (Iterator it2 = depConfs.iterator(); it2.hasNext();) {
+ String depConf = (String) it2.next();
+ if (depConf.startsWith("*")) {
+ if (intersectedDepConf
+ .indexOf("(" + depConf + ")") != -1) {
+ intersectedDepConfs.add(intersectedDepConf);
+ } else {
+ intersectedDepConfs.add(
+ "(" + intersectedDepConf + ")+(" + depConf + ")");
+ }
+ } else if (intersectedDepConf.startsWith("*")) {
+ if (depConf
+ .indexOf("(" + intersectedDepConf + ")") != -1) {
+ intersectedDepConfs.add(depConf);
+ } else {
+ intersectedDepConfs.add(
+ depConf + "+" + intersectedDepConf);
+ }
+ }
+ }
+ */
+ }
+ }
+ }
+ }
+ List confsList = (List) confs.get(moduleConfiguration);
+ if (confsList != null) {
+ intersectedDepConfs.addAll(confsList);
+ }
+ if (intersectedDepConfs.isEmpty()) {
+ List defConfs = (List) confs.get("*");
+ if (defConfs != null) {
+ for (Iterator it = defConfs.iterator(); it.hasNext();) {
+ String mappedConf = (String) it.next();
+ if (mappedConf != null && mappedConf.startsWith("@+")) {
+ return new String[] {
+ moduleConfiguration + mappedConf.substring(1)};
+ } else if (mappedConf != null && mappedConf.equals("@")) {
+ return new String[] {moduleConfiguration};
+ }
+ }
+ }
+ }
+ return (String[]) intersectedDepConfs.toArray(
+ new String[intersectedDepConfs.size()]);
+ } else if (c instanceof ConfigurationGroup) {
+ ConfigurationGroup group = (ConfigurationGroup) c;
+ Set /*<String>*/ groupDepConfs = new HashSet();
+ String[] members = group.getMembersConfigurationNames();
+ for (int i = 0; i < members.length; i++) {
+ Collection depConfs =
+ getDependencyConfigurationsIncludingExtending(
+ members[i], requestedConfiguration);
+ groupDepConfs.addAll(depConfs);
+ }
+ return (String[]) groupDepConfs.toArray(new String[groupDepConfs.size()]);
+ }
+ }
+
List confsList = (List) confs.get(moduleConfiguration);
if (confsList == null) {
// there is no mapping defined for this configuration, add the 'other' mappings.
@@ -285,6 +380,20 @@
return (String[]) ret.toArray(new String[ret.size()]);
}
+ private Collection getDependencyConfigurationsIncludingExtending(
+ String conf, String requestedConfiguration) {
+ Set/*<String>*/ allDepConfs = new LinkedHashSet();
+ allDepConfs.addAll(Arrays.asList(getDependencyConfigurations(conf, requestedConfiguration)));
+
+ Collection extendingConfs = Configuration.findConfigurationExtending(conf, md.getConfigurations());
+ for (Iterator it = extendingConfs.iterator(); it.hasNext();) {
+ Configuration extendingConf = (Configuration) it.next();
+ allDepConfs.addAll(Arrays.asList(getDependencyConfigurations(
+ extendingConf.getName(), requestedConfiguration)));
+ }
+ return allDepConfs;
+ }
+
protected static String replaceSelfFallbackPattern(final String conf,
final String moduleConfiguration) {
return replaceFallbackConfigurationPattern(
@@ -312,11 +421,14 @@
final String conf, final String moduleConfiguration) {
Matcher matcher = pattern.matcher(conf);
if (matcher.matches()) {
+ String mappedConf = moduleConfiguration;
if (matcher.group(1) != null) {
- return moduleConfiguration + matcher.group(1);
- } else {
- return moduleConfiguration;
+ mappedConf = mappedConf + matcher.group(1);
}
+ if (matcher.group(2) != null) {
+ mappedConf = mappedConf + matcher.group(2);
+ }
+ return mappedConf;
}
return null;
}
@@ -437,6 +549,14 @@
+ "' to configuration '" + masterConf + "' of module "
+ md.getModuleRevisionId() + " because this configuration doesn't exist!");
}
+ if (config instanceof ConfigurationGroup) {
+ ConfigurationGroup group = (ConfigurationGroup) config;
+ String[] members = group.getMembersConfigurationNames();
+ for (int i = 0; i < members.length; i++) {
+ addDependencyConfiguration(members[i], depConf);
+ }
+ return;
+ }
}
List confsList = (List) confs.get(masterConf);
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java Fri Jul 3 21:41:32 2009
@@ -32,6 +32,8 @@
import java.util.Map;
import java.util.Set;
import java.util.Stack;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.ivy.core.module.id.ArtifactId;
import org.apache.ivy.core.module.id.ModuleId;
@@ -336,19 +338,27 @@
* @param artifact
*/
public void addArtifact(String conf, Artifact artifact) {
- if (!configurations.containsKey(conf)) {
+ Configuration c = getConfiguration(conf);
+ if (c == null) {
throw new IllegalArgumentException("Cannot add artifact '" + artifact.getId().getArtifactId().getShortDescription()
+ "' to configuration '" + conf + "' of module " + revId
+ " because this configuration doesn't exist!");
}
-
- Collection artifacts = (Collection) artifactsByConf.get(conf);
- if (artifacts == null) {
- artifacts = new ArrayList();
- artifactsByConf.put(conf, artifacts);
+ if (c instanceof ConfigurationGroup) {
+ ConfigurationGroup group = (ConfigurationGroup) c;
+ String[] members = group.getMembersConfigurationNames();
+ for (int i = 0; i < members.length; i++) {
+ addArtifact(members[i], artifact);
+ }
+ } else {
+ Collection artifacts = (Collection) artifactsByConf.get(conf);
+ if (artifacts == null) {
+ artifacts = new ArrayList();
+ artifactsByConf.put(conf, artifacts);
+ }
+ artifacts.add(artifact);
+ this.artifacts.add(artifact);
}
- artifacts.add(artifact);
- this.artifacts.add(artifact);
}
public ModuleRevisionId getModuleRevisionId() {
@@ -388,16 +398,105 @@
* if not found.
*/
public Configuration getConfiguration(String confName) {
- return (Configuration) configurations.get(confName);
+ Configuration configuration = (Configuration) configurations.get(confName);
+ if (configuration == null && confName != null) {
+ // let's first check if the configuration is a conf group
+ Matcher m = Pattern.compile("\\*\\[([^=]+)\\=([^\\]]+)\\]").matcher(confName);
+ if (m.matches()) {
+ String attName = m.group(1);
+ String attValue = m.group(2);
+
+ // this is a conf group, let's search for its members
+ Map /*<String,Configuration>*/ members = new LinkedHashMap();
+ for (Iterator it = configurations.values().iterator(); it.hasNext();) {
+ Configuration conf = (Configuration) it.next();
+ if (attValue.equals(conf.getAttribute(attName))) {
+ members.put(conf.getName(), conf);
+ }
+ }
+ return new ConfigurationGroup(confName, members);
+ }
+
+ // let's see if a configuration intersection is requested
+ String[] confs = confName.split("\\+");
+ if (confs.length <= 1) {
+ return null;
+ }
+ Map /*<String,Configuration>*/ intersectedConfs = new LinkedHashMap();
+ for (int i = 0; i < confs.length; i++) {
+ Configuration c = (Configuration) configurations.get(confs[i]);
+ if (c == null) {
+ Message.verbose(
+ "missing configuration '" + confs[i]
+ + "' from intersection " + confName + " in " + this);
+ return null;
+ }
+ intersectedConfs.put(confs[i], c);
+ }
+ return new ConfigurationIntersection(confName, intersectedConfs);
+ }
+ return configuration;
}
public Artifact[] getArtifacts(String conf) {
- Collection artifacts = (Collection) artifactsByConf.get(conf);
- if (artifacts == null) {
+ Configuration c = getConfiguration(conf);
+ if (c == null) {
return new Artifact[0];
+ }
+ Collection artifacts = (Collection) artifactsByConf.get(conf);
+ if (c instanceof ConfigurationIntersection) {
+ ConfigurationIntersection intersection = (ConfigurationIntersection) c;
+ String[] intersected = intersection.getIntersectedConfigurationNames();
+ Set/*<Artifact>*/ intersectedArtifacts = new LinkedHashSet();
+ for (int j = 0; j < intersected.length; j++) {
+ Collection arts = getArtifactsIncludingExtending(intersected[j]);
+ if (intersectedArtifacts.isEmpty()) {
+ intersectedArtifacts.addAll(arts);
+ } else {
+ intersectedArtifacts.retainAll(arts);
+ }
+ }
+ if (artifacts != null) {
+ intersectedArtifacts.addAll(artifacts);
+ }
+ return (Artifact[]) intersectedArtifacts.toArray(
+ new Artifact[intersectedArtifacts.size()]);
+ } else if (c instanceof ConfigurationGroup) {
+ ConfigurationGroup group = (ConfigurationGroup) c;
+ String[] members = group.getMembersConfigurationNames();
+ Set/*<Artifact>*/ groupArtifacts = new LinkedHashSet();
+ for (int i = 0; i < members.length; i++) {
+ groupArtifacts.addAll(getArtifactsIncludingExtending(members[i]));
+ }
+ if (artifacts != null) {
+ groupArtifacts.addAll(artifacts);
+ }
+ return (Artifact[]) groupArtifacts.toArray(new Artifact[groupArtifacts.size()]);
} else {
- return (Artifact[]) artifacts.toArray(new Artifact[artifacts.size()]);
+ if (artifacts == null) {
+ return new Artifact[0];
+ } else {
+ return (Artifact[]) artifacts.toArray(new Artifact[artifacts.size()]);
+ }
+ }
+ }
+
+ private Collection/*<Artifact>*/ getArtifactsIncludingExtending(String conf) {
+ Collection extendingConfs = Configuration.findConfigurationExtending(
+ conf, getConfigurations());
+ Set/*<Artifact>*/ artifacts = new LinkedHashSet();
+ Collection arts = (Collection) artifactsByConf.get(conf);
+ if (arts != null) {
+ artifacts.addAll(arts);
+ }
+ for (Iterator it = extendingConfs.iterator(); it.hasNext();) {
+ Configuration extendingConf = (Configuration) it.next();
+ arts = (Collection) artifactsByConf.get(extendingConf.getName());
+ if (arts != null) {
+ artifacts.addAll(arts);
+ }
}
+ return artifacts;
}
public Artifact[] getAllArtifacts() {
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/descriptor/MDArtifact.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/descriptor/MDArtifact.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/descriptor/MDArtifact.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/descriptor/MDArtifact.java Fri Jul 3 21:41:32 2009
@@ -43,7 +43,7 @@
private String ext;
- private List confs = new ArrayList();
+ private List/*<String>*/ confs = new ArrayList();
private Map extraAttributes = null;
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java Fri Jul 3 21:41:32 2009
@@ -122,6 +122,13 @@
branch, revision, extraAttributes));
}
+ public static ModuleRevisionId newInstance(String organisation, String name, String branch,
+ String revision, Map extraAttributes, boolean replaceNullBranchWithDefault) {
+ return intern(
+ new ModuleRevisionId(ModuleId.newInstance(organisation, name),
+ branch, revision, extraAttributes, replaceNullBranchWithDefault));
+ }
+
public static ModuleRevisionId newInstance(ModuleRevisionId mrid, String rev) {
return intern(
new ModuleRevisionId(mrid.getModuleId(),
@@ -190,10 +197,15 @@
private ModuleRevisionId(ModuleId moduleId, String branch, String revision,
Map extraAttributes) {
+ this(moduleId, branch, revision, extraAttributes, true);
+ }
+
+ private ModuleRevisionId(ModuleId moduleId, String branch, String revision,
+ Map extraAttributes, boolean replaceNullBranchWithDefault) {
super(null, extraAttributes);
this.moduleId = moduleId;
IvyContext context = IvyContext.getContext();
- this.branch = branch == null
+ this.branch = (replaceNullBranchWithDefault && branch == null)
// we test if there's already an Ivy instance loaded, to avoid loading a default one
// just to get the default branch
? (context.peekIvy() == null ? null : context.getSettings().getDefaultBranch(moduleId))
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java Fri Jul 3 21:41:32 2009
@@ -154,4 +154,33 @@
public boolean isDownloaded() {
return DownloadStatus.SUCCESSFUL == downloadStatus;
}
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((artifact == null) ? 0 : artifact.hashCode());
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ArtifactDownloadReport other = (ArtifactDownloadReport) obj;
+ if (artifact == null) {
+ if (other.artifact != null) {
+ return false;
+ }
+ } else if (!artifact.equals(other.artifact)) {
+ return false;
+ }
+ return true;
+ }
+
}
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java Fri Jul 3 21:41:32 2009
@@ -56,13 +56,13 @@
private final ResolveOptions options;
- private Map dependencyReports = new LinkedHashMap();
+ private Map/*<IvyNode, List<ArtifactDownloadReport>>*/ dependencyReports = new LinkedHashMap();
- private Map dependencies = new LinkedHashMap();
+ private Map/*<ModuleRevisionId, IvyNode>*/ dependencies = new LinkedHashMap();
private final ResolveEngine resolveEngine;
- private Map modulesIdsMap = new LinkedHashMap();
+ private Map/*<ModuleId, Collection<IvyNode>>*/ modulesIdsMap = new LinkedHashMap();
private List modulesIds;
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/report/ResolveReport.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/report/ResolveReport.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/report/ResolveReport.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/report/ResolveReport.java Fri Jul 3 21:41:32 2009
@@ -50,9 +50,9 @@
/**
* the list of all dependencies resolved, ordered from the more dependent to the less dependent
*/
- private List dependencies = new ArrayList();
+ private List/*<IvyNode>*/ dependencies = new ArrayList();
- private List artifacts = new ArrayList();
+ private List/*<Artifact>*/ artifacts = new ArrayList();
private long resolveTime;
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/IvyNode.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/IvyNode.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/IvyNode.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/IvyNode.java Fri Jul 3 21:41:32 2009
@@ -39,6 +39,7 @@
import org.apache.ivy.core.event.resolve.StartResolveDependencyEvent;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.Configuration;
+import org.apache.ivy.core.module.descriptor.ConfigurationIntersection;
import org.apache.ivy.core.module.descriptor.DefaultArtifact;
import org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
@@ -348,7 +349,7 @@
depNode.addRootModuleConfigurations(depNode.usage, rootModuleConf, confsArray);
depNode.usage.setRequiredConfs(this, conf, confs);
- depNode.addCaller(rootModuleConf, this, conf, dependencyConfigurations, dd);
+ depNode.addCaller(rootModuleConf, this, conf, requestedConf, dependencyConfigurations, dd);
dependencies.add(depNode);
}
return dependencies;
@@ -1021,8 +1022,8 @@
}
public void addCaller(String rootModuleConf, IvyNode callerNode, String callerConf,
- String[] dependencyConfs, DependencyDescriptor dd) {
- callers.addCaller(rootModuleConf, callerNode, callerConf, dependencyConfs, dd);
+ String requestedConf, String[] dependencyConfs, DependencyDescriptor dd) {
+ callers.addCaller(rootModuleConf, callerNode, callerConf, requestedConf, dependencyConfs, dd);
boolean isCircular = callers.getAllCallersModuleIds().contains(getId().getModuleId());
if (isCircular) {
IvyContext.getContext().getCircularDependencyStrategy().handleCircularDependency(
@@ -1265,4 +1266,30 @@
return usage;
}
+ /**
+ * Indicates if there is any of the merged usages of this node which has a depender with
+ * transitive dependency descriptor.
+ * <p>
+ * If at there is at least one usage from the merged usages for which there is a depender in the
+ * given root module conf which has a dependency descriptor with transitive == true, then it
+ * returns true. Otherwise it returns false.
+ * </p>
+ *
+ * @param rootModuleConf
+ * the root module configuration to consider
+ * @return true if there is any merged usage with transitive dd, false otherwise.
+ */
+ public boolean hasAnyMergedUsageWithTransitiveDependency(String rootModuleConf) {
+ if (mergedUsages == null) {
+ return false;
+ }
+ for (Iterator iterator = mergedUsages.values().iterator(); iterator.hasNext();) {
+ IvyNodeUsage usage = (IvyNodeUsage) iterator.next();
+ if (usage.hasTransitiveDepender(rootModuleConf)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
}
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/IvyNodeCallers.java Fri Jul 3 21:41:32 2009
@@ -17,16 +17,19 @@
*/
package org.apache.ivy.core.resolve;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.descriptor.Configuration;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleId;
@@ -55,6 +58,19 @@
}
public void addConfiguration(String callerConf, String[] dependencyConfs) {
+ updateConfs(callerConf, dependencyConfs);
+ Configuration conf = md.getConfiguration(callerConf);
+ if (conf != null) {
+ String[] confExtends = conf.getExtends();
+ if (confExtends != null) {
+ for (int i = 0; i < confExtends.length; i++) {
+ addConfiguration(confExtends[i], dependencyConfs);
+ }
+ }
+ }
+ }
+
+ private void updateConfs(String callerConf, String[] dependencyConfs) {
String[] prevDepConfs = (String[]) confs.get(callerConf);
if (prevDepConfs != null) {
Set newDepConfs = new HashSet(Arrays.asList(prevDepConfs));
@@ -146,7 +162,7 @@
* the dependency revision id asked by the caller
*/
public void addCaller(String rootModuleConf, IvyNode callerNode, String callerConf,
- String[] dependencyConfs, DependencyDescriptor dd) {
+ String requestedConf, String[] dependencyConfs, DependencyDescriptor dd) {
ModuleDescriptor md = callerNode.getDescriptor();
ModuleRevisionId mrid = callerNode.getResolvedId();
if (mrid.getModuleId().equals(node.getId().getModuleId())) {
@@ -163,7 +179,7 @@
caller = new Caller(md, mrid, dd, callerNode.canExclude(rootModuleConf));
callers.put(mrid, caller);
}
- caller.addConfiguration(callerConf, dependencyConfs);
+ caller.addConfiguration(requestedConf, dependencyConfs);
IvyNode parent = callerNode.getRealNode();
for (Iterator iter = parent.getAllCallersModuleIds().iterator(); iter.hasNext();) {
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/IvyNodeUsage.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/IvyNodeUsage.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/IvyNodeUsage.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/IvyNodeUsage.java Fri Jul 3 21:41:32 2009
@@ -299,5 +299,28 @@
protected IvyNode getNode() {
return node;
}
+
+ /**
+ * Indicates if at least one depender has a transitive dependency descriptor for the given root
+ * module conf.
+ *
+ * @param rootModuleConf
+ * the root module conf to consider
+ * @return <code>true</code> if at least one depender has a transitive dependency descriptor for
+ * the given root module conf, <code>false</code> otherwise.
+ */
+ public boolean hasTransitiveDepender(String rootModuleConf) {
+ Set/*<Depender>*/ dependersSet = (Set) dependers.get(rootModuleConf);
+ if (dependersSet == null) {
+ return false;
+ }
+ for (Iterator iterator = dependersSet.iterator(); iterator.hasNext();) {
+ Depender depender = (Depender) iterator.next();
+ if (depender.dd.isTransitive()) {
+ return true;
+ }
+ }
+ return false;
+ }
}
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/ResolveEngine.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/ResolveEngine.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/ResolveEngine.java Fri Jul 3 21:41:32 2009
@@ -1131,7 +1131,10 @@
if (ResolveOptions.RESOLVEMODE_DYNAMIC.equals(resolveMode)
&& !dd.getDynamicConstraintDependencyRevisionId()
.equals(dd.getDependencyRevisionId())) {
- return dd.clone(dd.getDynamicConstraintDependencyRevisionId());
+ // the dynamicRevId can contain a null branch, so make sure this
+ // has been replaced by the default branch (if any!)
+ return dd.clone(ModuleRevisionId.newInstance(dd.getDynamicConstraintDependencyRevisionId(),
+ dd.getDynamicConstraintDependencyRevisionId().getRevision()));
} else {
return dd;
}
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/VisitNode.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/VisitNode.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/VisitNode.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/resolve/VisitNode.java Fri Jul 3 21:41:32 2009
@@ -216,7 +216,9 @@
*/
public boolean isTransitive() {
return (data.isTransitive()
- && node.getDependencyDescriptor(getParentNode()).isTransitive()
+ && (
+ node.getDependencyDescriptor(getParentNode()).isTransitive()
+ || node.hasAnyMergedUsageWithTransitiveDependency(rootModuleConf))
&& isParentConfTransitive());
}
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java Fri Jul 3 21:41:32 2009
@@ -38,7 +38,9 @@
import org.apache.ivy.core.LogOptions;
import org.apache.ivy.core.cache.ResolutionCacheManager;
import org.apache.ivy.core.event.EventManager;
+import org.apache.ivy.core.event.retrieve.EndRetrieveArtifactEvent;
import org.apache.ivy.core.event.retrieve.EndRetrieveEvent;
+import org.apache.ivy.core.event.retrieve.StartRetrieveArtifactEvent;
import org.apache.ivy.core.event.retrieve.StartRetrieveEvent;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
@@ -128,11 +130,19 @@
File destFile = settings.resolveFile((String) it2.next());
if (!settings.isCheckUpToDate() || !upToDate(archive, destFile)) {
Message.verbose("\t\tto " + destFile);
+ if (this.eventManager != null) {
+ this.eventManager.fireIvyEvent(
+ new StartRetrieveArtifactEvent(artifact, destFile));
+ }
if (options.isMakeSymlinks()) {
FileUtil.symlink(archive, destFile, null, true);
} else {
FileUtil.copy(archive, destFile, null, true);
}
+ if (this.eventManager != null) {
+ this.eventManager.fireIvyEvent(
+ new EndRetrieveArtifactEvent(artifact, destFile));
+ }
totalCopiedSize += destFile.length();
targetsCopied++;
} else {
@@ -294,8 +304,9 @@
continue; // skip this artifact, the filter didn't accept it!
}
- String destFileName = IvyPatternHelper.substitute(
- destPattern, artifact.getArtifact(), conf);
+ String destFileName = IvyPatternHelper.substitute(destPattern,
+ artifact.getArtifact().getModuleRevisionId(), artifact.getArtifact(),
+ conf, artifact.getArtifactOrigin());
Set dest = (Set) artifactsToCopy.get(artifact);
if (dest == null) {
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/settings/typedef.properties
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/settings/typedef.properties?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/settings/typedef.properties (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/core/settings/typedef.properties Fri Jul 3 21:41:32 2009
@@ -48,6 +48,7 @@
latest-vm = org.apache.ivy.plugins.version.LatestVersionMatcher
sub-vm = org.apache.ivy.plugins.version.SubVersionMatcher
range-vm = org.apache.ivy.plugins.version.VersionRangeMatcher
+pattern-vm = org.apache.ivy.plugins.version.PatternVersionMatcher
ant-build = org.apache.ivy.ant.AntBuildTrigger
ant-call = org.apache.ivy.ant.AntCallTrigger
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/namespace/Namespace.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/namespace/Namespace.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/namespace/Namespace.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/namespace/Namespace.java Fri Jul 3 21:41:32 2009
@@ -29,7 +29,7 @@
SYSTEM_NAMESPACE = new Namespace();
}
- private List rules = new ArrayList();
+ private List/*<NamespaceRule>*/ rules = new ArrayList();
private String name;
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/parser/ParserSettings.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/parser/ParserSettings.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/parser/ParserSettings.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/parser/ParserSettings.java Fri Jul 3 21:41:32 2009
@@ -22,6 +22,7 @@
import org.apache.ivy.core.RelativeUrlResolver;
import org.apache.ivy.core.cache.ResolutionCacheManager;
+import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.module.status.StatusManager;
import org.apache.ivy.plugins.conflict.ConflictManager;
@@ -52,5 +53,7 @@
File resolveFile(String filename);
File getBaseDir();
+
+ String getDefaultBranch(ModuleId moduleId);
}
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java Fri Jul 3 21:41:32 2009
@@ -292,6 +292,17 @@
if (dep.getType() != null) {
type = dep.getType();
}
+ String ext = type;
+
+ // if type is 'test-jar', the extension is 'jar' and the classifier is 'tests'
+ // Cfr. http://maven.apache.org/guides/mini/guide-attached-tests.html
+ if ("test-jar".equals(type)) {
+ ext = "jar";
+ extraAtt.put("m:classifier", "tests");
+ } else if (JAR_PACKAGINGS.contains(type)) {
+ ext = "jar";
+ }
+
// we deal with classifiers by setting an extra attribute and forcing the
// dependency to assume such an artifact is published
if (dep.getClassifier() != null) {
@@ -299,7 +310,7 @@
}
DefaultDependencyArtifactDescriptor depArtifact =
new DefaultDependencyArtifactDescriptor(dd, dd.getDependencyId().getName(),
- type, type, null, extraAtt);
+ type, ext, null, extraAtt);
// here we have to assume a type and ext for the artifact, so this is a limitation
// compared to how m2 behave with classifiers
String optionalizedScope = dep.isOptional() ? "optional" : scope;
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java Fri Jul 3 21:41:32 2009
@@ -49,6 +49,7 @@
import org.apache.ivy.core.module.id.ArtifactId;
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.conflict.ConflictManager;
import org.apache.ivy.plugins.conflict.FixedConflictManager;
import org.apache.ivy.plugins.matcher.PatternMatcher;
@@ -521,17 +522,40 @@
String name = settings.substitute(attributes.getValue("name"));
String branch = settings.substitute(attributes.getValue("branch"));
String branchConstraint = settings.substitute(attributes.getValue("branchConstraint"));
+
+// if (branchConstraint == null) {
+// // there was no branch constraint before, so we should
+// // set the branchConstraint to the current default branch
+// branchConstraint = settings.getDefaultBranch(ModuleId.newInstance(org, name));
+// }
+
String rev = settings.substitute(attributes.getValue("rev"));
String revConstraint = settings.substitute(attributes.getValue("revConstraint"));
- revConstraint = revConstraint == null ? rev : revConstraint;
+
Map extraAttributes = ExtendableItemHelper.getExtraAttributes(
settings, attributes, DEPENDENCY_REGULAR_ATTRIBUTES);
- dd = new DefaultDependencyDescriptor(
- getMd(),
- ModuleRevisionId.newInstance(org, name, branch, rev, extraAttributes),
- ModuleRevisionId.newInstance(
- org, name, branchConstraint, revConstraint, extraAttributes),
- force, changing, transitive);
+
+ ModuleRevisionId revId = ModuleRevisionId.newInstance(org, name, branch, rev,
+ extraAttributes);
+ ModuleRevisionId dynamicId = null;
+ if ((revConstraint == null) && (branchConstraint == null)) {
+ // no dynamic constraints defined, so dynamicId equals revId
+ dynamicId = ModuleRevisionId.newInstance(org, name, branch, rev,
+ extraAttributes, false);
+ } else {
+ if (branchConstraint == null) {
+ // this situation occurs when there was no branch defined
+ // in the original dependency descriptor. So the dynamicId
+ // shouldn't contain a branch neither
+ dynamicId = ModuleRevisionId.newInstance(org, name, null, revConstraint,
+ extraAttributes, false);
+ } else {
+ dynamicId = ModuleRevisionId.newInstance(org, name, branchConstraint,
+ revConstraint, extraAttributes);
+ }
+ }
+
+ dd = new DefaultDependencyDescriptor(getMd(), revId, dynamicId, force, changing, transitive);
getMd().addDependency(dd);
String confs = settings.substitute(attributes.getValue("conf"));
if (confs != null && confs.length() > 0) {
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/report/XmlReportParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/report/XmlReportParser.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/report/XmlReportParser.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/report/XmlReportParser.java Fri Jul 3 21:41:32 2009
@@ -104,7 +104,10 @@
realMrids.add(mrid);
}
try {
- pubdate = Ivy.DATE_FORMAT.parse(attributes.getValue("pubdate"));
+ String pubDateAttr = attributes.getValue("pubdate");
+ if (pubDateAttr != null) {
+ pubdate = Ivy.DATE_FORMAT.parse(pubDateAttr);
+ }
skip = false;
} catch (ParseException e) {
throw new IllegalArgumentException("invalid publication date for "
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/repository/Repository.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/repository/Repository.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/repository/Repository.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/repository/Repository.java Fri Jul 3 21:41:32 2009
@@ -32,7 +32,7 @@
* A repository supports the following fundamental operations
* <ul>
* <li>retrieving a resource from the repository.</li>
- * <li>transfering a resource to the repository.</li>
+ * <li>transferring a resource to the repository.</li>
* <li>retrieving a listing of resources.</li>
* </ul>
* </p>
@@ -66,7 +66,7 @@
* A string identifying the resource.
* @return The resource associated with the resource identifier.
* @throws IOException
- * On error whle trying to get resource.
+ * On error while trying to get resource.
*/
Resource getResource(String source) throws IOException;
@@ -130,7 +130,7 @@
* Determine if a given listener is attached to the repository.
*
* @param listener
- * The listener being quireied
+ * The listener being queried
* @return <code>true</code> if the provided listener is attached to the repository,
* <code>false</code> if not.
*/
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/repository/sftp/SFTPRepository.java Fri Jul 3 21:41:32 2009
@@ -78,12 +78,12 @@
}
/**
- * This method is similar to getResource, except that the returned resource is fully initialised
+ * This method is similar to getResource, except that the returned resource is fully initialized
* (resolved in the sftp repository), and that the given string is a full remote path
*
* @param path
* the full remote path in the repository of the resource
- * @return a fully initialised resource, able to answer to all its methods without needing any
+ * @return a fully initialized resource, able to answer to all its methods without needing any
* further connection
*/
public Resource resolveResource(String path) {
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/repository/ssh/SshCache.java Fri Jul 3 21:41:32 2009
@@ -327,6 +327,7 @@
}
session.setUserInfo(new CfUserInfo(host, username, userPassword, pemFile,
pemPassword, passFile));
+ session.setDaemonThread(true);
session.connect();
Message.verbose(":: SSH :: connected to " + host + "!");
setSession(username, host, port, session);
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java Fri Jul 3 21:41:32 2009
@@ -69,7 +69,7 @@
/**
* True if parsed ivy files should be validated against xsd, false if they should not, null if
- * default behaviur should be used
+ * default behavior should be used
*/
private Boolean validate = null;
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java Fri Jul 3 21:41:32 2009
@@ -167,7 +167,16 @@
* </p>
*/
String[] listTokenValues(String token, Map otherTokenValues);
-
+
+ /**
+ * Same as {@link #listTokenValues(String, Map)} but more generic.
+ *
+ * @param tokens
+ * the tokens of the query
+ * @param criteria
+ * the token which have values
+ * @return the list of token values (Map<Strin, String>[]), must not be <code>null</code>
+ */
Map[] listTokenValues(String[] tokens, Map criteria);
OrganisationEntry[] listOrganisations();
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java Fri Jul 3 21:41:32 2009
@@ -121,14 +121,15 @@
public void abortPublishTransaction() throws IOException {
if (supportTransaction()) {
- if (!isTransactionStarted()) {
- throw new IllegalStateException("no current transaction!");
- }
- try {
- getFileRepository().delete(transactionTempDir);
- Message.info("\tpublish aborted: deleted " + transactionTempDir);
- } finally {
- closeTransaction();
+ if (isTransactionStarted()) {
+ try {
+ getFileRepository().delete(transactionTempDir);
+ Message.info("\tpublish aborted: deleted " + transactionTempDir);
+ } finally {
+ closeTransaction();
+ }
+ } else {
+ Message.info("\tpublish aborted: nothing was started");
}
}
}
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java Fri Jul 3 21:41:32 2009
@@ -130,8 +130,7 @@
String rev = findSnapshotVersion(mrid);
if (rev != null) {
// replace the revision token in file name with the resolved revision
- String pattern = (String) getArtifactPatterns().get(0);
- pattern = pattern.replaceFirst("\\-\\[revision\\]", "-" + rev);
+ String pattern = getWholePattern().replaceFirst("\\-\\[revision\\]", "-" + rev);
return findResourceUsingPattern(mrid, pattern, artifact,
getDefaultRMDParser(artifact.getModuleRevisionId().getModuleId()), date);
}
@@ -148,8 +147,7 @@
Message.verbose("[" + rev + "] " + mrid);
// replace the revision token in file name with the resolved revision
- String pattern = (String) getIvyPatterns().get(0);
- pattern = pattern.replaceFirst("\\-\\[revision\\]", "-" + rev);
+ String pattern = getWholePattern().replaceFirst("\\-\\[revision\\]", "-" + rev);
return findResourceUsingPattern(mrid, pattern,
DefaultArtifact.newPomArtifact(
mrid, data.getDate()), getRMDParser(dd, data), data.getDate());
@@ -162,8 +160,7 @@
return null;
}
- String pattern = (String) getIvyPatterns().get(0);
- if (shouldUseMavenMetadata(pattern)) {
+ if (shouldUseMavenMetadata(getWholePattern())) {
InputStream metadataStream = null;
try {
String metadataLocation = IvyPatternHelper.substitute(
@@ -337,40 +334,37 @@
// let's see if we should use maven metadata for this listing...
if (IvyPatternHelper.REVISION_KEY.equals(token)
- && isM2compatible()
- && isUseMavenMetadata()) {
- if (((String) getIvyPatterns().get(0)).endsWith(M2_PER_MODULE_PATTERN)) {
- // now we must use metadata if available
+ && shouldUseMavenMetadata(getWholePattern())) {
+ // now we must use metadata if available
+ /*
+ * we substitute tokens with ext token only in the m2 per module pattern, to match
+ * has has been done in the given pattern
+ */
+ String partiallyResolvedM2PerModulePattern = IvyPatternHelper.substituteTokens(
+ M2_PER_MODULE_PATTERN,
+ Collections.singletonMap(IvyPatternHelper.EXT_KEY, "pom"));
+ if (pattern.endsWith(partiallyResolvedM2PerModulePattern)) {
/*
- * we substitute tokens with ext token only in the m2 per module pattern, to match
- * has has been done in the given pattern
+ * the given pattern already contain resolved org and module, we just have to
+ * replace the per module pattern at the end by 'maven-metadata.xml' to have the
+ * maven metadata file location
*/
- String partiallyResolvedM2PerModulePattern = IvyPatternHelper.substituteTokens(
- M2_PER_MODULE_PATTERN,
- Collections.singletonMap(IvyPatternHelper.EXT_KEY, "pom"));
- if (pattern.endsWith(partiallyResolvedM2PerModulePattern)) {
- /*
- * the given pattern already contain resolved org and module, we just have to
- * replace the per module pattern at the end by 'maven-metadata.xml' to have the
- * maven metadata file location
- */
- String metadataLocation = pattern.substring(0, pattern
- .lastIndexOf(partiallyResolvedM2PerModulePattern))
- + "maven-metadata.xml";
- List revs = listRevisionsWithMavenMetadata(getRepository(), metadataLocation);
- if (revs != null) {
- return (String[]) revs.toArray(new String[revs.size()]);
- }
- } else {
- /*
- * this is probably because the given pattern has been substituted with jar ext,
- * if this resolver has optional module descriptors. But since we have to use
- * maven metadata, we don't care about this case, maven metadata has already
- * been used when looking for revisions with the pattern substituted with
- * ext=xml for the "ivy" pattern.
- */
- return new String[0];
+ String metadataLocation = pattern.substring(0, pattern
+ .lastIndexOf(partiallyResolvedM2PerModulePattern))
+ + "maven-metadata.xml";
+ List revs = listRevisionsWithMavenMetadata(getRepository(), metadataLocation);
+ if (revs != null) {
+ return (String[]) revs.toArray(new String[revs.size()]);
}
+ } else {
+ /*
+ * this is probably because the given pattern has been substituted with jar ext,
+ * if this resolver has optional module descriptors. But since we have to use
+ * maven metadata, we don't care about this case, maven metadata has already
+ * been used when looking for revisions with the pattern substituted with
+ * ext=xml for the "ivy" pattern.
+ */
+ return new String[0];
}
}
return super.listTokenValues(pattern, token);
@@ -478,8 +472,7 @@
protected void findTokenValues(Collection names, List patterns, Map tokenValues, String token) {
if (IvyPatternHelper.REVISION_KEY.equals(token)) {
- String pattern = (String) patterns.get(0);
- if (shouldUseMavenMetadata(pattern)) {
+ if (shouldUseMavenMetadata(getWholePattern())) {
List revs = listRevisionsWithMavenMetadata(getRepository(), tokenValues);
if (revs != null) {
names.addAll(filterNames(revs));
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java Fri Jul 3 21:41:32 2009
@@ -220,6 +220,13 @@
String[] checksums = getChecksumAlgorithms();
for (int i = 0; i < checksums.length; i++) {
if (!ChecksumHelper.isKnownAlgorithm(checksums[i])) {
+ throw new IllegalArgumentException("Unknown checksum algorithm: " + checksums[i]);
+ }
+ }
+
+ repository.put(artifact, src, dest, overwrite);
+ for (int i = 0; i < checksums.length; i++) {
+ if (!ChecksumHelper.isKnownAlgorithm(checksums[i])) {
throw new IllegalArgumentException("Unknown checksum algorithm: " + checksums[i]); }
}
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/packager/PackagerCacheEntry.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/packager/PackagerCacheEntry.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/packager/PackagerCacheEntry.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/packager/PackagerCacheEntry.java Fri Jul 3 21:41:32 2009
@@ -218,7 +218,7 @@
private String getResourceURL() {
String baseURL = IvyPatternHelper.substitute(this.resourceURL, this.mr.getOrganisation(),
this.mr.getName(), this.mr.getRevision(), null, null, null, null,
- this.mr.getAttributes());
+ this.mr.getAttributes(), null);
int slash = baseURL.lastIndexOf('/');
if (slash != -1) {
baseURL = baseURL.substring(0, slash + 1);
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/util/ResolverHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/util/ResolverHelper.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/util/ResolverHelper.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/resolver/util/ResolverHelper.java Fri Jul 3 21:41:32 2009
@@ -75,7 +75,7 @@
namePattern = namePattern.replaceAll("\\.", "\\\\.");
String acceptNamePattern = ".*?"
+ IvyPatternHelper.substituteToken(namePattern, token, "([^" + fileSep
- + "]+)") + "($|" + fileSep + ".*)" ;
+ + "]+)") + "($|" + fileSep + ".*)";
Pattern p = Pattern.compile(acceptNamePattern);
for (Iterator iter = all.iterator(); iter.hasNext();) {
String path = (String) iter.next();
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/version/VersionMatcher.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/version/VersionMatcher.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/version/VersionMatcher.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/plugins/version/VersionMatcher.java Fri Jul 3 21:41:32 2009
@@ -25,15 +25,21 @@
/**
* 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
+ * them) and if a found revision matches the asked one.
+ * <p>
+ * Two ways of matching are possible:
+ * <ul>
+ * <li>based on the module revision only (known as ModuleRevisionId)</li>
+ * <li>based on the parsed module descriptor</li>
+ * </ul>
* 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).
+ * needs such parsing or not using the
+ * {@link #needModuleDescriptor(ModuleRevisionId, ModuleRevisionId)} 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
+ * {@link #needModuleDescriptor(ModuleRevisionId, ModuleRevisionId)} and
+ * {@link #accept(ModuleRevisionId, ModuleDescriptor)}.
*/
public interface VersionMatcher {
/**
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/util/filter/FilterHelper.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/util/filter/FilterHelper.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/util/filter/FilterHelper.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/util/filter/FilterHelper.java Fri Jul 3 21:41:32 2009
@@ -33,9 +33,20 @@
return NO_FILTER;
}
String[] t = types.split(",");
- List acceptedTypes = new ArrayList(t.length);
- for (int i = 0; i < t.length; i++) {
- acceptedTypes.add(t[i].trim());
+ return getArtifactTypeFilter(t);
+ }
+
+ public static Filter getArtifactTypeFilter(String[] types) {
+ if (types == null || types.length == 0) {
+ return NO_FILTER;
+ }
+ List acceptedTypes = new ArrayList(types.length);
+ for (int i = 0; i < types.length; i++) {
+ String current = types[i].trim();
+ if ("*".equals(current)) {
+ return NO_FILTER;
+ }
+ acceptedTypes.add(current);
}
return new ArtifactTypeFilter(acceptedTypes);
}
Modified: ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/util/url/HttpClientHandler.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/util/url/HttpClientHandler.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/util/url/HttpClientHandler.java (original)
+++ ant/ivy/core/branches/2.1.x/src/java/org/apache/ivy/util/url/HttpClientHandler.java Fri Jul 3 21:41:32 2009
@@ -35,8 +35,9 @@
import org.apache.commons.httpclient.HttpMethodBase;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.NTCredentials;
import org.apache.commons.httpclient.auth.AuthPolicy;
+import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
@@ -45,6 +46,7 @@
import org.apache.ivy.util.CopyProgressListener;
import org.apache.ivy.util.Credentials;
import org.apache.ivy.util.FileUtil;
+import org.apache.ivy.util.HostUtil;
import org.apache.ivy.util.Message;
/**
@@ -66,7 +68,7 @@
private String proxyPasswd = null;
private HttpClientHelper httpClientHelper;
-
+
private static HttpClient httpClient;
public HttpClientHandler() {
@@ -74,7 +76,7 @@
}
private void configureProxy() {
- proxyRealm = null;
+ proxyRealm = System.getProperty("http.auth.ntlm.domain");
// no equivalent for realm in jdk proxy support ?
proxyHost = System.getProperty("http.proxyHost");
// TODO constant is better ...
@@ -84,8 +86,8 @@
proxyPasswd = System.getProperty("http.proxyPassword");
// It seems there is no equivalent in HttpClient for
// 'http.nonProxyHosts' property
- Message.verbose("proxy configured: host=" + proxyHost + " port=" + proxyPort
- + " user=" + proxyUserName);
+ Message.verbose("proxy configured: host=" + proxyHost + " port=" + proxyPort + " user="
+ + proxyUserName);
} else {
Message.verbose("no proxy configured");
}
@@ -95,9 +97,8 @@
GetMethod get = doGet(url, 0);
if (!checkStatusCode(url, get)) {
get.releaseConnection();
- throw new IOException(
- "The HTTP response code for " + url + " did not indicate a success."
- + " See log for more detail.");
+ throw new IOException("The HTTP response code for " + url
+ + " did not indicate a success." + " See log for more detail.");
}
return new GETInputStream(get);
}
@@ -107,9 +108,8 @@
try {
// We can only figure the content we got is want we want if the status is success.
if (!checkStatusCode(src, get)) {
- throw new IOException(
- "The HTTP response code for " + src + " did not indicate a success."
- + " See log for more detail.");
+ throw new IOException("The HTTP response code for " + src
+ + " did not indicate a success." + " See log for more detail.");
}
FileUtil.copy(get.getResponseBodyAsStream(), dest, l);
dest.setLastModified(getLastModified(get));
@@ -162,7 +162,7 @@
} catch (UnknownHostException e) {
Message.warn("Host " + e.getMessage() + " not found. url=" + url);
Message.info("You probably access the destination server through "
- + "a proxy server that is not well configured.");
+ + "a proxy server that is not well configured.");
} catch (IOException e) {
Message.error("HttpClientHandler: " + e.getMessage() + " url=" + url);
} catch (IllegalArgumentException e) {
@@ -175,7 +175,7 @@
}
return UNAVAILABLE;
}
-
+
private boolean checkStatusCode(URL url, HttpMethodBase method) throws IOException {
int status = method.getStatusCode();
if (status == HttpStatus.SC_OK) {
@@ -189,7 +189,7 @@
} else if (String.valueOf(status).startsWith("5")) {
Message.error("SERVER ERROR: " + method.getStatusText() + " url=" + url);
}
-
+
return false;
}
@@ -221,8 +221,8 @@
Message.verbose("using commons httpclient 3.x helper");
} catch (SecurityException e) {
Message.verbose("unable to get access to getResponseContentLength of "
- + "commons-httpclient HeadMethod. Please use commons-httpclient 3.0 or "
- + "use ivy with sufficient security permissions.");
+ + "commons-httpclient HeadMethod. Please use commons-httpclient 3.0 or "
+ + "use ivy with sufficient security permissions.");
Message.verbose("exception: " + e.getMessage());
httpClientHelper = new HttpClientHelper2x();
Message.verbose("using commons httpclient 2.x helper");
@@ -261,42 +261,46 @@
private HttpClient getClient(URL url) {
if (httpClient == null) {
- final MultiThreadedHttpConnectionManager connManager
- = new MultiThreadedHttpConnectionManager();
+ final MultiThreadedHttpConnectionManager connManager =
+ new MultiThreadedHttpConnectionManager();
httpClient = new HttpClient(connManager);
-
+
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
public void run() {
connManager.shutdown();
}
}));
-
- List authPrefs = new ArrayList(2);
+
+ List authPrefs = new ArrayList(3);
authPrefs.add(AuthPolicy.DIGEST);
authPrefs.add(AuthPolicy.BASIC);
- // Exclude the NTLM authentication scheme because it is not supported by this class
+ authPrefs.add(AuthPolicy.NTLM); // put it at the end to give less priority (IVY-213)
httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
-
+
if (useProxy()) {
httpClient.getHostConfiguration().setProxy(proxyHost, proxyPort);
if (useProxyAuthentication()) {
- httpClient.getState().setProxyCredentials(proxyRealm, proxyHost,
- new UsernamePasswordCredentials(proxyUserName, proxyPasswd));
+ httpClient.getState().setProxyCredentials(
+ new AuthScope(proxyHost, proxyPort, proxyRealm),
+ new NTCredentials(proxyUserName, proxyPasswd,
+ HostUtil.getLocalHostName(), proxyRealm));
}
}
-
+
// user-agent
- httpClient.getParams().setParameter(
- "http.useragent", "Apache Ivy/" + Ivy.getIvyVersion());
+ httpClient.getParams().setParameter("http.useragent",
+ "Apache Ivy/" + Ivy.getIvyVersion());
}
-
+
Credentials c = getCredentials(url);
if (c != null) {
Message.debug("found credentials for " + url + ": " + c);
- httpClient.getState().setCredentials(c.getRealm(), c.getHost(),
- new UsernamePasswordCredentials(c.getUserName(), c.getPasswd()));
+ httpClient.getState().setProxyCredentials(
+ new AuthScope(c.getHost(), AuthScope.ANY_PORT, c.getRealm()),
+ new NTCredentials(c.getUserName(), c.getPasswd(),
+ HostUtil.getLocalHostName(), c.getRealm()));
}
-
+
return httpClient;
}
@@ -315,7 +319,7 @@
private boolean useProxyAuthentication() {
return (proxyUserName != null && proxyUserName.trim().length() > 0);
}
-
+
private static final class GETInputStream extends InputStream {
private InputStream is;
Modified: ant/ivy/core/branches/2.1.x/test/java/org/apache/ivy/ant/IvyDeliverTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.1.x/test/java/org/apache/ivy/ant/IvyDeliverTest.java?rev=791026&r1=791025&r2=791026&view=diff
==============================================================================
--- ant/ivy/core/branches/2.1.x/test/java/org/apache/ivy/ant/IvyDeliverTest.java (original)
+++ ant/ivy/core/branches/2.1.x/test/java/org/apache/ivy/ant/IvyDeliverTest.java Fri Jul 3 21:41:32 2009
@@ -255,7 +255,7 @@
settings.setProject(project);
settings.execute();
// change the default branch to use
- IvyAntSettings.getDefaultInstance(project).getConfiguredIvyInstance().getSettings().setDefaultBranch("BRANCH1");
+ IvyAntSettings.getDefaultInstance(settings).getConfiguredIvyInstance(settings).getSettings().setDefaultBranch("BRANCH1");
// resolve a module dependencies
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-latest.xml");