Author: maartenc
Date: Fri Nov 30 12:38:22 2007
New Revision: 599950
URL: http://svn.apache.org/viewvc?rev=599950&view=rev
Log:
FIX: m2 incompatibility - IVY does not recognize property section (IVY-637)
FIX: m2 incompatibility - IVY does not recognize parent pom (IVY-636)
Modified:
incubator/ivy/core/trunk/CHANGES.txt
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/ParserSettings.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResourceResolver.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MockResolver.java
incubator/ivy/core/trunk/test/java/org/apache/ivy/util/url/ApacheURLListerTest.java
Modified: incubator/ivy/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/CHANGES.txt?rev=599950&r1=599949&r2=599950&view=diff
==============================================================================
--- incubator/ivy/core/trunk/CHANGES.txt (original)
+++ incubator/ivy/core/trunk/CHANGES.txt Fri Nov 30 12:38:22 2007
@@ -55,6 +55,8 @@
version in SVN
=====================================
+- FIX: m2 incompatibility - IVY does not recognize property section (IVY-637)
+- FIX: m2 incompatibility - IVY does not recognize parent pom (IVY-636)
- FIX: Attempt to download a file with & in its name causes SAXParseException
in Ivy (IVY-635)
- FIX: Bad IvyContext scope causing memory leak and bad handling of subproject
builds (IVY-639)
- FIX: Resolution failure when no ivy.xml file present (IVY-630)
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/ParserSettings.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/ParserSettings.java?rev=599950&r1=599949&r2=599950&view=diff
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/ParserSettings.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/ParserSettings.java
Fri Nov 30 12:38:22 2007
@@ -18,10 +18,12 @@
package org.apache.ivy.plugins.parser;
import org.apache.ivy.core.RelativeUrlResolver;
+import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.status.StatusManager;
import org.apache.ivy.plugins.conflict.ConflictManager;
import org.apache.ivy.plugins.matcher.PatternMatcher;
import org.apache.ivy.plugins.namespace.Namespace;
+import org.apache.ivy.plugins.resolver.DependencyResolver;
public interface ParserSettings {
@@ -36,5 +38,7 @@
StatusManager getStatusManager();
RelativeUrlResolver getRelativeUrlResolver();
+
+ DependencyResolver getResolver(ModuleId mRevId);
}
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java?rev=599950&r1=599949&r2=599950&view=diff
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
Fri Nov 30 12:38:22 2007
@@ -28,21 +28,27 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.Stack;
import javax.xml.parsers.ParserConfigurationException;
+import org.apache.ivy.core.IvyContext;
import org.apache.ivy.core.IvyPatternHelper;
import org.apache.ivy.core.module.descriptor.Configuration;
import org.apache.ivy.core.module.descriptor.DefaultArtifact;
import
org.apache.ivy.core.module.descriptor.DefaultDependencyArtifactDescriptor;
import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
import org.apache.ivy.core.module.descriptor.DefaultExcludeRule;
+import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.descriptor.Configuration.Visibility;
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.resolve.ResolveData;
+import org.apache.ivy.core.resolve.ResolveEngine;
+import org.apache.ivy.core.resolve.ResolveOptions;
import org.apache.ivy.plugins.matcher.ExactPatternMatcher;
import org.apache.ivy.plugins.matcher.PatternMatcher;
import org.apache.ivy.plugins.parser.AbstractModuleDescriptorParser;
@@ -50,6 +56,8 @@
import org.apache.ivy.plugins.parser.ParserSettings;
import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorWriter;
import org.apache.ivy.plugins.repository.Resource;
+import org.apache.ivy.plugins.resolver.DependencyResolver;
+import org.apache.ivy.plugins.resolver.util.ResolvedResource;
import org.apache.ivy.util.Message;
import org.apache.ivy.util.XMLHelper;
import org.xml.sax.Attributes;
@@ -126,6 +134,8 @@
private static final class Parser extends AbstractParser {
private static final String JAR_EXTENSION = "jar";
+
+ private ParserSettings settings;
private Stack contextStack = new Stack();
@@ -159,9 +169,10 @@
private String relocationRevision;
- public Parser(ModuleDescriptorParser parser, Resource res) {
+ public Parser(ModuleDescriptorParser parser, Resource res,
ParserSettings settings) {
super(parser);
setResource(res);
+ this.settings = settings;
md.setResolvedPublicationDate(new Date(res.getLastModified()));
for (int i = 0; i < MAVEN2_CONFIGURATIONS.length; i++) {
md.addConfiguration(MAVEN2_CONFIGURATIONS[i]);
@@ -229,6 +240,10 @@
fillMrid();
} else if ("project/parent/version".equals(context)) {
properties.put("parent.version", revision);
+ } else if ("project/parent/groupId".equals(context)) {
+ properties.put("parent.groupId", organisation);
+ } else if (context.equals("project/parent")) {
+ parseParentPom();
} else if (((organisation != null && module != null && revision !=
null) || dd != null)
&& "project/dependencies/dependency".equals(context)) {
if (dd == null) {
@@ -338,11 +353,14 @@
revision = txt;
return;
}
+ if (context.equals("project/parent/artifactId")) {
+ properties.put("parent.artifactId", txt);
+ }
if (context.equals("project/parent/packaging") && type ==
null) {
type = txt;
ext = txt;
return;
- }
+ }
if
(context.equals("project/distributionManagement/relocation/groupId")) {
relocationOrganisation= txt;
return;
@@ -358,6 +376,10 @@
if (context.startsWith("project/parent")) {
return;
}
+ if (context.startsWith("project/properties")) {
+ String key =
context.substring("project/properties/".length());
+ properties.put(key, txt);
+ }
if (md.getModuleRevisionId() == null
||
context.startsWith("project/dependencies/dependency")) {
if (context.equals("project/groupId")) {
@@ -408,6 +430,78 @@
}
return md;
}
+
+ public void parseParentPom() throws SAXException {
+ String parentOrg = (String) properties.get("parent.groupId");
+ String parentName = (String) properties.get("parent.artifactId");
+ String parentVersion = (String) properties.get("parent.version");
+
+ if (parentOrg != null && parentName != null && parentVersion !=
null) {
+ ModuleRevisionId parent =
ModuleRevisionId.newInstance(parentOrg, parentName,
+ parentVersion);
+ DependencyResolver resolver =
settings.getResolver(parent.getModuleId());
+
+ DependencyDescriptor dd = new
DefaultDependencyDescriptor(parent, true);
+ ResolveData data = IvyContext.getContext().getResolveData();
+ if (data == null) {
+ return;
+// TODO: maybe do something like this:
+// ResolveEngine engine =
IvyContext.getContext().getIvy().getResolveEngine();
+// ResolveOptions options = new ResolveOptions();
+//
options.setCache(IvyContext.getContext().getCacheManager());
+// options.setDownload(false);
+// data = new ResolveData(engine, options);
+ }
+
+ ResolvedResource rr = resolver.findIvyFileRef(dd, data);
+
+ if (rr == null) {
+ // parent not found. Maybe we should throw an exception
here?
+ return;
+ }
+
+ Parser parser = new Parser(getModuleDescriptorParser(),
rr.getResource(), settings);
+ InputStream pomStream = null;
+ try {
+ pomStream = rr.getResource().openStream();
+ XMLHelper.parse(pomStream, null, parser, null);
+ } catch (IOException e) {
+ throw new SAXException("Error occurred while parsing
parent", e);
+ } catch (ParserConfigurationException e) {
+ throw new SAXException("Error occurred while parsing
parent", e);
+ } finally {
+ if (pomStream != null) {
+ try {
+ pomStream.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+
+ // move the parent properties into ours
+ Map parentProps = parser.properties;
+ Set keys = parentProps.keySet();
+ for ( Iterator iter = keys.iterator(); iter.hasNext(); ) {
+ String key = iter.next().toString();
+ if ( key.startsWith("pom")) {
+ // don't see a need to copy pom values from parent...
+ // ignore
+ } else if ( key.startsWith("parent")) {
+ // don't see a need to copy parent values from
parent...
+ // ignore
+ } else {
+ // the key may need the groupId substituted
+ String _key =
IvyPatternHelper.substituteVariables(key,
+ parentProps).trim();
+ String _value =
IvyPatternHelper.substituteVariables(parentProps.get(key).toString(),
+ parentProps).trim();
+ properties.put(_key, _value);
+ }
+ }
+
+ }
+ }
}
private static final PomModuleDescriptorParser INSTANCE = new
PomModuleDescriptorParser();
@@ -417,12 +511,11 @@
}
private PomModuleDescriptorParser() {
-
}
public ModuleDescriptor parseDescriptor(ParserSettings settings, URL
descriptorURL, Resource res,
boolean validate) throws ParseException, IOException {
- Parser parser = new Parser(this, res);
+ Parser parser = new Parser(this, res, settings);
try {
XMLHelper.parse(descriptorURL, null, parser);
} catch (SAXException ex) {
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResourceResolver.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResourceResolver.java?rev=599950&r1=599949&r2=599950&view=diff
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResourceResolver.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResourceResolver.java
Fri Nov 30 12:38:22 2007
@@ -67,7 +67,7 @@
public AbstractResourceResolver() {
}
- protected ResolvedResource findIvyFileRef(DependencyDescriptor dd,
ResolveData data) {
+ public ResolvedResource findIvyFileRef(DependencyDescriptor dd,
ResolveData data) {
ModuleRevisionId mrid = dd.getDependencyRevisionId();
if (isM2compatible()) {
mrid = convertM2IdForResourceSearch(mrid);
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java?rev=599950&r1=599949&r2=599950&view=diff
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
Fri Nov 30 12:38:22 2007
@@ -907,8 +907,6 @@
protected abstract Collection findNames(Map tokenValues, String token);
- protected abstract ResolvedResource findIvyFileRef(DependencyDescriptor
dd, ResolveData data);
-
protected ResolvedResource findFirstArtifactRef(ModuleDescriptor md,
DependencyDescriptor dd,
ResolveData data) {
ResolvedResource ret = null;
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java?rev=599950&r1=599949&r2=599950&view=diff
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
Fri Nov 30 12:38:22 2007
@@ -39,6 +39,7 @@
import org.apache.ivy.plugins.latest.LatestStrategy;
import org.apache.ivy.plugins.resolver.util.HasLatestStrategy;
import org.apache.ivy.plugins.resolver.util.ResolvedModuleRevisionProxy;
+import org.apache.ivy.plugins.resolver.util.ResolvedResource;
import org.apache.ivy.util.Message;
/**
@@ -187,6 +188,18 @@
return getLatestStrategy().findLatest(ais, date) != ais[0];
}
+ public ResolvedResource findIvyFileRef(DependencyDescriptor dd,
ResolveData data) {
+ for (Iterator iter = chain.iterator(); iter.hasNext();) {
+ DependencyResolver resolver = (DependencyResolver) iter.next();
+ ResolvedResource result = resolver.findIvyFileRef(dd, data);
+ if (result != null) {
+ return result;
+ }
+ }
+
+ return null;
+ }
+
public void reportFailure() {
for (Iterator iter = chain.iterator(); iter.hasNext();) {
DependencyResolver resolver = (DependencyResolver) iter.next();
@@ -312,5 +325,6 @@
public boolean isDual() {
return dual;
}
+
}
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java?rev=599950&r1=599949&r2=599950&view=diff
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DependencyResolver.java
Fri Nov 30 12:38:22 2007
@@ -32,6 +32,7 @@
import org.apache.ivy.core.search.ModuleEntry;
import org.apache.ivy.core.search.OrganisationEntry;
import org.apache.ivy.core.search.RevisionEntry;
+import org.apache.ivy.plugins.resolver.util.ResolvedResource;
/**
*
@@ -57,6 +58,16 @@
*/
ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData
data)
throws ParseException;
+
+ /**
+ * Finds the module descriptor for the specified
<tt>DependencyDescriptor</tt>.
+ * If this resolver can't find the module descriptor, <tt>null</tt> is
returned.
+ *
+ * @param dd the dependency descriptor
+ * @param data the resolve data
+ * @return the module descriptor, or <tt>null</tt>
+ */
+ ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data);
DownloadReport download(Artifact[] artifacts, DownloadOptions options);
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java?rev=599950&r1=599949&r2=599950&view=diff
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
Fri Nov 30 12:38:22 2007
@@ -29,6 +29,7 @@
import org.apache.ivy.core.resolve.ResolveData;
import org.apache.ivy.core.resolve.ResolvedModuleRevision;
import org.apache.ivy.plugins.resolver.util.ResolvedModuleRevisionProxy;
+import org.apache.ivy.plugins.resolver.util.ResolvedResource;
import org.apache.ivy.util.Message;
/**
@@ -81,6 +82,10 @@
}
}
+ public ResolvedResource findIvyFileRef(DependencyDescriptor dd,
ResolveData data) {
+ return ivyResolver.findIvyFileRef(dd, data);
+ }
+
public void reportFailure() {
ivyResolver.reportFailure();
artifactResolver.reportFailure();
@@ -157,4 +162,5 @@
public void setAllownomd(boolean allownomd) {
this.allownomd = allownomd;
}
+
}
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java?rev=599950&r1=599949&r2=599950&view=diff
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
Fri Nov 30 12:38:22 2007
@@ -61,7 +61,7 @@
public IBiblioResolver() {
}
- protected ResolvedResource findIvyFileRef(DependencyDescriptor dd,
ResolveData data) {
+ public ResolvedResource findIvyFileRef(DependencyDescriptor dd,
ResolveData data) {
if (isM2compatible() && isUsepoms()) {
ModuleRevisionId mrid = dd.getDependencyRevisionId();
mrid = convertM2IdForResourceSearch(mrid);
Modified:
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MockResolver.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MockResolver.java?rev=599950&r1=599949&r2=599950&view=diff
==============================================================================
---
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MockResolver.java
(original)
+++
incubator/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MockResolver.java
Fri Nov 30 12:38:22 2007
@@ -34,6 +34,7 @@
import org.apache.ivy.core.resolve.DownloadOptions;
import org.apache.ivy.core.resolve.ResolveData;
import org.apache.ivy.core.resolve.ResolvedModuleRevision;
+import org.apache.ivy.plugins.resolver.util.ResolvedResource;
public class MockResolver extends AbstractResolver {
static MockResolver buildMockResolver(String name, boolean findRevision,
@@ -104,6 +105,10 @@
}
public void publish(Artifact artifact, File src, boolean overwrite) throws
IOException {
+ }
+
+ public ResolvedResource findIvyFileRef(DependencyDescriptor dd,
ResolveData data) {
+ return null;
}
}
Modified:
incubator/ivy/core/trunk/test/java/org/apache/ivy/util/url/ApacheURLListerTest.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/test/java/org/apache/ivy/util/url/ApacheURLListerTest.java?rev=599950&r1=599949&r2=599950&view=diff
==============================================================================
---
incubator/ivy/core/trunk/test/java/org/apache/ivy/util/url/ApacheURLListerTest.java
(original)
+++
incubator/ivy/core/trunk/test/java/org/apache/ivy/util/url/ApacheURLListerTest.java
Fri Nov 30 12:38:22 2007
@@ -21,6 +21,8 @@
import java.util.Iterator;
import java.util.List;
+import org.apache.ivy.plugins.urllister.ApacheURLLister;
+
import junit.framework.TestCase;
/**