You are viewing a plain text version of this content. The canonical link for it is here.
Posted to easyant-commits@incubator.apache.org by jl...@apache.org on 2012/11/23 08:05:33 UTC
svn commit: r1412769 - in /incubator/easyant/core/trunk: ./
src/main/java/org/apache/easyant/core/
src/main/java/org/apache/easyant/core/parser/
src/main/java/org/apache/easyant/tasks/
src/main/java/org/apache/ivy/core/cache/
Author: jlboudart
Date: Fri Nov 23 08:05:31 2012
New Revision: 1412769
URL: http://svn.apache.org/viewvc?rev=1412769&view=rev
Log:
Upgrade ivy to 2.3.0rc2
fix ***** issue that was bloking publication when no location attribute was set on extend tag
hack RepositoryCacheManger and ResolutionCacheManger: they use XmlModuleDescriptor under the hood, so parent and specific easyant tags was not read correctly from cache
Modified:
incubator/easyant/core/trunk/build.xml
incubator/easyant/core/trunk/module.ivy
incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java
incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/parser/DefaultEasyAntXmlModuleDescriptorParser.java
incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java
incubator/easyant/core/trunk/src/main/java/org/apache/ivy/core/cache/EasyAntRepositoryCacheManager.java
Modified: incubator/easyant/core/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/build.xml?rev=1412769&r1=1412768&r2=1412769&view=diff
==============================================================================
--- incubator/easyant/core/trunk/build.xml (original)
+++ incubator/easyant/core/trunk/build.xml Fri Nov 23 08:05:31 2012
@@ -19,7 +19,7 @@
<target name="ivy:init">
<mkdir dir="${bootstrap.dir}"/>
- <property name="ivy.version" value="2.3.0-rc1"/>
+ <property name="ivy.version" value="2.3.0-rc2"/>
<property name="ivy.jar.url" value="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"/>
<get src="${ivy.jar.url}" dest="${bootstrap.dir}/ivy.jar" usetimestamp="true"/>
<path id="ivy.lib.path">
Modified: incubator/easyant/core/trunk/module.ivy
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/module.ivy?rev=1412769&r1=1412768&r2=1412769&view=diff
==============================================================================
--- incubator/easyant/core/trunk/module.ivy (original)
+++ incubator/easyant/core/trunk/module.ivy Fri Nov 23 08:05:31 2012
@@ -30,7 +30,7 @@
<dependency org="org.apache.ant" name="ant-testutil" rev="1.8.4" conf="test->default" transitive="false" />
<dependency org="org.apache.ant" name="ant" rev="1.8.4" conf="default->default"/>
- <dependency org="org.apache.ivy" name="ivy" rev="2.3.0-rc1" conf="default->default"/>
+ <dependency org="org.apache.ivy" name="ivy" rev="2.3.0-rc2" conf="default->default"/>
<dependency org="ant-contrib" name="ant-contrib" rev="1.0b2" conf="default->default"/>
<dependency org="commons-cli" name="commons-cli" rev="1.2" conf="default->default"/>
<!-- ivy uses a different namespace to reference ant -->
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java?rev=1412769&r1=1412768&r2=1412769&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/EasyAntEngine.java Fri Nov 23 08:05:31 2012
@@ -43,6 +43,7 @@ import org.apache.ivy.Ivy;
import org.apache.ivy.ant.IvyAntSettings;
import org.apache.ivy.ant.IvyConfigure;
import org.apache.ivy.core.cache.EasyAntRepositoryCacheManager;
+import org.apache.ivy.core.cache.EasyantResolutionCacheManager;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.BuildLogger;
@@ -134,12 +135,18 @@ public class EasyAntEngine {
IvyAntSettings easyantIvySettings = IvyInstanceHelper.getEasyAntIvyAntSettings(project);
+ // FIXME: hack as ResolutionCacheManager and RepositoryCacheManger use XmlModuleDescriptorParser under the hood
Ivy easyantIvyInstance = easyantIvySettings.getConfiguredIvyInstance(easyantIvyConfigure);
EasyAntRepositoryCacheManager cacheManager = new EasyAntRepositoryCacheManager("default-easyant-cache",
easyantIvyInstance.getSettings(), easyantIvyInstance.getSettings().getDefaultCache());
easyantIvyInstance.getSettings().setDefaultRepositoryCacheManager(cacheManager);
+ EasyantResolutionCacheManager resolutionCacheManager = new EasyantResolutionCacheManager();
+ resolutionCacheManager.setBasedir(easyantIvyInstance.getSettings().getDefaultResolutionCacheBasedir());
+ resolutionCacheManager.setSettings(easyantIvyInstance.getSettings());
+ easyantIvyInstance.getSettings().setResolutionCacheManager(resolutionCacheManager);
+
return easyantIvySettings;
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/parser/DefaultEasyAntXmlModuleDescriptorParser.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/parser/DefaultEasyAntXmlModuleDescriptorParser.java?rev=1412769&r1=1412768&r2=1412769&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/parser/DefaultEasyAntXmlModuleDescriptorParser.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/core/parser/DefaultEasyAntXmlModuleDescriptorParser.java Fri Nov 23 08:05:31 2012
@@ -19,12 +19,15 @@ package org.apache.easyant.core.parser;
import java.io.File;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
@@ -38,6 +41,7 @@ import org.apache.easyant.core.descripto
import org.apache.easyant.core.descriptor.PluginType;
import org.apache.easyant.core.descriptor.PropertyDescriptor;
import org.apache.easyant.core.ivy.InheritableScope;
+import org.apache.ivy.Ivy;
import org.apache.ivy.ant.IvyConflict;
import org.apache.ivy.ant.IvyDependency;
import org.apache.ivy.ant.IvyDependencyArtifact;
@@ -47,11 +51,17 @@ import org.apache.ivy.ant.IvyDependencyI
import org.apache.ivy.ant.IvyExclude;
import org.apache.ivy.core.IvyContext;
import org.apache.ivy.core.module.descriptor.Configuration;
+import org.apache.ivy.core.module.descriptor.DefaultExtendsDescriptor;
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.plugins.parser.ModuleDescriptorParser;
+import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
import org.apache.ivy.plugins.parser.ParserSettings;
import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser;
import org.apache.ivy.plugins.repository.Resource;
+import org.apache.ivy.plugins.repository.file.FileResource;
+import org.apache.ivy.util.FileUtil;
import org.apache.ivy.util.Message;
import org.apache.ivy.util.PropertiesFile;
import org.xml.sax.Attributes;
@@ -713,5 +723,112 @@ public class DefaultEasyAntXmlModuleDesc
protected String getDefaultParentLocation() {
return "../parent.ivy";
}
+
+ /**
+ * TODO: Fix for IVY-1391, should be removed on next ivy upgrade
+ */
+ /**
+ * Handle extends elements. It checks :
+ * <ul>
+ * <li>filesystem based on location attribute, if no one is specified it will check the default parent location</li>
+ * <li>cache to find a resolved parent descriptor</li>
+ * <li>ask repositories to retrieve the parent module descriptor</li>
+ * </ul>
+ *
+ * @param attributes
+ * @throws ParseException
+ */
+ protected void extendsStarted(Attributes attributes) throws ParseException {
+ String parentOrganisation = getSettings().substitute(attributes.getValue("organisation"));
+ String parentModule = getSettings().substitute(attributes.getValue("module"));
+ String parentRevision = attributes.getValue("revision") != null ? getSettings().substitute(
+ attributes.getValue("revision")) : Ivy.getWorkingRevision();
+ String location = attributes.getValue("location") != null ? getSettings().substitute(
+ attributes.getValue("location")) : getDefaultParentLocation();
+ ModuleDescriptor parent = null;
+
+ String extendType = attributes.getValue("extendType") != null ? getSettings().substitute(
+ attributes.getValue("extendType").toLowerCase(Locale.US)) : "all";
+
+ List<String> extendTypes = Arrays.asList(extendType.split(","));
+ ModuleId parentMid = new ModuleId(parentOrganisation, parentModule);
+ ModuleRevisionId parentMrid = new ModuleRevisionId(parentMid, parentRevision);
+
+ // check on filesystem based on location attribute (for dev ONLY)
+ boolean local = false;
+ try {
+ parent = parseParentModuleOnFilesystem(location);
+ if (parent != null) {
+ ModuleId foundMid = parent.getResolvedModuleRevisionId().getModuleId();
+ if (!foundMid.equals(parentMid)) {
+ // the filesystem contains a parent module with different organisation
+ // or module name; ignore that parent module
+ Message.info("Found a parent module with unexpected ModuleRevisionId at source location "
+ + location + "! Expected: " + parentMid + ". Found: " + foundMid
+ + ". This parent module will be ignored.");
+ parent = null;
+ }
+ }
+
+ local = parent != null;
+ } catch (IOException e) {
+ Message.warn("Unable to parse included ivy file " + location, e);
+ }
+
+ // if not found, tries to resolve using repositories
+ if (parent == null) {
+ try {
+ parent = parseOtherIvyFile(parentMrid);
+ } catch (ParseException e) {
+ Message.warn("Unable to parse included ivy file for " + parentMrid.toString(), e);
+ }
+ }
+
+ // if still not found throw an exception
+ if (parent == null) {
+ throw new ParseException("Unable to parse included ivy file for " + parentMrid.toString(), 0);
+ }
+
+ DefaultExtendsDescriptor ed = new DefaultExtendsDescriptor(parent, location,
+ (String[]) extendTypes.toArray(new String[extendTypes.size()]), local);
+ getMd().addInheritedDescriptor(ed);
+
+ mergeWithOtherModuleDescriptor(extendTypes, parent);
+ }
+
+ /**
+ * Returns the parent module using the location attribute (for dev purpose).
+ *
+ * @param location
+ * a given location
+ * @throws IOException
+ * @throws ParseException
+ */
+ private ModuleDescriptor parseParentModuleOnFilesystem(String location) throws IOException, ParseException {
+ if (!"file".equals(getDescriptorURL().getProtocol())) {
+ return null;
+ }
+
+ File file = new File(location);
+ if (!file.isAbsolute()) {
+ URL url = getSettings().getRelativeUrlResolver().getURL(getDescriptorURL(), location);
+ try {
+ file = new File(new URI(url.toExternalForm()));
+ } catch (URISyntaxException e) {
+ file = new File(url.getPath());
+ }
+ }
+
+ file = FileUtil.normalize(file.getAbsolutePath());
+ if (!file.exists()) {
+ Message.verbose("Parent module doesn't exist on the filesystem: " + file.getAbsolutePath());
+ return null;
+ }
+
+ FileResource res = new FileResource(null, file);
+ ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(res);
+ return parser.parseDescriptor(getSettings(), file.toURI().toURL(), res, isValidate());
+ }
+
}
}
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java?rev=1412769&r1=1412768&r2=1412769&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/easyant/tasks/LoadModule.java Fri Nov 23 08:05:31 2012
@@ -41,6 +41,8 @@ import org.apache.ivy.ant.IvyAntSettings
import org.apache.ivy.ant.IvyConfigure;
import org.apache.ivy.ant.IvyInfo;
import org.apache.ivy.core.IvyContext;
+import org.apache.ivy.core.cache.EasyAntRepositoryCacheManager;
+import org.apache.ivy.core.cache.EasyantResolutionCacheManager;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.plugins.parser.ModuleDescriptorParser;
import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
@@ -240,7 +242,19 @@ public class LoadModule extends Abstract
}
}
}
+
initTask(projectIvyInstance).execute();
+
+ // FIXME: hack as ResolutionCacheManager use XmlModuleDescriptorParser under the hood
+ EasyAntRepositoryCacheManager cacheManager = new EasyAntRepositoryCacheManager("default-project-cache",
+ getProjectIvyInstance().getSettings(), getProjectIvyInstance().getSettings().getDefaultCache());
+ getProjectIvyInstance().getSettings().setDefaultRepositoryCacheManager(cacheManager);
+
+ EasyantResolutionCacheManager resolutionCacheManager = new EasyantResolutionCacheManager();
+ resolutionCacheManager.setBasedir(getProjectIvyInstance().getSettings().getDefaultResolutionCacheBasedir());
+ resolutionCacheManager.setSettings(getProjectIvyInstance().getSettings());
+ getProjectIvyInstance().getSettings().setResolutionCacheManager(resolutionCacheManager);
+
}
protected void loadBuildFile(File buildModule) {
Modified: incubator/easyant/core/trunk/src/main/java/org/apache/ivy/core/cache/EasyAntRepositoryCacheManager.java
URL: http://svn.apache.org/viewvc/incubator/easyant/core/trunk/src/main/java/org/apache/ivy/core/cache/EasyAntRepositoryCacheManager.java?rev=1412769&r1=1412768&r2=1412769&view=diff
==============================================================================
--- incubator/easyant/core/trunk/src/main/java/org/apache/ivy/core/cache/EasyAntRepositoryCacheManager.java (original)
+++ incubator/easyant/core/trunk/src/main/java/org/apache/ivy/core/cache/EasyAntRepositoryCacheManager.java Fri Nov 23 08:05:31 2012
@@ -27,7 +27,6 @@ import java.util.Date;
import java.util.Map;
import java.util.regex.Pattern;
-import org.apache.easyant.core.parser.DefaultEasyAntXmlModuleDescriptorParser;
import org.apache.ivy.Ivy;
import org.apache.ivy.core.IvyPatternHelper;
import org.apache.ivy.core.module.descriptor.Artifact;
@@ -58,6 +57,7 @@ import org.apache.ivy.plugins.repository
import org.apache.ivy.plugins.repository.Resource;
import org.apache.ivy.plugins.repository.ResourceDownloader;
import org.apache.ivy.plugins.repository.ResourceHelper;
+import org.apache.ivy.plugins.repository.url.URLResource;
import org.apache.ivy.plugins.resolver.AbstractResolver;
import org.apache.ivy.plugins.resolver.DependencyResolver;
import org.apache.ivy.plugins.resolver.util.ResolvedResource;
@@ -621,8 +621,8 @@ public class EasyAntRepositoryCacheManag
if (ivyFile.exists()) {
// found in cache !
try {
- DefaultEasyAntXmlModuleDescriptorParser parser = DefaultEasyAntXmlModuleDescriptorParser
- .getInstance();
+ ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(
+ new URLResource(ivyFile.toURI().toURL()));
ModuleDescriptor depMD = getMdFromCache(parser, options, ivyFile);
String resolverName = getSavedResolverName(depMD);
String artResolverName = getSavedArtResolverName(depMD);
@@ -693,8 +693,8 @@ public class EasyAntRepositoryCacheManag
}
}
- private ModuleDescriptor getMdFromCache(XmlModuleDescriptorParser mdParser, CacheMetadataOptions options,
- File ivyFile) throws ParseException, IOException {
+ private ModuleDescriptor getMdFromCache(ModuleDescriptorParser mdParser, CacheMetadataOptions options, File ivyFile)
+ throws ParseException, IOException {
ModuleDescriptorMemoryCache cache = getMemoryCache();
ModuleDescriptorProvider mdProvider = new MyModuleDescriptorProvider(mdParser, settings);
return cache.get(ivyFile, settings, options.isValidate(), mdProvider);