You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-commits@incubator.apache.org by xa...@apache.org on 2007/01/31 11:00:37 UTC
svn commit: r501796 [3/10] - in /incubator/ivy/core/trunk:
src/java/org/apache/ivy/ src/java/org/apache/ivy/ant/
src/java/org/apache/ivy/core/ src/java/org/apache/ivy/core/cache/
src/java/org/apache/ivy/core/event/ src/java/org/apache/ivy/core/event/do...
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/Main.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/Main.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/Main.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/Main.java Wed Jan 31 03:00:29 2007
@@ -206,10 +206,10 @@
boolean validate = line.hasOption("novalidate")?false:true;
- Ivy ivy = new Ivy();
- ivy.addAllVariables(System.getProperties());
+ Ivy ivy = Ivy.newInstance();
+ ivy.getSettings().addAllVariables(System.getProperties());
if (line.hasOption("m2compatible")) {
- ivy.setVariable("ivy.default.configuration.m2compatible", "true");
+ ivy.getSettings().setVariable("ivy.default.configuration.m2compatible", "true");
}
configureURLHandler(
@@ -220,7 +220,7 @@
String confPath = line.getOptionValue("conf", "");
if ("".equals(confPath)) {
- ivy.configureDefault();
+ ivy.getSettings().loadDefault();
} else {
File conffile = new File(confPath);
if (!conffile.exists()) {
@@ -231,7 +231,7 @@
ivy.configure(conffile);
}
- File cache = new File(ivy.substitute(line.getOptionValue("cache", ivy.getDefaultCache().getAbsolutePath())));
+ File cache = new File(ivy.getSettings().substitute(line.getOptionValue("cache", ivy.getSettings().getDefaultCache().getAbsolutePath())));
if (!cache.exists()) {
cache.mkdirs();
} else if (!cache.isDirectory()) {
@@ -262,7 +262,7 @@
XmlModuleDescriptorWriter.write(md, ivyfile);
confs = new String[] {"default"};
} else {
- ivyfile = new File(ivy.substitute(line.getOptionValue("ivy", "ivy.xml")));
+ ivyfile = new File(ivy.getSettings().substitute(line.getOptionValue("ivy", "ivy.xml")));
if (!ivyfile.exists()) {
error(options, "ivy file not found: "+ivyfile);
} else if (ivyfile.isDirectory()) {
@@ -292,7 +292,7 @@
confs = md.getConfigurationsNames();
}
if (line.hasOption("retrieve")) {
- String retrievePattern = ivy.substitute(line.getOptionValue("retrieve"));
+ String retrievePattern = ivy.getSettings().substitute(line.getOptionValue("retrieve"));
if (retrievePattern.indexOf("[") == -1) {
retrievePattern = retrievePattern + "/lib/[conf]/[artifact].[ext]";
}
@@ -305,21 +305,21 @@
if (line.hasOption("revision")) {
ivy.deliver(
md.getResolvedModuleRevisionId(),
- ivy.substitute(line.getOptionValue("revision")),
+ ivy.getSettings().substitute(line.getOptionValue("revision")),
cache,
- ivy.substitute(line.getOptionValue("deliverto", "ivy-[revision].xml")),
- ivy.substitute(line.getOptionValue("status", "release")),
+ ivy.getSettings().substitute(line.getOptionValue("deliverto", "ivy-[revision].xml")),
+ ivy.getSettings().substitute(line.getOptionValue("status", "release")),
null,
new DefaultPublishingDRResolver(),
validate);
if (line.hasOption("publish")) {
ivy.publish(
md.getResolvedModuleRevisionId(),
- ivy.substitute(line.getOptionValue("revision")),
+ ivy.getSettings().substitute(line.getOptionValue("revision")),
cache,
- ivy.substitute(line.getOptionValue("publishpattern", "distrib/[type]s/[artifact]-[revision].[ext]")),
+ ivy.getSettings().substitute(line.getOptionValue("publishpattern", "distrib/[type]s/[artifact]-[revision].[ext]")),
line.getOptionValue("publish"),
- ivy.substitute(line.getOptionValue("deliverto", "ivy-[revision].xml")),
+ ivy.getSettings().substitute(line.getOptionValue("deliverto", "ivy-[revision].xml")),
validate);
}
@@ -348,7 +348,7 @@
}
for (Iterator iter = all.iterator(); iter.hasNext();) {
Artifact artifact = (Artifact)iter.next();
- buf.append(ivy.getArchiveFileInCache(cache, artifact).getCanonicalPath());
+ buf.append(ivy.getCacheManager(cache).getArchiveFileInCache(artifact).getCanonicalPath());
if (iter.hasNext()) {
buf.append(pathSeparator);
}
@@ -376,7 +376,7 @@
for (Iterator iter = all.iterator(); iter.hasNext();) {
Artifact artifact = (Artifact)iter.next();
- urls.add(ivy.getArchiveFileInCache(cache, artifact).toURL());
+ urls.add(ivy.getCacheManager(cache).getArchiveFileInCache(artifact).toURL());
}
} catch (Exception ex) {
throw new RuntimeException("impossible to build ivy cache path: "+ex.getMessage(), ex);
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactProperty.java Wed Jan 31 03:00:29 2007
@@ -19,10 +19,10 @@
import java.io.File;
-import org.apache.ivy.Ivy;
import org.apache.ivy.core.IvyPatternHelper;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.report.XmlReportParser;
import org.apache.tools.ant.BuildException;
@@ -86,24 +86,24 @@
}
public void execute() throws BuildException {
- Ivy ivy = getIvyInstance();
+ IvySettings settings = getSettings();
- _organisation = getProperty(_organisation, ivy, "ivy.organisation");
- _module = getProperty(_module, ivy, "ivy.module");
+ _organisation = getProperty(_organisation, settings, "ivy.organisation");
+ _module = getProperty(_module, settings, "ivy.module");
ensureResolved(isHaltonfailure(), false, getOrganisation(), getModule());
- _conf = getProperty(_conf, ivy, "ivy.resolved.configurations");
+ _conf = getProperty(_conf, settings, "ivy.resolved.configurations");
if ("*".equals(_conf)) {
- _conf = getProperty(ivy, "ivy.resolved.configurations");
+ _conf = getProperty(settings, "ivy.resolved.configurations");
if (_conf == null) {
throw new BuildException("bad provided for ivy artifactproperty: * can only be used with a prior call to <resolve/>");
}
}
- _organisation = getProperty(_organisation, ivy, "ivy.organisation");
- _module = getProperty(_module, ivy, "ivy.module");
+ _organisation = getProperty(_organisation, settings, "ivy.organisation");
+ _module = getProperty(_module, settings, "ivy.module");
if (_cache == null) {
- _cache = ivy.getDefaultCache();
+ _cache = settings.getDefaultCache();
}
if (_organisation == null) {
@@ -122,8 +122,8 @@
Artifact[] artifacts = parser.getArtifacts(new ModuleId(_organisation, _module), confs[i], _cache);
for (int j = 0; j < artifacts.length; j++) {
Artifact artifact = artifacts[j];
- String name = IvyPatternHelper.substitute(ivy.substitute(getName()), artifact, confs[i]);
- String value = IvyPatternHelper.substitute(ivy.substitute(getValue()), artifact, confs[i]);
+ String name = IvyPatternHelper.substitute(settings.substitute(getName()), artifact, confs[i]);
+ String value = IvyPatternHelper.substitute(settings.substitute(getValue()), artifact, confs[i]);
getProject().setProperty(name, value);
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java Wed Jan 31 03:00:29 2007
@@ -37,10 +37,12 @@
import org.apache.ivy.Ivy;
import org.apache.ivy.core.cache.ArtifactOrigin;
+import org.apache.ivy.core.cache.CacheManager;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.resolve.IvyNode;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.xml.sax.SAXException;
@@ -94,19 +96,20 @@
}
Ivy ivy = getIvyInstance();
+ IvySettings settings = ivy.getSettings();
ensureResolved(isHaltonfailure(), false, null, null);
- String _organisation = getProperty(null, ivy, "ivy.organisation");
- String _module = getProperty(null, ivy, "ivy.module");
+ String _organisation = getProperty(null, settings, "ivy.organisation");
+ String _module = getProperty(null, settings, "ivy.module");
if (_cache == null) {
- _cache = ivy.getDefaultCache();
+ _cache = settings.getDefaultCache();
}
- _pattern = getProperty(_pattern, ivy, "ivy.retrieve.pattern");
- _conf = getProperty(_conf, ivy, "ivy.resolved.configurations");
+ _pattern = getProperty(_pattern, settings, "ivy.retrieve.pattern");
+ _conf = getProperty(_conf, settings, "ivy.resolved.configurations");
if ("*".equals(_conf)) {
- _conf = getProperty(ivy, "ivy.resolved.configurations");
+ _conf = getProperty(settings, "ivy.resolved.configurations");
if (_conf == null) {
throw new BuildException("bad provided for ivy artifact report task: * can only be used with a prior call to <resolve/>");
}
@@ -123,7 +126,7 @@
}
try {
String[] confs = splitConfs(_conf);
- IvyNode[] dependencies = ivy.getDependencies((ModuleDescriptor) getProject().getReference("ivy.resolved.descriptor"), confs, _cache, new Date(), null, doValidate(ivy));
+ IvyNode[] dependencies = ivy.getDependencies((ModuleDescriptor) getProject().getReference("ivy.resolved.descriptor"), confs, _cache, new Date(), null, doValidate(settings));
Map artifactsToCopy = ivy.determineArtifactsToCopy(new ModuleId(_organisation, _module), confs, _cache, _pattern, null);
Map moduleRevToArtifactsMap = new HashMap();
@@ -137,7 +140,8 @@
moduleRevArtifacts.add(artifact);
}
- generateXml(ivy, dependencies, moduleRevToArtifactsMap, artifactsToCopy);
+ CacheManager cache = getCacheManager();
+ generateXml(cache, dependencies, moduleRevToArtifactsMap, artifactsToCopy);
} catch (ParseException e) {
log(e.getMessage(), Project.MSG_ERR);
throw new BuildException("syntax errors in ivy file: "+e, e);
@@ -145,8 +149,7 @@
throw new BuildException("impossible to generate report: "+e, e);
}
}
-
- private void generateXml(Ivy ivy, IvyNode[] dependencies, Map moduleRevToArtifactsMap, Map artifactsToCopy) {
+ private void generateXml(CacheManager cache, IvyNode[] dependencies, Map moduleRevToArtifactsMap, Map artifactsToCopy) {
try {
FileOutputStream fileOuputStream = new FileOutputStream(_tofile);
try {
@@ -170,9 +173,9 @@
startArtifact(saxHandler, artifact);
- writeOriginLocationIfPresent(ivy, saxHandler, artifact);
+ writeOriginLocationIfPresent(cache, saxHandler, artifact);
- writeCacheLocation(ivy, saxHandler, artifact);
+ writeCacheLocation(cache, saxHandler, artifact);
Set artifactDestPaths = (Set) artifactsToCopy.get(artifact);
for (Iterator iterator = artifactDestPaths.iterator(); iterator.hasNext();) {
@@ -224,8 +227,8 @@
saxHandler.startElement(null, "artifact", "artifact", artifactAttrs);
}
- private void writeOriginLocationIfPresent(Ivy ivy, TransformerHandler saxHandler, Artifact artifact) throws IOException, SAXException {
- ArtifactOrigin origin = ivy.getSavedArtifactOrigin(_cache, artifact);
+ private void writeOriginLocationIfPresent(CacheManager cache, TransformerHandler saxHandler, Artifact artifact) throws IOException, SAXException {
+ ArtifactOrigin origin = cache.getSavedArtifactOrigin(artifact);
if (origin != null) {
String originName = origin.getLocation();
boolean isOriginLocal = origin.isLocal();
@@ -249,9 +252,9 @@
}
}
- private void writeCacheLocation(Ivy ivy, TransformerHandler saxHandler, Artifact artifact) throws SAXException {
- ArtifactOrigin origin = ivy.getSavedArtifactOrigin(_cache, artifact);
- File archiveInCacheFile = ivy.getArchiveFileInCache(_cache, artifact, origin, false);
+ private void writeCacheLocation(CacheManager cache, TransformerHandler saxHandler, Artifact artifact) throws SAXException {
+ ArtifactOrigin origin = cache.getSavedArtifactOrigin(artifact);
+ File archiveInCacheFile = cache.getArchiveFileInCache(artifact, origin, false);
StringBuffer archiveInCachePathWithSlashes = new StringBuffer(1000);
replaceFileSeparatorWithSlash(archiveInCacheFile, archiveInCachePathWithSlashes);
@@ -305,5 +308,10 @@
}
return (p.startsWith(l)) ? p.substring(l.length()) : p;
}
+
+ protected CacheManager getCacheManager() {
+ CacheManager cache = new CacheManager(getSettings(), _cache);
+ return cache;
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildList.java Wed Jan 31 03:00:29 2007
@@ -22,7 +22,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@@ -36,6 +35,7 @@
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
import org.apache.ivy.util.Message;
import org.apache.tools.ant.BuildException;
@@ -125,7 +125,9 @@
}
Ivy ivy = getIvyInstance();
- _ivyFilePath = getProperty(_ivyFilePath, ivy, "ivy.buildlist.ivyfilepath");
+ IvySettings settings = ivy.getSettings();
+
+ _ivyFilePath = getProperty(_ivyFilePath, settings, "ivy.buildlist.ivyfilepath");
Path path = new Path(getProject());
@@ -166,7 +168,7 @@
}
} else {
try {
- ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(ivy, ivyFile.toURL(), doValidate(ivy));
+ ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(settings, ivyFile.toURL(), doValidate(settings));
buildFiles.put(md, buildFile);
mdsMap.put(md.getModuleRevisionId().getModuleId().getName(), md);
} catch (Exception ex) {
@@ -195,7 +197,7 @@
mds = filterModulesFromLeaf(mds, leafModuleDescriptors);
}
- List sortedModules = ivy.sortModuleDescriptors(mds);
+ List sortedModules = ivy.sortModuleDescriptors(mds);
for (ListIterator iter = independent.listIterator(); iter.hasNext();) {
File buildFile = (File)iter.next();
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyBuildNumber.java Wed Jan 31 03:00:29 2007
@@ -21,6 +21,7 @@
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.resolve.ResolvedModuleRevision;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.tools.ant.BuildException;
@@ -102,8 +103,9 @@
}
Ivy ivy = getIvyInstance();
+ IvySettings settings = ivy.getSettings();
if (_branch == null) {
- ivy.getDefaultBranch(new ModuleId(_organisation, _module));
+ settings.getDefaultBranch(new ModuleId(_organisation, _module));
}
if (_revision == null || _revision.length() == 0) {
_revision = "latest.integration";
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheFileset.java Wed Jan 31 03:00:29 2007
@@ -20,7 +20,7 @@
import java.util.Iterator;
import java.util.List;
-import org.apache.ivy.Ivy;
+import org.apache.ivy.core.cache.CacheManager;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.types.FileSet;
@@ -65,11 +65,11 @@
NameEntry ne = fileset.createExclude();
ne.setName("**/*");
} else {
- Ivy ivy = getIvyInstance();
+ CacheManager cache = getCacheManager();
for (Iterator iter = paths.iterator(); iter.hasNext();) {
Artifact a = (Artifact)iter.next();
NameEntry ne = fileset.createInclude();
- ne.setName(ivy.getArchivePathInCache(a, ivy.getSavedArtifactOrigin(getCache(), a)));
+ ne.setName(cache.getArchivePathInCache(a, cache.getSavedArtifactOrigin(a)));
}
}
} catch (Exception ex) {
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java Wed Jan 31 03:00:29 2007
@@ -19,7 +19,7 @@
import java.util.Iterator;
-import org.apache.ivy.Ivy;
+import org.apache.ivy.core.cache.CacheManager;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -63,10 +63,10 @@
try {
Path path = new Path(getProject());
getProject().addReference(_pathid, path);
- Ivy ivy = getIvyInstance();
+ CacheManager cache = getCacheManager();
for (Iterator iter = getArtifacts().iterator(); iter.hasNext();) {
Artifact a = (Artifact) iter.next();
- path.createPathElement().setLocation(ivy.getArchiveFileInCache(getCache(), a, ivy.getSavedArtifactOrigin(getCache(), a), isUseOrigin()));
+ path.createPathElement().setLocation(cache.getArchiveFileInCache(a, cache.getSavedArtifactOrigin(a), isUseOrigin()));
}
} catch (Exception ex) {
throw new BuildException("impossible to build ivy path: "+ex, ex);
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheTask.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheTask.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheTask.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCacheTask.java Wed Jan 31 03:00:29 2007
@@ -27,6 +27,7 @@
import java.util.List;
import java.util.Set;
+import org.apache.ivy.core.cache.CacheManager;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.ArtifactDownloadReport;
@@ -91,4 +92,9 @@
}
return all;
}
+
+ protected CacheManager getCacheManager() {
+ CacheManager cache = new CacheManager(getSettings(), getCache());
+ return cache;
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConfigure.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConfigure.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConfigure.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConfigure.java Wed Jan 31 03:00:29 2007
@@ -25,13 +25,13 @@
import java.util.Properties;
import org.apache.ivy.Ivy;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.util.Message;
import org.apache.ivy.util.url.CredentialsStore;
import org.apache.ivy.util.url.URLHandler;
import org.apache.ivy.util.url.URLHandlerDispatcher;
import org.apache.ivy.util.url.URLHandlerRegistry;
import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Property;
@@ -132,10 +132,11 @@
throw new BuildException("impossible to load ivy default properties file: "+ex, ex);
}
ensureMessageInitialised();
- Ivy ivy = new Ivy();
+ Ivy ivy = Ivy.newInstance();
try {
configureURLHandler();
- ivy.addAllVariables(getProject().getProperties());
+ IvySettings settings = ivy.getSettings();
+ settings.addAllVariables(getProject().getProperties());
if (_file == null && _url == null) {
_file = new File(getProject().getBaseDir(), getProject().getProperty("ivy.conf.file"));
Message.verbose("searching ivyconf file: trying "+_file);
@@ -145,7 +146,7 @@
if (!_file.exists()) {
Message.info("no configuration file found, using default...");
_file = null;
- _url = Ivy.getDefaultConfigurationURL();
+ _url = IvySettings.getDefaultConfigurationURL();
}
}
}
@@ -167,7 +168,7 @@
private void loadDefaultProperties() {
Property prop = new Property() {
public void execute() throws BuildException {
- URL url = Ivy.getDefaultPropertiesURL();
+ URL url = IvySettings.getDefaultPropertiesURL();
// this is copy of loadURL code from ant Property task (not available in 1.5.1)
Properties props = new Properties();
Message.verbose("Loading " + url);
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConvertPom.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConvertPom.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConvertPom.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConvertPom.java Wed Jan 31 03:00:29 2007
@@ -21,8 +21,8 @@
import java.net.MalformedURLException;
import java.text.ParseException;
-import org.apache.ivy.Ivy;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.parser.m2.PomModuleDescriptorParser;
import org.apache.ivy.plugins.repository.url.URLResource;
import org.apache.tools.ant.BuildException;
@@ -61,7 +61,7 @@
if (_ivyFile == null) {
throw new BuildException("destination ivy file is required for convertpom task");
}
- ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(new Ivy(), _pomFile.toURL(), false);
+ ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(new IvySettings(), _pomFile.toURL(), false);
PomModuleDescriptorParser.getInstance().toIvyFile(_pomFile.toURL().openStream(), new URLResource(_pomFile.toURL()), getIvyFile(), md);
} catch (MalformedURLException e) {
throw new BuildException("unable to convert given pom file to url: "+_pomFile+": "+e, e);
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java Wed Jan 31 03:00:29 2007
@@ -27,6 +27,7 @@
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.module.status.StatusManager;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.util.Message;
import org.apache.ivy.util.MessageImpl;
import org.apache.tools.ant.BuildException;
@@ -292,25 +293,27 @@
}
public void execute() throws BuildException {
- Ivy ivy = getIvyInstance();
- _organisation = getProperty(_organisation, ivy, "ivy.organisation");
- _module = getProperty(_module, ivy, "ivy.module");
- _revision = getProperty(_revision, ivy, "ivy.revision");
- _pubRevision = getProperty(_pubRevision, ivy, "ivy.deliver.revision");
+ Ivy ivy = getIvyInstance();
+ IvySettings settings = ivy.getSettings();
+
+ _organisation = getProperty(_organisation, settings, "ivy.organisation");
+ _module = getProperty(_module, settings, "ivy.module");
+ _revision = getProperty(_revision, settings, "ivy.revision");
+ _pubRevision = getProperty(_pubRevision, settings, "ivy.deliver.revision");
if (_cache == null) {
- _cache = ivy.getDefaultCache();
+ _cache = settings.getDefaultCache();
}
- _deliverpattern = getProperty(_deliverpattern, ivy,
+ _deliverpattern = getProperty(_deliverpattern, settings,
"ivy.deliver.ivy.pattern");
- _status = getProperty(_status, ivy, "ivy.status");
+ _status = getProperty(_status, settings, "ivy.status");
if (_deliveryList == null) {
- String deliveryListPath = getProperty(ivy, "ivy.delivery.list.file");
+ String deliveryListPath = getProperty(settings, "ivy.delivery.list.file");
if (deliveryListPath == null) {
_deliveryList = new File(System.getProperty("java.io.tmpdir")
+ "/delivery.properties");
} else {
_deliveryList = getProject().resolveFile(
- ivy.substitute(deliveryListPath));
+ settings.substitute(deliveryListPath));
}
}
if (_organisation == null) {
@@ -322,7 +325,7 @@
"no module name provided for ivy deliver task: It can either be set explicitely via the attribute 'module' or via 'ivy.module' property or a prior call to <resolve/>");
}
if (_revision == null) {
- _revision = "working@"+Ivy.getLocalHostName();
+ _revision = Ivy.getWorkingRevision();
}
Date pubdate = getPubDate(_pubdate, new Date());
if (_pubRevision == null) {
@@ -357,7 +360,7 @@
drResolver = new DefaultPublishingDRResolver();
}
ivy.deliver(mrid, _pubRevision, _cache, _deliverpattern, _status,
- pubdate, drResolver, doValidate(ivy), _replacedynamicrev);
+ pubdate, drResolver, doValidate(settings), _replacedynamicrev);
} catch (Exception e) {
throw new BuildException("impossible to deliver " + mrid + ": " + e, e);
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyFindRevision.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyFindRevision.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyFindRevision.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyFindRevision.java Wed Jan 31 03:00:29 2007
@@ -21,6 +21,7 @@
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.resolve.ResolvedModuleRevision;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.tools.ant.BuildException;
@@ -92,8 +93,9 @@
}
Ivy ivy = getIvyInstance();
+ IvySettings settings = ivy.getSettings();
if (_branch == null) {
- ivy.getDefaultBranch(new ModuleId(_organisation, _module));
+ settings.getDefaultBranch(new ModuleId(_organisation, _module));
}
ResolvedModuleRevision rmr = ivy.findModule(ModuleRevisionId.newInstance(_organisation, _module, _branch, _revision));
if (rmr != null) {
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInfo.java Wed Jan 31 03:00:29 2007
@@ -27,6 +27,7 @@
import org.apache.ivy.core.module.descriptor.Configuration;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.descriptor.Configuration.Visibility;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -50,18 +51,19 @@
public void execute() throws BuildException {
Ivy ivy = getIvyInstance();
+ IvySettings settings = ivy.getSettings();
if (_file == null) {
- _file = new File(getProject().getBaseDir(), getProperty(ivy, "ivy.dep.file"));
+ _file = new File(getProject().getBaseDir(), getProperty(settings, "ivy.dep.file"));
}
try {
- ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(ivy, _file.toURL(), doValidate(ivy));
+ ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(settings, _file.toURL(), doValidate(settings));
getProject().setProperty("ivy.organisation", md.getModuleRevisionId().getOrganisation());
getProject().setProperty("ivy.module", md.getModuleRevisionId().getName());
if (md.getModuleRevisionId().getRevision() != null) {
getProject().setProperty("ivy.revision", md.getModuleRevisionId().getRevision());
} else {
- getProject().setProperty("ivy.revision", "working@"+Ivy.getLocalHostName());
+ getProject().setProperty("ivy.revision", Ivy.getWorkingRevision());
}
getProject().setProperty("ivy.configurations", mergeConfs(md.getConfigurationsNames()));
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyInstall.java Wed Jan 31 03:00:29 2007
@@ -21,6 +21,7 @@
import org.apache.ivy.Ivy;
import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.matcher.PatternMatcher;
import org.apache.ivy.util.filter.FilterHelper;
import org.apache.tools.ant.BuildException;
@@ -47,8 +48,9 @@
public void execute() throws BuildException {
Ivy ivy = getIvyInstance();
+ IvySettings settings = ivy.getSettings();
if (_cache == null) {
- _cache = ivy.getDefaultCache();
+ _cache = settings.getDefaultCache();
}
if (_organisation == null) {
throw new BuildException("no organisation provided for ivy publish task: It can either be set explicitely via the attribute 'organisation' or via 'ivy.organisation' property or a prior call to <resolve/>");
@@ -71,7 +73,7 @@
}
ModuleRevisionId mrid = ModuleRevisionId.newInstance(_organisation, _module, _revision);
try {
- ivy.install(mrid, _from, _to, _transitive, doValidate(ivy), _overwrite, FilterHelper.getArtifactTypeFilter(_type), _cache, _matcher);
+ ivy.install(mrid, _from, _to, _transitive, doValidate(settings), _overwrite, FilterHelper.getArtifactTypeFilter(_type), _cache, _matcher);
} catch (Exception e) {
throw new BuildException("impossible to install "+ mrid +": "+e, e);
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyListModules.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyListModules.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyListModules.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyListModules.java Wed Jan 31 03:00:29 2007
@@ -20,6 +20,7 @@
import org.apache.ivy.Ivy;
import org.apache.ivy.core.IvyPatternHelper;
import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.matcher.PatternMatcher;
import org.apache.tools.ant.BuildException;
@@ -113,10 +114,11 @@
throw new BuildException("no value provided for ivy findmodules");
}
Ivy ivy = getIvyInstance();
- ModuleRevisionId[] mrids = ivy.listModules(ModuleRevisionId.newInstance(_organisation, _module, _branch, _revision), ivy.getMatcher(_matcher));
+ IvySettings settings = ivy.getSettings();
+ ModuleRevisionId[] mrids = ivy.listModules(ModuleRevisionId.newInstance(_organisation, _module, _branch, _revision), settings.getMatcher(_matcher));
for (int i = 0; i < mrids.length; i++) {
- String name = IvyPatternHelper.substitute(ivy.substitute(_property), mrids[i]);
- String value = IvyPatternHelper.substitute(ivy.substitute(_value), mrids[i]);
+ String name = IvyPatternHelper.substitute(settings.substitute(_property), mrids[i]);
+ String value = IvyPatternHelper.substitute(settings.substitute(_value), mrids[i]);
getProject().setProperty(name, value);
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java Wed Jan 31 03:00:29 2007
@@ -22,6 +22,7 @@
import org.apache.ivy.Ivy;
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.report.ResolveReport;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.util.Message;
import org.apache.ivy.util.StringUtils;
import org.apache.ivy.util.filter.Filter;
@@ -63,11 +64,12 @@
protected void prepareAndCheck() {
Ivy ivy = getIvyInstance();
+ IvySettings settings = ivy.getSettings();
boolean orgAndModSetManually = (_organisation != null) && (_module != null);
- _organisation = getProperty(_organisation, ivy, "ivy.organisation");
- _module = getProperty(_module, ivy, "ivy.module");
+ _organisation = getProperty(_organisation, settings, "ivy.organisation");
+ _module = getProperty(_module, settings, "ivy.module");
if (isInline()) {
_conf = _conf == null ? "*" : _conf;
@@ -101,19 +103,19 @@
// there (TODO: maybe we can check which reports exist and extract the configurations
// from these report names?)
if (!orgAndModSetManually) {
- ensureResolved(isHaltonfailure(), isUseOrigin(), isTransitive(), getOrganisation(), getModule(), getProperty(_conf, ivy, "ivy.resolved.configurations"));
+ ensureResolved(isHaltonfailure(), isUseOrigin(), isTransitive(), getOrganisation(), getModule(), getProperty(_conf, settings, "ivy.resolved.configurations"));
}
- _conf = getProperty(_conf, ivy, "ivy.resolved.configurations");
+ _conf = getProperty(_conf, settings, "ivy.resolved.configurations");
if ("*".equals(_conf)) {
- _conf = getProperty(ivy, "ivy.resolved.configurations");
+ _conf = getProperty(settings, "ivy.resolved.configurations");
if (_conf == null) {
throw new BuildException("bad conf provided for ivy cache task: * can only be used with a prior call to <resolve/>");
}
}
}
- _organisation = getProperty(_organisation, ivy, "ivy.organisation");
- _module = getProperty(_module, ivy, "ivy.module");
+ _organisation = getProperty(_organisation, settings, "ivy.organisation");
+ _module = getProperty(_module, settings, "ivy.module");
if (_organisation == null) {
throw new BuildException("no organisation provided for ivy cache task: It can either be set explicitely via the attribute 'organisation' or via 'ivy.organisation' property or a prior call to <resolve/>");
}
@@ -124,7 +126,7 @@
throw new BuildException("no conf provided for ivy cache task: It can either be set explicitely via the attribute 'conf' or via 'ivy.resolved.configurations' property or a prior call to <resolve/>");
}
if (_cache == null) {
- _cache = ivy.getDefaultCache();
+ _cache = settings.getDefaultCache();
}
_artifactFilter = FilterHelper.getArtifactTypeFilter(_type);
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPublish.java Wed Jan 31 03:00:29 2007
@@ -32,6 +32,7 @@
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.id.ArtifactRevisionId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.util.Message;
import org.apache.tools.ant.BuildException;
@@ -164,15 +165,17 @@
public void execute() throws BuildException {
Ivy ivy = getIvyInstance();
- _organisation = getProperty(_organisation, ivy, "ivy.organisation");
- _module = getProperty(_module, ivy, "ivy.module");
- _revision = getProperty(_revision, ivy, "ivy.revision");
- _pubRevision = getProperty(_pubRevision, ivy, "ivy.deliver.revision");
+ IvySettings settings = ivy.getSettings();
+
+ _organisation = getProperty(_organisation, settings, "ivy.organisation");
+ _module = getProperty(_module, settings, "ivy.module");
+ _revision = getProperty(_revision, settings, "ivy.revision");
+ _pubRevision = getProperty(_pubRevision, settings, "ivy.deliver.revision");
if (_cache == null) {
- _cache = ivy.getDefaultCache();
+ _cache = settings.getDefaultCache();
}
if (_artifactspattern.isEmpty()) {
- String p = getProperty(null, ivy, "ivy.publish.src.artifacts.pattern");
+ String p = getProperty(null, settings, "ivy.publish.src.artifacts.pattern");
if (p != null) {
_artifactspattern.add(p);
}
@@ -180,7 +183,7 @@
if (_srcivypattern == null) {
_srcivypattern = getArtifactspattern();
}
- _status = getProperty(_status, ivy, "ivy.status");
+ _status = getProperty(_status, settings, "ivy.status");
if (_organisation == null) {
throw new BuildException("no organisation provided for ivy publish task: It can either be set explicitely via the attribute 'organisation' or via 'ivy.organisation' property or a prior call to <resolve/>");
}
@@ -197,7 +200,7 @@
throw new BuildException("no publish deliver name: please provide it through parameter 'resolver'");
}
if ("working".equals(_revision)) {
- _revision = "working@"+Ivy.getLocalHostName();
+ _revision = Ivy.getWorkingRevision();
}
Date pubdate = getPubDate(_pubdate, new Date());
if (_pubRevision == null) {
@@ -233,7 +236,7 @@
deliver.setPubrevision(getPubrevision());
deliver.setRevision(getRevision());
deliver.setStatus(getStatus());
- deliver.setValidate(doValidate(ivy));
+ deliver.setValidate(doValidate(settings));
deliver.setReplacedynamicrev(isReplacedynamicrev());
deliver.execute();
@@ -248,7 +251,7 @@
_publishivy?_srcivypattern:null,
getStatus(),
pubdate,
- (Artifact[]) _artifacts.toArray(new Artifact[_artifacts.size()]), doValidate(ivy),
+ (Artifact[]) _artifacts.toArray(new Artifact[_artifacts.size()]), doValidate(settings),
_overwrite,
_update,
_conf);
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyReport.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyReport.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyReport.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyReport.java Wed Jan 31 03:00:29 2007
@@ -26,6 +26,7 @@
import org.apache.ivy.Ivy;
import org.apache.ivy.core.IvyPatternHelper;
import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.report.XmlReportOutputter;
import org.apache.ivy.util.FileUtil;
import org.apache.ivy.util.Message;
@@ -112,26 +113,27 @@
public void execute() throws BuildException {
Ivy ivy = getIvyInstance();
+ IvySettings settings = ivy.getSettings();
- _organisation = getProperty(_organisation, ivy, "ivy.organisation");
- _module = getProperty(_module, ivy, "ivy.module");
+ _organisation = getProperty(_organisation, settings, "ivy.organisation");
+ _module = getProperty(_module, settings, "ivy.module");
if (_cache == null) {
- _cache = ivy.getDefaultCache();
+ _cache = settings.getDefaultCache();
}
- _conf = getProperty(_conf, ivy, "ivy.resolved.configurations");
+ _conf = getProperty(_conf, settings, "ivy.resolved.configurations");
if (_conf.equals("*")) {
- _conf = getProperty(ivy, "ivy.resolved.configurations");
+ _conf = getProperty(settings, "ivy.resolved.configurations");
}
if (_conf == null) {
throw new BuildException("no conf provided for ivy report task: It can either be set explicitely via the attribute 'conf' or via 'ivy.resolved.configurations' property or a prior call to <resolve/>");
}
if (_todir == null) {
- String t = getProperty(ivy, "ivy.report.todir");
+ String t = getProperty(settings, "ivy.report.todir");
if (t != null) {
_todir = new File(t);
}
}
- _outputpattern = getProperty(_outputpattern, ivy, "ivy.report.output.pattern");
+ _outputpattern = getProperty(_outputpattern, settings, "ivy.report.output.pattern");
if (_todir != null && _todir.exists()) {
_todir.mkdirs();
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRepositoryReport.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRepositoryReport.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRepositoryReport.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRepositoryReport.java Wed Jan 31 03:00:29 2007
@@ -28,6 +28,7 @@
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.ResolveReport;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.matcher.PatternMatcher;
import org.apache.ivy.plugins.report.XmlReportOutputter;
import org.apache.ivy.util.FileUtil;
@@ -64,8 +65,9 @@
public void execute() throws BuildException {
Ivy ivy = getIvyInstance();
+ IvySettings settings = ivy.getSettings();
if (_cache == null) {
- _cache = ivy.getDefaultCache();
+ _cache = settings.getDefaultCache();
}
if (_xsl && _xslFile == null) {
throw new BuildException("xsl file is mandatory when using xsl generation");
@@ -77,7 +79,7 @@
}
ModuleRevisionId mrid = ModuleRevisionId.newInstance(_organisation, _module, _revision);
try {
- ModuleId[] mids = ivy.listModules(new ModuleId(_organisation, _module), ivy.getMatcher(_matcher));
+ ModuleId[] mids = ivy.listModules(new ModuleId(_organisation, _module), settings.getMatcher(_matcher));
ModuleRevisionId[] mrids = new ModuleRevisionId[mids.length];
for (int i = 0; i < mrids.length; i++) {
if (_branch != null) {
@@ -87,7 +89,7 @@
}
}
DefaultModuleDescriptor md = DefaultModuleDescriptor.newCallerInstance(mrids, true, false);
- ResolveReport report = ivy.resolve(md, new String[] {"*"}, _cache, null, doValidate(ivy), false, true, false, false, FilterHelper.NO_FILTER);
+ ResolveReport report = ivy.resolve(md, new String[] {"*"}, _cache, null, doValidate(settings), false, true, false, false, FilterHelper.NO_FILTER);
new XmlReportOutputter().output(report, _cache);
if (_graph) {
gengraph(_cache, md.getModuleRevisionId().getOrganisation(), md.getModuleRevisionId().getName());
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java Wed Jan 31 03:00:29 2007
@@ -25,6 +25,7 @@
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.ResolveReport;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.util.Message;
import org.apache.ivy.util.filter.FilterHelper;
import org.apache.tools.ant.BuildException;
@@ -131,11 +132,12 @@
public void execute() throws BuildException {
Ivy ivy = getIvyInstance();
+ IvySettings settings = ivy.getSettings();
try {
- _conf = getProperty(_conf, ivy, "ivy.configurations");
- _type = getProperty(_type, ivy, "ivy.resolve.default.type.filter");
+ _conf = getProperty(_conf, settings, "ivy.configurations");
+ _type = getProperty(_type, settings, "ivy.resolve.default.type.filter");
if (_cache == null) {
- _cache = ivy.getDefaultCache();
+ _cache = settings.getDefaultCache();
}
String[] confs = splitConfs(_conf);
@@ -160,7 +162,7 @@
_changing,
_cache,
getPubDate(_pubdate, null),
- doValidate(ivy),
+ doValidate(settings),
_useCacheOnly,
_useOrigin,
FilterHelper.getArtifactTypeFilter(_type));
@@ -173,16 +175,16 @@
throw new BuildException("'module' not allowed when not using 'org' attribute");
}
if (_file == null) {
- _file = new File(getProject().getBaseDir(), getProperty(ivy, "ivy.dep.file"));
+ _file = new File(getProject().getBaseDir(), getProperty(settings, "ivy.dep.file"));
}
- _revision = getProperty(_revision, ivy, "ivy.revision");
+ _revision = getProperty(_revision, settings, "ivy.revision");
report = ivy.resolve(
_file.toURL(),
_revision,
confs,
_cache,
getPubDate(_pubdate, null),
- doValidate(ivy),
+ doValidate(settings),
_useCacheOnly,
_transitive,
_useOrigin,
@@ -203,20 +205,20 @@
// put resolved infos in ant properties and ivy variables
// putting them in ivy variables is important to be able to change from one resolve call to the other
getProject().setProperty("ivy.organisation", md.getModuleRevisionId().getOrganisation());
- ivy.setVariable("ivy.organisation", md.getModuleRevisionId().getOrganisation());
+ settings.setVariable("ivy.organisation", md.getModuleRevisionId().getOrganisation());
getProject().setProperty("ivy.module", md.getModuleRevisionId().getName());
- ivy.setVariable("ivy.module", md.getModuleRevisionId().getName());
+ settings.setVariable("ivy.module", md.getModuleRevisionId().getName());
getProject().setProperty("ivy.revision", md.getResolvedModuleRevisionId().getRevision());
- ivy.setVariable("ivy.revision", md.getResolvedModuleRevisionId().getRevision());
+ settings.setVariable("ivy.revision", md.getResolvedModuleRevisionId().getRevision());
boolean hasChanged = report.hasChanged();
getProject().setProperty("ivy.deps.changed", String.valueOf(hasChanged));
- ivy.setVariable("ivy.deps.changed", String.valueOf(hasChanged));
+ settings.setVariable("ivy.deps.changed", String.valueOf(hasChanged));
if (_conf.trim().equals("*")) {
getProject().setProperty("ivy.resolved.configurations", mergeConfs(md.getConfigurationsNames()));
- ivy.setVariable("ivy.resolved.configurations", mergeConfs(md.getConfigurationsNames()));
+ settings.setVariable("ivy.resolved.configurations", mergeConfs(md.getConfigurationsNames()));
} else {
getProject().setProperty("ivy.resolved.configurations", _conf);
- ivy.setVariable("ivy.resolved.configurations", _conf);
+ settings.setVariable("ivy.resolved.configurations", _conf);
}
}
} catch (MalformedURLException e) {
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java Wed Jan 31 03:00:29 2007
@@ -43,7 +43,7 @@
public void execute() throws BuildException {
prepareAndCheck();
- _pattern = getProperty(_pattern, getIvyInstance(), "ivy.retrieve.pattern");
+ _pattern = getProperty(_pattern, getSettings(), "ivy.retrieve.pattern");
try {
Filter artifactFilter = getArtifactFilter();
int targetsCopied = getIvyInstance().retrieve(getResolvedModuleId(), splitConfs(getConf()), getCache(), _pattern, _ivypattern, artifactFilter, _sync, isUseOrigin(), _symlink);
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java Wed Jan 31 03:00:29 2007
@@ -29,6 +29,7 @@
import org.apache.ivy.core.IvyContext;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.report.ResolveReport;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.util.Message;
import org.apache.ivy.util.StringUtils;
import org.apache.tools.ant.BuildException;
@@ -46,7 +47,7 @@
public static final String ANT_PROJECT_CONTEXT_KEY = "ant-project";
private Boolean _validate = null;
- protected boolean doValidate(Ivy ivy) {
+ protected boolean doValidate(IvySettings ivy) {
if (_validate != null) {
return _validate.booleanValue();
}
@@ -59,6 +60,10 @@
_validate = Boolean.valueOf(validate);
}
+ protected IvySettings getSettings() {
+ return getIvyInstance().getSettings();
+ }
+
protected Ivy getIvyInstance() {
ensureMessageInitialised();
Object ref = getProject().getReference("ivy.instances");
@@ -250,7 +255,7 @@
}
}
- protected String getProperty(String value, Ivy ivy, String name) {
+ protected String getProperty(String value, IvySettings ivy, String name) {
if (value == null) {
return getProperty(ivy, name);
} else {
@@ -260,7 +265,7 @@
}
}
- protected String getProperty(Ivy ivy, String name) {
+ protected String getProperty(IvySettings ivy, String name) {
String val = ivy.getVariable(name);
if (val == null) {
val = ivy.substitute(getProject().getProperty(name));
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyVar.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyVar.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyVar.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyVar.java Wed Jan 31 03:00:29 2007
@@ -25,6 +25,7 @@
import java.util.Properties;
import org.apache.ivy.Ivy;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.tools.ant.BuildException;
@@ -93,8 +94,9 @@
public void execute() throws BuildException {
Ivy ivy = getIvyInstance();
+ IvySettings settings = ivy.getSettings();
if (getName() != null) {
- ivy.setVariable(getVarName(getName()), getValue());
+ settings.setVariable(getVarName(getName()), getValue());
} else {
Properties props = new Properties();
InputStream is = null;
@@ -117,7 +119,7 @@
for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
String name = (String)iter.next();
String value = (String)props.get(name);
- ivy.setVariable(getVarName(name), value);
+ settings.setVariable(getVarName(name), value);
}
}
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyContext.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyContext.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyContext.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyContext.java Wed Jan 31 03:00:29 2007
@@ -23,6 +23,9 @@
import java.util.Map;
import org.apache.ivy.Ivy;
+import org.apache.ivy.core.cache.CacheManager;
+import org.apache.ivy.core.event.EventManager;
+import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.plugins.circular.CircularDependencyStrategy;
import org.apache.ivy.util.MessageImpl;
@@ -87,9 +90,9 @@
private Ivy getDefaultIvy() {
if (_defaultIvy == null) {
- _defaultIvy = new Ivy();
+ _defaultIvy = Ivy.newInstance();
try {
- getDefaultIvy().configureDefault();
+ _defaultIvy.configureDefault();
} catch (Exception e) {
}
}
@@ -100,14 +103,18 @@
_operatingThread = Thread.currentThread();
}
public File getCache() {
- return _cache == null ? getIvy().getDefaultCache() : _cache;
+ return _cache == null ? getSettings().getDefaultCache() : _cache;
}
public void setCache(File cache) {
_cache = cache;
}
+
+ public IvySettings getSettings() {
+ return getIvy().getSettings();
+ }
public CircularDependencyStrategy getCircularDependencyStrategy() {
- return getIvy().getCircularDependencyStrategy();
+ return getSettings().getCircularDependencyStrategy();
}
public Object get(String key) {
@@ -134,6 +141,15 @@
public void setMessageImpl(MessageImpl impl) {
_messageImpl = impl;
+ }
+
+ public EventManager getEventManager() {
+ return getIvy().getEventManager();
+ }
+
+ public CacheManager getCacheManager() {
+ // TODO : reuse one instance
+ return new CacheManager(getSettings(), getCache());
}
// should be better to use context to store this kind of information, but not yet ready to do so...
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java Wed Jan 31 03:00:29 2007
@@ -17,7 +17,6 @@
*/
package org.apache.ivy.core;
-import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -27,8 +26,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.ivy.Ivy;
import org.apache.ivy.core.cache.ArtifactOrigin;
+import org.apache.ivy.core.cache.CacheManager;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.DefaultArtifact;
import org.apache.ivy.core.module.id.ModuleRevisionId;
@@ -390,13 +389,12 @@
ModuleRevisionId revId = ModuleRevisionId.newInstance(org, moduleName, branch, revision);
Artifact artifact = new DefaultArtifact(revId, null, artifactName, artifactType, artifactExt);
- Ivy ivy = IvyContext.getContext().getIvy();
- File cache = IvyContext.getContext().getCache();
+ CacheManager cacheManager = IvyContext.getContext().getCacheManager();
- origin = ivy.getSavedArtifactOrigin(cache, artifact);
+ origin = cacheManager.getSavedArtifactOrigin(artifact);
if (origin == null) {
- Message.debug("no artifact origin found for "+artifact+" in "+cache);
+ Message.debug("no artifact origin found for "+artifact+" in "+cacheManager);
return null;
}
}
Added: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java?view=auto&rev=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java (added)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java Wed Jan 31 03:00:29 2007
@@ -0,0 +1,212 @@
+package org.apache.ivy.core.cache;
+
+import java.io.File;
+
+import org.apache.ivy.core.IvyPatternHelper;
+import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.descriptor.DefaultArtifact;
+import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.resolve.DefaultModuleRevision;
+import org.apache.ivy.core.resolve.ResolvedModuleRevision;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser;
+import org.apache.ivy.plugins.resolver.DependencyResolver;
+import org.apache.ivy.util.Message;
+import org.apache.ivy.util.PropertiesFile;
+
+public class CacheManager {
+
+ private IvySettings _settings;
+ private File _cache;
+
+ public CacheManager(IvySettings settings, File cache) {
+ _settings = settings;
+ _cache = cache;
+ }
+
+ public File getResolvedIvyFileInCache(ModuleRevisionId mrid) {
+ return new File(_cache, IvyPatternHelper.substitute(_settings.getCacheResolvedIvyPattern(), mrid.getOrganisation(), mrid.getName(), mrid.getRevision(), "ivy", "ivy", "xml"));
+ }
+
+ public File getResolvedIvyPropertiesInCache(ModuleRevisionId mrid) {
+ return new File(_cache, IvyPatternHelper.substitute(_settings.getCacheResolvedIvyPropertiesPattern(), mrid.getOrganisation(), mrid.getName(), mrid.getRevision(), "ivy", "ivy", "xml"));
+ }
+
+ public File getIvyFileInCache(ModuleRevisionId mrid) {
+ return new File(_cache, IvyPatternHelper.substitute(_settings.getCacheIvyPattern(), DefaultArtifact.newIvyArtifact(mrid, null)));
+ }
+
+ /**
+ * Returns a File object pointing to where the artifact can be found on the local file system.
+ * This is usually in the cache, but it can be directly in the repository if it is local
+ * and if the resolve has been done with useOrigin = true
+ *
+ */
+ public File getArchiveFileInCache(Artifact artifact) {
+ ArtifactOrigin origin = getSavedArtifactOrigin(artifact);
+ return getArchiveFileInCache(artifact, origin);
+ }
+
+ /**
+ * Returns a File object pointing to where the artifact can be found on the local file system.
+ * This is usually in the cache, but it can be directly in the repository if it is local
+ * and if the resolve has been done with useOrigin = true
+ *
+ */
+ public File getArchiveFileInCache(Artifact artifact, ArtifactOrigin origin) {
+ File archive = new File(_cache, getArchivePathInCache(artifact, origin));
+ if (!archive.exists() && origin != null && origin.isLocal()) {
+ File original = new File(origin.getLocation());
+ if (original.exists()) {
+ return original;
+ }
+ }
+ return archive;
+ }
+ /**
+ * Returns a File object pointing to where the artifact can be found on the local file system,
+ * using or not the original location depending on the availability of origin information provided
+ * as parameter and the setting of useOrigin.
+ *
+ * If useOrigin is false, this method will always return the file in the cache.
+ *
+ */
+ public File getArchiveFileInCache(Artifact artifact, ArtifactOrigin origin, boolean useOrigin) {
+ if (useOrigin && origin != null && origin.isLocal()) {
+ return new File(origin.getLocation());
+ } else {
+ return new File(_cache, getArchivePathInCache(artifact, origin));
+ }
+ }
+
+
+ public String getArchivePathInCache(Artifact artifact) {
+ return IvyPatternHelper.substitute(_settings.getCacheArtifactPattern(), artifact);
+ }
+
+ public String getArchivePathInCache(Artifact artifact, ArtifactOrigin origin) {
+ return IvyPatternHelper.substitute(_settings.getCacheArtifactPattern(), artifact, origin);
+ }
+
+ /**
+ * Saves the information of which resolver was used to resolve a md,
+ * so that this info can be retrieve later (even after a jvm restart)
+ * by getSavedResolverName(ModuleDescriptor md)
+ * @param md the module descriptor resolved
+ * @param name resolver name
+ */
+ public void saveResolver(ModuleDescriptor md, String name) {
+ PropertiesFile cdf = getCachedDataFile(md);
+ cdf.setProperty("resolver", name);
+ cdf.save();
+ }
+
+ /**
+ * Saves the information of which resolver was used to resolve a md,
+ * so that this info can be retrieve later (even after a jvm restart)
+ * by getSavedArtResolverName(ModuleDescriptor md)
+ * @param md the module descriptor resolved
+ * @param name artifact resolver name
+ */
+ public void saveArtResolver(ModuleDescriptor md, String name) {
+ PropertiesFile cdf = getCachedDataFile(md);
+ cdf.setProperty("artifact.resolver", name);
+ cdf.save();
+ }
+
+ public void saveArtifactOrigin(Artifact artifact, ArtifactOrigin origin) {
+ PropertiesFile cdf = getCachedDataFile(artifact.getModuleRevisionId());
+ cdf.setProperty("artifact." + artifact.getName() + "#" + artifact.getExt() + ".is-local", String.valueOf(origin.isLocal()));
+ cdf.setProperty("artifact." + artifact.getName() + "#" + artifact.getExt() + ".location", origin.getLocation());
+ cdf.save();
+ }
+
+ public ArtifactOrigin getSavedArtifactOrigin(Artifact artifact) {
+ PropertiesFile cdf = getCachedDataFile(artifact.getModuleRevisionId());
+ String location = cdf.getProperty("artifact." + artifact.getName() + "#" + artifact.getExt() + ".location");
+ boolean isLocal = Boolean.valueOf(cdf.getProperty("artifact." + artifact.getName() + "#" + artifact.getExt() + ".is-local")).booleanValue();
+
+ if (location == null) {
+ // origin has not been specified, return null
+ return null;
+ }
+
+ return new ArtifactOrigin(isLocal, location);
+ }
+
+ public void removeSavedArtifactOrigin(Artifact artifact) {
+ PropertiesFile cdf = getCachedDataFile(artifact.getModuleRevisionId());
+ cdf.remove("artifact." + artifact.getName() + "#" + artifact.getExt() + ".location");
+ cdf.remove("artifact." + artifact.getName() + "#" + artifact.getExt() + ".is-local");
+ cdf.save();
+ }
+
+ private String getSavedResolverName(ModuleDescriptor md) {
+ PropertiesFile cdf = getCachedDataFile(md);
+ return cdf.getProperty("resolver");
+ }
+
+ private String getSavedArtResolverName(ModuleDescriptor md) {
+ PropertiesFile cdf = getCachedDataFile(md);
+ return cdf.getProperty("artifact.resolver");
+ }
+
+ private PropertiesFile getCachedDataFile(ModuleDescriptor md) {
+ return getCachedDataFile(md.getResolvedModuleRevisionId());
+ }
+
+ private PropertiesFile getCachedDataFile(ModuleRevisionId mRevId) {
+ return new PropertiesFile(new File(_cache, IvyPatternHelper.substitute(_settings.getCacheDataFilePattern(),mRevId)), "ivy cached data file for "+mRevId);
+ }
+
+ public ResolvedModuleRevision findModuleInCache(ModuleRevisionId mrid, boolean validate) {
+ // first, check if it is in cache
+ if (!_settings.getVersionMatcher().isDynamic(mrid)) {
+ File ivyFile = getIvyFileInCache(mrid);
+ if (ivyFile.exists()) {
+ // found in cache !
+ try {
+ ModuleDescriptor depMD = XmlModuleDescriptorParser.getInstance().parseDescriptor(_settings, ivyFile.toURL(), validate);
+ String resolverName = getSavedResolverName(depMD);
+ String artResolverName = getSavedArtResolverName(depMD);
+ DependencyResolver resolver = _settings.getResolver(resolverName);
+ if (resolver == null) {
+ Message.debug("\tresolver not found: "+resolverName+" => trying to use the one configured for "+mrid);
+ resolver = _settings.getResolver(depMD.getResolvedModuleRevisionId().getModuleId());
+ if (resolver != null) {
+ Message.debug("\tconfigured resolver found for "+depMD.getResolvedModuleRevisionId()+": "+resolver.getName()+": saving this data");
+ saveResolver(depMD, resolver.getName());
+ }
+ }
+ DependencyResolver artResolver = _settings.getResolver(artResolverName);
+ if (artResolver == null) {
+ artResolver = resolver;
+ }
+ if (resolver != null) {
+ Message.debug("\tfound ivy file in cache for "+mrid+" (resolved by "+resolver.getName()+"): "+ivyFile);
+ return new DefaultModuleRevision(resolver, artResolver, depMD, false, false, ivyFile.toURL());
+ } else {
+ Message.debug("\tresolver not found: "+resolverName+" => cannot use cached ivy file for "+mrid);
+ }
+ } catch (Exception e) {
+ // will try with resolver
+ Message.debug("\tproblem while parsing cached ivy file for: "+mrid+": "+e.getMessage());
+ }
+ } else {
+ Message.debug("\tno ivy file in cache for "+mrid+": tried "+ivyFile);
+ }
+ }
+ return null;
+ }
+
+
+ public String toString() {
+ return "cache: "+String.valueOf(_cache);
+ }
+
+ public File getCache() {
+ return _cache;
+ }
+
+}
Added: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/EventManager.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/EventManager.java?view=auto&rev=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/EventManager.java (added)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/EventManager.java Wed Jan 31 03:00:29 2007
@@ -0,0 +1,79 @@
+package org.apache.ivy.core.event;
+
+import java.util.Arrays;
+
+import javax.swing.event.EventListenerList;
+
+import org.apache.ivy.plugins.repository.TransferEvent;
+import org.apache.ivy.plugins.repository.TransferListener;
+import org.apache.ivy.util.filter.Filter;
+
+public class EventManager implements TransferListener {
+
+ private EventListenerList _listeners = new EventListenerList();
+
+ public void addIvyListener(IvyListener listener) {
+ _listeners.add(IvyListener.class, listener);
+ }
+
+ public void addIvyListener(IvyListener listener, String eventName) {
+ addIvyListener(listener, new IvyEventFilter(eventName, null, null));
+ }
+
+ public void addIvyListener(IvyListener listener, Filter filter) {
+ _listeners.add(IvyListener.class, new FilteredIvyListener(listener, filter));
+ }
+
+ public void removeIvyListener(IvyListener listener) {
+ _listeners.remove(IvyListener.class, listener);
+ IvyListener[] listeners = (IvyListener[])_listeners.getListeners(IvyListener.class);
+ for (int i = 0; i < listeners.length; i++) {
+ if (listeners[i] instanceof FilteredIvyListener) {
+ if (listener.equals(((FilteredIvyListener)listeners[i]).getIvyListener())) {
+ _listeners.remove(IvyListener.class, listeners[i]);
+ }
+ }
+ }
+ }
+
+ public boolean hasIvyListener(IvyListener listener) {
+ return Arrays.asList(_listeners.getListeners(IvyListener.class)).contains(listener);
+ }
+ public void fireIvyEvent(IvyEvent evt) {
+ Object[] listeners = _listeners.getListenerList();
+ for (int i = listeners.length-2; i>=0; i-=2) {
+ if (listeners[i]==IvyListener.class) {
+ ((IvyListener)listeners[i+1]).progress(evt);
+ }
+ }
+ }
+
+ public void addTransferListener(TransferListener listener) {
+ _listeners.add(TransferListener.class, listener);
+ }
+
+ public void removeTransferListener(TransferListener listener) {
+ _listeners.remove(TransferListener.class, listener);
+ }
+
+ public boolean hasTransferListener(TransferListener listener) {
+ return Arrays.asList(_listeners.getListeners(TransferListener.class)).contains(listener);
+ }
+ protected void fireTransferEvent(TransferEvent evt) {
+ Object[] listeners = _listeners.getListenerList();
+ for (int i = listeners.length-2; i>=0; i-=2) {
+ if (listeners[i]==TransferListener.class) {
+ ((TransferListener)listeners[i+1]).transferProgress(evt);
+ }
+ }
+ }
+
+
+
+ public void transferProgress(TransferEvent evt) {
+ fireTransferEvent(evt);
+ fireIvyEvent(evt);
+ }
+
+
+}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/IvyEvent.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/IvyEvent.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/IvyEvent.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/IvyEvent.java Wed Jan 31 03:00:29 2007
@@ -20,7 +20,7 @@
import java.util.HashMap;
import java.util.Map;
-import org.apache.ivy.Ivy;
+import org.apache.ivy.core.IvyContext;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
@@ -51,12 +51,12 @@
*
*/
public class IvyEvent {
- private Ivy _source;
+ private EventManager _source;
private String _name;
private Map _attributes = new HashMap();
- protected IvyEvent(Ivy source, String name) {
- _source = source;
+ protected IvyEvent(String name) {
+ _source = IvyContext.getContext().getEventManager();
_name = name;
}
@@ -92,7 +92,7 @@
}
- public Ivy getSource() {
+ public EventManager getSource() {
return _source;
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/DownloadEvent.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/DownloadEvent.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/DownloadEvent.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/DownloadEvent.java Wed Jan 31 03:00:29 2007
@@ -17,15 +17,14 @@
*/
package org.apache.ivy.core.event.download;
-import org.apache.ivy.Ivy;
import org.apache.ivy.core.event.IvyEvent;
import org.apache.ivy.core.module.descriptor.Artifact;
public abstract class DownloadEvent extends IvyEvent {
private Artifact _artifact;
- public DownloadEvent(Ivy source, String name, Artifact artifact) {
- super(source, name);
+ public DownloadEvent(String name, Artifact artifact) {
+ super(name);
_artifact = artifact;
addArtifactAttributes(_artifact);
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/EndArtifactDownloadEvent.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/EndArtifactDownloadEvent.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/EndArtifactDownloadEvent.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/EndArtifactDownloadEvent.java Wed Jan 31 03:00:29 2007
@@ -19,7 +19,6 @@
import java.io.File;
-import org.apache.ivy.Ivy;
import org.apache.ivy.core.cache.ArtifactOrigin;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.report.ArtifactDownloadReport;
@@ -32,8 +31,8 @@
private DependencyResolver _resolver;
private ArtifactDownloadReport _report;
- public EndArtifactDownloadEvent(Ivy source, DependencyResolver resolver, Artifact artifact, ArtifactDownloadReport report, File dest) {
- super(source, NAME, artifact);
+ public EndArtifactDownloadEvent(DependencyResolver resolver, Artifact artifact, ArtifactDownloadReport report, File dest) {
+ super(NAME, artifact);
_resolver = resolver;
_report = report;
addAttribute("resolver", _resolver.getName());
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/NeedArtifactEvent.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/NeedArtifactEvent.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/NeedArtifactEvent.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/NeedArtifactEvent.java Wed Jan 31 03:00:29 2007
@@ -17,7 +17,6 @@
*/
package org.apache.ivy.core.event.download;
-import org.apache.ivy.Ivy;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.plugins.resolver.DependencyResolver;
@@ -26,8 +25,8 @@
private DependencyResolver _resolver;
- public NeedArtifactEvent(Ivy source, DependencyResolver resolver, Artifact artifact) {
- super(source, NAME, artifact);
+ public NeedArtifactEvent(DependencyResolver resolver, Artifact artifact) {
+ super(NAME, artifact);
_resolver = resolver;
addAttribute("resolver", _resolver.getName());
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/PrepareDownloadEvent.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/PrepareDownloadEvent.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/PrepareDownloadEvent.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/PrepareDownloadEvent.java Wed Jan 31 03:00:29 2007
@@ -17,7 +17,6 @@
*/
package org.apache.ivy.core.event.download;
-import org.apache.ivy.Ivy;
import org.apache.ivy.core.event.IvyEvent;
import org.apache.ivy.core.module.descriptor.Artifact;
@@ -25,8 +24,8 @@
public static final String NAME = "prepare-download";
private Artifact[] _artifacts;
- public PrepareDownloadEvent(Ivy source, Artifact[] artifacts) {
- super(source, NAME);
+ public PrepareDownloadEvent(Artifact[] artifacts) {
+ super(NAME);
_artifacts = artifacts;
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/StartArtifactDownloadEvent.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/StartArtifactDownloadEvent.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/StartArtifactDownloadEvent.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/StartArtifactDownloadEvent.java Wed Jan 31 03:00:29 2007
@@ -17,7 +17,6 @@
*/
package org.apache.ivy.core.event.download;
-import org.apache.ivy.Ivy;
import org.apache.ivy.core.cache.ArtifactOrigin;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.plugins.resolver.DependencyResolver;
@@ -28,8 +27,8 @@
private DependencyResolver _resolver;
private ArtifactOrigin _origin;
- public StartArtifactDownloadEvent(Ivy source, DependencyResolver resolver, Artifact artifact, ArtifactOrigin origin) {
- super(source, NAME, artifact);
+ public StartArtifactDownloadEvent(DependencyResolver resolver, Artifact artifact, ArtifactOrigin origin) {
+ super(NAME, artifact);
_resolver = resolver;
_origin = origin;
addAttribute("resolver", _resolver.getName());
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/EndResolveDependencyEvent.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/EndResolveDependencyEvent.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/EndResolveDependencyEvent.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/EndResolveDependencyEvent.java Wed Jan 31 03:00:29 2007
@@ -17,7 +17,6 @@
*/
package org.apache.ivy.core.event.resolve;
-import org.apache.ivy.Ivy;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.resolve.ResolvedModuleRevision;
import org.apache.ivy.plugins.resolver.DependencyResolver;
@@ -26,8 +25,8 @@
public static final String NAME = "post-resolve-dependency";
private ResolvedModuleRevision _module;
- public EndResolveDependencyEvent(Ivy source, DependencyResolver resolver, DependencyDescriptor dd, ResolvedModuleRevision module) {
- super(source, NAME, resolver, dd);
+ public EndResolveDependencyEvent(DependencyResolver resolver, DependencyDescriptor dd, ResolvedModuleRevision module) {
+ super(NAME, resolver, dd);
_module = module;
if (_module != null) {
// override revision from the dependency descriptor
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/EndResolveEvent.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/EndResolveEvent.java?view=diff&rev=501796&r1=501795&r2=501796
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/EndResolveEvent.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/event/resolve/EndResolveEvent.java Wed Jan 31 03:00:29 2007
@@ -17,7 +17,6 @@
*/
package org.apache.ivy.core.event.resolve;
-import org.apache.ivy.Ivy;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.report.ResolveReport;
@@ -26,8 +25,8 @@
private ResolveReport _report;
- public EndResolveEvent(Ivy source, ModuleDescriptor md, String[] confs, ResolveReport report) {
- super(source, NAME, md, confs);
+ public EndResolveEvent(ModuleDescriptor md, String[] confs, ResolveReport report) {
+ super(NAME, md, confs);
_report = report;
}