Author: xavier
Date: Wed Jan 31 09:29:49 2007
New Revision: 501916
URL: http://svn.apache.org/viewvc?view=rev&rev=501916
Log:
REFACTOR: review deliver API
Added:
incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverOptions.java
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/Main.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDeliver.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyContext.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngine.java
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverEngine.java
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java?view=diff&rev=501916&r1=501915&r2=501916
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java Wed Jan 31
09:29:49 2007
@@ -33,7 +33,7 @@
import org.apache.ivy.core.cache.CacheManager;
import org.apache.ivy.core.check.CheckEngine;
import org.apache.ivy.core.deliver.DeliverEngine;
-import org.apache.ivy.core.deliver.PublishingDependencyRevisionResolver;
+import org.apache.ivy.core.deliver.DeliverOptions;
import org.apache.ivy.core.event.EventManager;
import org.apache.ivy.core.install.InstallEngine;
import org.apache.ivy.core.module.descriptor.Artifact;
@@ -347,13 +347,26 @@
// DELIVER
/////////////////////////////////////////////////////////////////////////
- public void deliver(ModuleRevisionId mrid, String revision, File cache,
String destIvyPattern, String status, Date pubdate,
PublishingDependencyRevisionResolver pdrResolver, boolean validate, boolean
resolveDynamicRevisions) throws IOException, ParseException {
- _deliverEngine.deliver(mrid, revision, cache, destIvyPattern,
status, pubdate, pdrResolver, validate, resolveDynamicRevisions);
+ public void deliver(ModuleRevisionId mrid, String revision, String
destIvyPattern) throws IOException, ParseException {
+ _deliverEngine.deliver(mrid, revision, destIvyPattern,
DeliverOptions.newInstance(_settings));
}
- public void deliver(ModuleRevisionId mrid, String revision, File cache,
String destIvyPattern, String status, Date pubdate,
PublishingDependencyRevisionResolver pdrResolver, boolean validate) throws
IOException, ParseException {
- _deliverEngine.deliver(mrid, revision, cache, destIvyPattern,
status, pubdate, pdrResolver, validate);
+ /**
+ * Example of use:
+ * deliver(mrid, "1.5", "target/ivy/ivy-[revision].xml",
+ *
DeliverOptions.newInstance(settings).setStatus("release").setValidate(false));
+ *
+ * @param mrid
+ * @param revision
+ * @param destIvyPattern
+ * @param options
+ * @throws IOException
+ * @throws ParseException
+ */
+ public void deliver(ModuleRevisionId mrid, String revision, String
destIvyPattern, DeliverOptions options) throws IOException, ParseException {
+ _deliverEngine.deliver(mrid, revision, destIvyPattern, options);
}
+
/////////////////////////////////////////////////////////////////////////
// PUBLISH
Added: incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java?view=auto&rev=501916
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java (added)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy14.java Wed Jan 31
09:29:49 2007
@@ -0,0 +1,303 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivy;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URL;
+import java.text.ParseException;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ivy.core.cache.CacheManager;
+import org.apache.ivy.core.deliver.DeliverOptions;
+import org.apache.ivy.core.deliver.PublishingDependencyRevisionResolver;
+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.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.ArtifactDownloadReport;
+import org.apache.ivy.core.report.ResolveReport;
+import org.apache.ivy.core.resolve.IvyNode;
+import org.apache.ivy.core.resolve.ResolvedModuleRevision;
+import org.apache.ivy.core.search.ModuleEntry;
+import org.apache.ivy.core.search.OrganisationEntry;
+import org.apache.ivy.core.search.RevisionEntry;
+import org.apache.ivy.plugins.matcher.PatternMatcher;
+import org.apache.ivy.plugins.resolver.DependencyResolver;
+import org.apache.ivy.util.filter.Filter;
+
+
+
+/**
+ * This class can be used for easy migration from Ivy 1.4 API.
+ *
+ * Indeed, Ivy 1.5 API has changed substantially, so it can take time to
+ * migrate existing code using Ivy 1.4 API to the new API.
+ *
+ * Using this class it's really easy: replace your instance of Ivy by an
+ * instance of this class. For instance, where you were doing:
+ * Ivy ivy = new Ivy();
+ *
+ * do instead:
+ * Ivy14 ivy = new Ivy14();
+ *
+ * And that should be enough in most cases!
+ *
+ * @author Xavier Hanin
+ */
+public class Ivy14 {
+ private Ivy _ivy;
+
+ public Ivy14() {
+ this(Ivy.newInstance());
+ }
+
+ public Ivy14(Ivy ivy) {
+ _ivy = ivy;
+ }
+
+ public boolean check(URL ivyFile, String resolvername) {
+ return _ivy.check(ivyFile, resolvername);
+ }
+
+ public void configure(File settingsFile) throws ParseException,
IOException {
+ _ivy.configure(settingsFile);
+ }
+
+ public void configure(URL settingsURL) throws ParseException,
IOException {
+ _ivy.configure(settingsURL);
+ }
+
+ public void configureDefault() throws ParseException, IOException {
+ _ivy.configureDefault();
+ }
+
+ public void deliver(ModuleRevisionId mrid, String revision, File cache,
String destIvyPattern, String status, Date pubdate,
PublishingDependencyRevisionResolver pdrResolver, boolean validate, boolean
resolveDynamicRevisions) throws IOException, ParseException {
+ _ivy.deliver(mrid, revision, destIvyPattern, new
DeliverOptions(status, pubdate, CacheManager.getInstance(_ivy.getSettings(),
cache), pdrResolver, validate, resolveDynamicRevisions));
+ }
+
+ public void deliver(ModuleRevisionId mrid, String revision, File cache,
String destIvyPattern, String status, Date pubdate,
PublishingDependencyRevisionResolver pdrResolver, boolean validate) throws
IOException, ParseException {
+ deliver(mrid, revision, cache, destIvyPattern, status, pubdate,
pdrResolver, validate, true);
+ }
+
+ public Map determineArtifactsToCopy(ModuleId moduleId, String[] confs,
File cache, String destFilePattern, String destIvyPattern, Filter
artifactFilter) throws ParseException, IOException {
+ return _ivy.determineArtifactsToCopy(moduleId, confs, cache,
destFilePattern, destIvyPattern, artifactFilter);
+ }
+
+ public Map determineArtifactsToCopy(ModuleId moduleId, String[] confs,
File cache, String destFilePattern, String destIvyPattern) throws
ParseException, IOException {
+ return _ivy.determineArtifactsToCopy(moduleId, confs, cache,
destFilePattern, destIvyPattern);
+ }
+
+ public ArtifactDownloadReport download(Artifact artifact, File cache,
boolean useOrigin) {
+ return _ivy.download(artifact, cache, useOrigin);
+ }
+
+ public void downloadArtifacts(ResolveReport report, CacheManager
cacheManager, boolean useOrigin, Filter artifactFilter) {
+ _ivy.downloadArtifacts(report, cacheManager, useOrigin,
artifactFilter);
+ }
+
+ public ResolvedModuleRevision findModule(ModuleRevisionId id) {
+ return _ivy.findModule(id);
+ }
+
+ public IvyNode[] getDependencies(ModuleDescriptor md, String[] confs,
File cache, Date date, ResolveReport report, boolean validate, boolean
transitive) {
+ return _ivy.getDependencies(md, confs, cache, date, report,
validate, transitive);
+ }
+
+ public IvyNode[] getDependencies(ModuleDescriptor md, String[] confs,
File cache, Date date, ResolveReport report, boolean validate) {
+ return _ivy.getDependencies(md, confs, cache, date, report,
validate);
+ }
+
+ public IvyNode[] getDependencies(URL ivySource, String[] confs, File
cache, Date date, boolean validate) throws ParseException, IOException {
+ return _ivy.getDependencies(ivySource, confs, cache, date,
validate);
+ }
+
+ public String getVariable(String name) {
+ return _ivy.getVariable(name);
+ }
+
+ public ResolveReport install(ModuleRevisionId mrid, String from, String
to, boolean transitive, boolean validate, boolean overwrite, Filter
artifactFilter, File cache, String matcherName) throws IOException {
+ return _ivy.install(mrid, from, to, transitive, validate,
overwrite, artifactFilter, cache, matcherName);
+ }
+
+ public void interrupt() {
+ _ivy.interrupt();
+ }
+
+ public void interrupt(Thread operatingThread) {
+ _ivy.interrupt(operatingThread);
+ }
+
+ public boolean isInterrupted() {
+ return _ivy.isInterrupted();
+ }
+
+ public ModuleEntry[] listModuleEntries(OrganisationEntry org) {
+ return _ivy.listModuleEntries(org);
+ }
+
+ public ModuleId[] listModules(ModuleId criteria, PatternMatcher
matcher) {
+ return _ivy.listModules(criteria, matcher);
+ }
+
+ public ModuleRevisionId[] listModules(ModuleRevisionId criteria,
PatternMatcher matcher) {
+ return _ivy.listModules(criteria, matcher);
+ }
+
+ public String[] listModules(String org) {
+ return _ivy.listModules(org);
+ }
+
+ public OrganisationEntry[] listOrganisationEntries() {
+ return _ivy.listOrganisationEntries();
+ }
+
+ public String[] listOrganisations() {
+ return _ivy.listOrganisations();
+ }
+
+ public RevisionEntry[] listRevisionEntries(ModuleEntry module) {
+ return _ivy.listRevisionEntries(module);
+ }
+
+ public String[] listRevisions(String org, String module) {
+ return _ivy.listRevisions(org, module);
+ }
+
+ public String[] listTokenValues(String token, Map otherTokenValues) {
+ return _ivy.listTokenValues(token, otherTokenValues);
+ }
+
+ public Collection publish(ModuleDescriptor md, DependencyResolver
resolver, Collection srcArtifactPattern, String srcIvyPattern, Artifact[]
extraArtifacts, boolean overwrite, String conf) throws IOException {
+ return _ivy.publish(md, resolver, srcArtifactPattern,
srcIvyPattern, extraArtifacts, overwrite, conf);
+ }
+
+ public Collection publish(ModuleRevisionId mrid, String pubrevision,
File cache, Collection srcArtifactPattern, String resolverName, String
srcIvyPattern, String status, Date pubdate, Artifact[] extraArtifacts, boolean
validate, boolean overwrite, boolean update, String conf) throws IOException {
+ return _ivy.publish(mrid, pubrevision, cache,
srcArtifactPattern, resolverName, srcIvyPattern, status, pubdate,
extraArtifacts, validate, overwrite, update, conf);
+ }
+
+ public Collection publish(ModuleRevisionId mrid, String pubrevision,
File cache, String srcArtifactPattern, String resolverName, String
srcIvyPattern, boolean validate, boolean overwrite) throws IOException {
+ return _ivy.publish(mrid, pubrevision, cache,
srcArtifactPattern, resolverName, srcIvyPattern, validate, overwrite);
+ }
+
+ public Collection publish(ModuleRevisionId mrid, String pubrevision,
File cache, String srcArtifactPattern, String resolverName, String
srcIvyPattern, boolean validate) throws IOException {
+ return _ivy.publish(mrid, pubrevision, cache,
srcArtifactPattern, resolverName, srcIvyPattern, validate);
+ }
+
+ public Collection publish(ModuleRevisionId mrid, String pubrevision,
File cache, String srcArtifactPattern, String resolverName, String
srcIvyPattern, String status, Date pubdate, Artifact[] extraArtifacts, boolean
validate, boolean overwrite, boolean update, String conf) throws IOException {
+ return _ivy.publish(mrid, pubrevision, cache,
srcArtifactPattern, resolverName, srcIvyPattern, status, pubdate,
extraArtifacts, validate, overwrite, update, conf);
+ }
+
+ public ResolveReport resolve(File ivySource) throws ParseException,
IOException {
+ return _ivy.resolve(ivySource);
+ }
+
+ public ResolveReport resolve(ModuleDescriptor md, String[] confs, File
cache, Date date, boolean validate, boolean useCacheOnly, boolean transitive,
boolean useOrigin, boolean download, boolean outputReport, Filter
artifactFilter) throws ParseException, IOException, FileNotFoundException {
+ return _ivy.resolve(md, confs, cache, date, validate,
useCacheOnly, transitive, useOrigin, download, outputReport, artifactFilter);
+ }
+
+ public ResolveReport resolve(ModuleDescriptor md, String[] confs, File
cache, Date date, boolean validate, boolean useCacheOnly, boolean transitive,
boolean download, boolean outputReport, Filter artifactFilter) throws
ParseException, IOException, FileNotFoundException {
+ return _ivy.resolve(md, confs, cache, date, validate,
useCacheOnly, transitive, download, outputReport, artifactFilter);
+ }
+
+ public ResolveReport resolve(ModuleDescriptor md, String[] confs, File
cache, Date date, boolean validate, boolean useCacheOnly, boolean transitive,
Filter artifactFilter) throws ParseException, IOException,
FileNotFoundException {
+ return _ivy.resolve(md, confs, cache, date, validate,
useCacheOnly, transitive, artifactFilter);
+ }
+
+ public ResolveReport resolve(ModuleDescriptor md, String[] confs, File
cache, Date date, boolean validate, boolean useCacheOnly, Filter
artifactFilter) throws ParseException, IOException, FileNotFoundException {
+ return _ivy.resolve(md, confs, cache, date, validate,
useCacheOnly, artifactFilter);
+ }
+
+ public ResolveReport resolve(ModuleRevisionId mrid, String[] confs,
boolean transitive, boolean changing, File cache, Date date, boolean validate,
boolean useCacheOnly, boolean useOrigin, Filter artifactFilter) throws
ParseException, IOException {
+ return _ivy.resolve(mrid, confs, transitive, changing, cache,
date, validate, useCacheOnly, useOrigin, artifactFilter);
+ }
+
+ public ResolveReport resolve(ModuleRevisionId mrid, String[] confs,
boolean transitive, boolean changing, File cache, Date date, boolean validate,
boolean useCacheOnly, Filter artifactFilter) throws ParseException, IOException
{
+ return _ivy.resolve(mrid, confs, transitive, changing, cache,
date, validate, useCacheOnly, artifactFilter);
+ }
+
+ public ResolveReport resolve(ModuleRevisionId mrid, String[] confs)
throws ParseException, IOException {
+ return _ivy.resolve(mrid, confs);
+ }
+
+ public ResolveReport resolve(URL ivySource, String revision, String[]
confs, File cache, Date date, boolean validate, boolean useCacheOnly, boolean
transitive, boolean useOrigin, Filter artifactFilter) throws ParseException,
IOException {
+ return _ivy.resolve(ivySource, revision, confs, cache, date,
validate, useCacheOnly, transitive, useOrigin, artifactFilter);
+ }
+
+ public ResolveReport resolve(URL ivySource, String revision, String[]
confs, File cache, Date date, boolean validate, boolean useCacheOnly, boolean
transitive, Filter artifactFilter) throws ParseException, IOException {
+ return _ivy.resolve(ivySource, revision, confs, cache, date,
validate, useCacheOnly, transitive, artifactFilter);
+ }
+
+ public ResolveReport resolve(URL ivySource, String revision, String[]
confs, File cache, Date date, boolean validate, boolean useCacheOnly, Filter
artifactFilter) throws ParseException, IOException {
+ return _ivy.resolve(ivySource, revision, confs, cache, date,
validate, useCacheOnly, artifactFilter);
+ }
+
+ public ResolveReport resolve(URL ivySource, String revision, String[]
confs, File cache, Date date, boolean validate, boolean useCacheOnly) throws
ParseException, IOException {
+ return _ivy.resolve(ivySource, revision, confs, cache, date,
validate, useCacheOnly);
+ }
+
+ public ResolveReport resolve(URL ivySource, String revision, String[]
confs, File cache, Date date, boolean validate) throws ParseException,
IOException {
+ return _ivy.resolve(ivySource, revision, confs, cache, date,
validate);
+ }
+
+ public ResolveReport resolve(URL ivySource) throws ParseException,
IOException {
+ return _ivy.resolve(ivySource);
+ }
+
+ public int retrieve(ModuleId moduleId, String[] confs, File cache,
String destFilePattern, String destIvyPattern, Filter artifactFilter, boolean
sync, boolean useOrigin, boolean makeSymlinks) {
+ return _ivy.retrieve(moduleId, confs, cache, destFilePattern,
destIvyPattern, artifactFilter, sync, useOrigin, makeSymlinks);
+ }
+
+ public int retrieve(ModuleId moduleId, String[] confs, File cache,
String destFilePattern, String destIvyPattern, Filter artifactFilter, boolean
sync, boolean useOrigin) {
+ return _ivy.retrieve(moduleId, confs, cache, destFilePattern,
destIvyPattern, artifactFilter, sync, useOrigin);
+ }
+
+ public int retrieve(ModuleId moduleId, String[] confs, File cache,
String destFilePattern, String destIvyPattern, Filter artifactFilter) {
+ return _ivy.retrieve(moduleId, confs, cache, destFilePattern,
destIvyPattern, artifactFilter);
+ }
+
+ public int retrieve(ModuleId moduleId, String[] confs, File cache,
String destFilePattern, String destIvyPattern) {
+ return _ivy.retrieve(moduleId, confs, cache, destFilePattern,
destIvyPattern);
+ }
+
+ public int retrieve(ModuleId moduleId, String[] confs, File cache,
String destFilePattern) {
+ return _ivy.retrieve(moduleId, confs, cache, destFilePattern);
+ }
+
+ public void setVariable(String varName, String value) {
+ _ivy.setVariable(varName, value);
+ }
+
+ public List sortModuleDescriptors(Collection moduleDescriptors) {
+ return _ivy.sortModuleDescriptors(moduleDescriptors);
+ }
+
+ public List sortNodes(Collection nodes) {
+ return _ivy.sortNodes(nodes);
+ }
+
+ public String substitute(String str) {
+ return _ivy.substitute(str);
+ }
+
+
+}
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=501916&r1=501915&r2=501916
==============================================================================
--- 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
09:29:49 2007
@@ -39,7 +39,8 @@
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
-import org.apache.ivy.core.deliver.DefaultPublishingDRResolver;
+import org.apache.ivy.core.cache.CacheManager;
+import org.apache.ivy.core.deliver.DeliverOptions;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
@@ -220,7 +221,7 @@
String confPath = line.getOptionValue("conf", "");
if ("".equals(confPath)) {
- ivy.getSettings().loadDefault();
+ ivy.configureDefault();
} else {
File conffile = new File(confPath);
if (!conffile.exists()) {
@@ -237,6 +238,7 @@
} else if (!cache.isDirectory()) {
error(options, cache+" is not a directory");
}
+ CacheManager cacheManager =
CacheManager.getInstance(ivy.getSettings(), cache);
String[] confs;
if (line.hasOption("confs")) {
@@ -303,15 +305,15 @@
}
if (line.hasOption("revision")) {
- ivy.deliver(
+ ivy.deliver(
md.getResolvedModuleRevisionId(),
ivy.getSettings().substitute(line.getOptionValue("revision")),
- cache,
ivy.getSettings().substitute(line.getOptionValue("deliverto",
"ivy-[revision].xml")),
- ivy.getSettings().substitute(line.getOptionValue("status",
"release")),
- null,
- new DefaultPublishingDRResolver(),
- validate);
+ DeliverOptions.newInstance(ivy.getSettings())
+
.setStatus(ivy.getSettings().substitute(line.getOptionValue("status",
"release")))
+ .setValidate(validate)
+ .setCache(cacheManager)
+ );
if (line.hasOption("publish")) {
ivy.publish(
md.getResolvedModuleRevisionId(),
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=501916&r1=501915&r2=501916
==============================================================================
--- 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 09:29:49 2007
@@ -22,7 +22,9 @@
import org.apache.ivy.Ivy;
import org.apache.ivy.core.IvyContext;
+import org.apache.ivy.core.cache.CacheManager;
import org.apache.ivy.core.deliver.DefaultPublishingDRResolver;
+import org.apache.ivy.core.deliver.DeliverOptions;
import org.apache.ivy.core.deliver.PublishingDependencyRevisionResolver;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleRevisionId;
@@ -359,8 +361,10 @@
} else {
drResolver = new DefaultPublishingDRResolver();
}
- ivy.deliver(mrid, _pubRevision, _cache, _deliverpattern, _status,
- pubdate, drResolver, doValidate(settings),
_replacedynamicrev);
+ ivy.deliver(mrid, _pubRevision, _deliverpattern,
+ new DeliverOptions(_status, pubdate,
+ CacheManager.getInstance(settings,
_cache),
+ 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/core/IvyContext.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/IvyContext.java?view=diff&rev=501916&r1=501915&r2=501916
==============================================================================
--- 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 09:29:49 2007
@@ -148,8 +148,7 @@
}
public CacheManager getCacheManager() {
- // TODO : reuse one instance
- return new CacheManager(getSettings(), getCache());
+ return CacheManager.getInstance(getSettings(), getCache());
}
public void checkInterrupted() {
Modified:
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=diff&rev=501916&r1=501915&r2=501916
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java
Wed Jan 31 09:29:49 2007
@@ -33,6 +33,13 @@
import org.apache.ivy.util.PropertiesFile;
public class CacheManager {
+ public static CacheManager getInstance(IvySettings settings, File
cache) {
+ return new CacheManager(settings, cache);
+ }
+
+ public static CacheManager getInstance(IvySettings settings) {
+ return getInstance(settings, settings.getDefaultCache());
+ }
private IvySettings _settings;
private File _cache;
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngine.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngine.java?view=diff&rev=501916&r1=501915&r2=501916
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngine.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/check/CheckEngine.java
Wed Jan 31 09:29:49 2007
@@ -50,7 +50,7 @@
/**
- * Checks the given ivy file using current configuration to see if all
dependencies
+ * Checks the given ivy file using current settings to see if all
dependencies
* are available, with good confs. If a resolver name is given, it also
checks that the declared
* publications are available in the corresponding resolver.
* Note that the check is not performed recursively, i.e. if a dependency
has itself dependencies
Modified:
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverEngine.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverEngine.java?view=diff&rev=501916&r1=501915&r2=501916
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverEngine.java
(original)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverEngine.java
Wed Jan 31 09:29:49 2007
@@ -23,14 +23,12 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.text.ParseException;
-import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import org.apache.ivy.core.IvyPatternHelper;
-import org.apache.ivy.core.cache.CacheManager;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleRevisionId;
@@ -47,51 +45,26 @@
_settings = settings;
}
- public void deliver(ModuleRevisionId mrid,
- String revision,
- File cache,
- String destIvyPattern,
- String status,
- Date pubdate,
- PublishingDependencyRevisionResolver pdrResolver,
- boolean validate
- ) throws IOException, ParseException {
- deliver(mrid, revision, cache, destIvyPattern, status, pubdate,
pdrResolver, validate, true);
- }
-
/**
- * delivers a resolved ivy file based upon last resolve call status and
- * the given PublishingDependencyRevisionResolver.
- * If resolve report file cannot be found in cache, then it throws
- * an IllegalStateException (maybe resolve has not been called before ?)
- * Moreover, the given PublishingDependencyRevisionResolver is used for
each
- * dependency to get its published information. This can particularly
useful
- * when the publish is made for a delivery, and when we wish to deliver
each
- * dependency which is still in integration. The
PublishingDependencyRevisionResolver
- * can then do the delivering work for the dependency and return the new
(delivered)
- * dependency info (with the delivered revision). Note that
- * PublishingDependencyRevisionResolver is only called for each
<b>direct</b> dependency.
+ * Delivers a resolved ivy file based upon last resolve call status.
*
- * @param status the new status, null to keep the old one
- * @throws ParseException
+ * If resolve report file cannot be found in cache, then it throws
+ * an IllegalStateException (maybe resolve has not been called before ?).
+ *
+ * @param mrid the module revision id of the module to deliver
+ * @param revision the revision to which the module should be delivered
+ * @param destIvyPattern the pattern to which the delivered ivy file
should be written
+ * @param options the options with which deliver should be done
*/
- public void deliver(ModuleRevisionId mrid,
- String revision,
- File cache,
- String destIvyPattern,
- String status,
- Date pubdate,
- PublishingDependencyRevisionResolver pdrResolver,
- boolean validate,
- boolean resolveDynamicRevisions) throws IOException,
ParseException {
- Message.info(":: delivering :: "+mrid+" :: "+revision+" :: "+status+"
:: "+pubdate);
- Message.verbose("\tvalidate = "+validate);
+ public void deliver(ModuleRevisionId mrid, String revision,
+ String destIvyPattern, DeliverOptions options) throws
IOException, ParseException {
+ Message.info(":: delivering :: "+mrid+" :: "+revision+" ::
"+options.getStatus()+" :: "+options.getPubdate());
+ Message.verbose("\toptions = "+options);
long start = System.currentTimeMillis();
destIvyPattern = _settings.substitute(destIvyPattern);
- CacheManager cacheManager = getCacheManager(cache);
// 1) find the resolved module descriptor in cache
- File ivyFile = cacheManager.getResolvedIvyFileInCache(mrid);
+ File ivyFile = options.getCache().getResolvedIvyFileInCache(mrid);
if (!ivyFile.exists()) {
throw new IllegalStateException("ivy file not found in cache for
"+mrid+": please resolve dependencies before publishing ("+ivyFile+")");
}
@@ -99,9 +72,9 @@
URL ivyFileURL = null;
try {
ivyFileURL = ivyFile.toURL();
- md =
XmlModuleDescriptorParser.getInstance().parseDescriptor(_settings, ivyFileURL,
validate);
+ md =
XmlModuleDescriptorParser.getInstance().parseDescriptor(_settings, ivyFileURL,
options.isValidate());
md.setResolvedModuleRevisionId(ModuleRevisionId.newInstance(mrid,
revision));
- md.setResolvedPublicationDate(pubdate);
+ md.setResolvedPublicationDate(options.getPubdate());
} catch (MalformedURLException e) {
throw new RuntimeException("malformed url obtained for file
"+ivyFile , e);
} catch (ParseException e) {
@@ -111,7 +84,7 @@
// 2) parse resolvedRevisions From properties file
Map resolvedRevisions = new HashMap(); // Map (ModuleId -> String
revision)
Map dependenciesStatus = new HashMap(); // Map (ModuleId -> String
status)
- File ivyProperties =
cacheManager.getResolvedIvyPropertiesInCache(mrid);
+ File ivyProperties =
options.getCache().getResolvedIvyPropertiesInCache(mrid);
if (!ivyProperties.exists()) {
throw new IllegalStateException("ivy properties not found in cache
for "+mrid+": please resolve dependencies before publishing ("+ivyFile+")");
}
@@ -122,7 +95,7 @@
String depMridStr = (String)iter.next();
String[] parts = props.getProperty(depMridStr).split(" ");
ModuleRevisionId decodedMrid = ModuleRevisionId.decode(depMridStr);
- if (resolveDynamicRevisions) {
+ if (options.isResolveDynamicRevisions()) {
resolvedRevisions.put(decodedMrid, parts[0]);
}
dependenciesStatus.put(decodedMrid, parts[1]);
@@ -138,7 +111,7 @@
}
String depStatus =
(String)dependenciesStatus.get(dependencies[i].getDependencyRevisionId());
resolvedDependencies.put(dependencies[i].getDependencyRevisionId(),
- pdrResolver.resolve(md, status,
+ options.getPdrResolver().resolve(md, options.getStatus(),
ModuleRevisionId.newInstance(dependencies[i].getDependencyRevisionId(), rev),
depStatus));
}
@@ -151,17 +124,11 @@
try {
XmlModuleDescriptorUpdater.update(_settings, ivyFileURL,
new File(publishedIvy),
- resolvedDependencies, status, revision, pubdate, null,
true);
+ resolvedDependencies, options.getStatus(), revision,
options.getPubdate(), null, true);
} catch (SAXException ex) {
throw new RuntimeException("bad ivy file in cache for "+mrid+":
please clean and resolve again" , ex);
}
Message.verbose("\tdeliver done
("+(System.currentTimeMillis()-start)+"ms)");
}
-
- private CacheManager getCacheManager(File cache) {
- //TODO : reuse instance
- CacheManager cacheManager = new CacheManager(_settings, cache);
- return cacheManager;
- }
}
Added:
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverOptions.java
URL:
http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverOptions.java?view=auto&rev=501916
==============================================================================
---
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverOptions.java
(added)
+++
incubator/ivy/core/trunk/src/java/org/apache/ivy/core/deliver/DeliverOptions.java
Wed Jan 31 09:29:49 2007
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivy.core.deliver;
+
+import java.util.Date;
+
+import org.apache.ivy.core.cache.CacheManager;
+import org.apache.ivy.core.settings.IvySettings;
+
+/**
+ * A set of options used to do a deliver.
+ */
+public class DeliverOptions {
+ private String _status;
+ private Date _pubdate;
+ private CacheManager _cache;
+ private PublishingDependencyRevisionResolver _pdrResolver = new
DefaultPublishingDRResolver();
+ private boolean _validate = true;
+ private boolean _resolveDynamicRevisions = true;
+
+ /**
+ * Returns an instance of DeliverOptions with options corresponding to
default values
+ * taken from the given settings.
+ *
+ * @param settings The settings to use to get default option values
+ * @return a DeliverOptions instance ready to be used or customized
+ */
+ public static DeliverOptions newInstance(IvySettings settings) {
+ return new DeliverOptions(null, new Date(),
CacheManager.getInstance(settings),
+ new DefaultPublishingDRResolver(),
+ settings.doValidate(),
+ true);
+ }
+
+ /**
+ * Creates an instance of DeliverOptions which require to be configured
+ * using the appropriate setters.
+ */
+ public DeliverOptions() {
+ }
+
+ /**
+ * Creates an instance of DeliverOptions with all options explicitly
set.
+ */
+ public DeliverOptions(String status, Date pubDate, CacheManager cache,
PublishingDependencyRevisionResolver pdrResolver, boolean validate, boolean
resolveDynamicRevisions) {
+ _status = status;
+ _pubdate = pubDate;
+ _cache = cache;
+ _pdrResolver = pdrResolver;
+ _validate = validate;
+ _resolveDynamicRevisions = resolveDynamicRevisions;
+ }
+
+ public CacheManager getCache() {
+ return _cache;
+ }
+
+ public DeliverOptions setCache(CacheManager cache) {
+ _cache = cache;
+ return this;
+ }
+
+ /**
+ * Return the pdrResolver that will be used during deliver for each
+ * dependency to get its published information.
+ * This can particularly useful
+ * when the deliver is made for a release, and when we wish to deliver
each
+ * dependency which is still in integration. The
PublishingDependencyRevisionResolver
+ * can then do the delivering work for the dependency and return the
new (delivered)
+ * dependency info (with the delivered revision). Note that
+ * PublishingDependencyRevisionResolver is only called for each
<b>direct</b> dependency.
+ * @return the pdrResolver that will be used during deliver
+ */
+ public PublishingDependencyRevisionResolver getPdrResolver() {
+ return _pdrResolver;
+ }
+
+ /**
+ * Sets the pdrResolver that will be used during deliver for each
+ * dependency to get its published information.
+ * This can particularly useful
+ * when the deliver is made for a release, and when we wish to deliver
each
+ * dependency which is still in integration. The
PublishingDependencyRevisionResolver
+ * can then do the delivering work for the dependency and return the
new (delivered)
+ * dependency info (with the delivered revision). Note that
+ * PublishingDependencyRevisionResolver is only called for each
<b>direct</b> dependency.
+ * @return the instance of DeliverOptions on which the method has been
called,
+ * for easy method chaining
+ */
+ public DeliverOptions
setPdrResolver(PublishingDependencyRevisionResolver pdrResolver) {
+ _pdrResolver = pdrResolver;
+ return this;
+ }
+
+ public boolean isResolveDynamicRevisions() {
+ return _resolveDynamicRevisions;
+ }
+
+ public DeliverOptions setResolveDynamicRevisions(boolean
resolveDynamicRevisions) {
+ _resolveDynamicRevisions = resolveDynamicRevisions;
+ return this;
+ }
+
+ public boolean isValidate() {
+ return _validate;
+ }
+
+ public DeliverOptions setValidate(boolean validate) {
+ _validate = validate;
+ return this;
+ }
+
+ public Date getPubdate() {
+ return _pubdate;
+ }
+
+ public DeliverOptions setPubdate(Date pubdate) {
+ _pubdate = pubdate;
+ return this;
+ }
+
+ /**
+ * Returns the status to which the module should be delivered,
+ * or null if the current status should be kept.
+ * @return the status to which the module should be delivered
+ */
+ public String getStatus() {
+ return _status;
+ }
+
+ /**
+ * Sets the status to which the module should be delivered,
+ * use null if the current status should be kept.
+ * @return the instance of DeliverOptions on which the method has been
called,
+ * for easy method chaining
+ */
+ public DeliverOptions setStatus(String status) {
+ _status = status;
+ return this;
+ }
+
+ public String toString() {
+ return "status="+_status+" pubdate="+_pubdate+"
validate="+_validate+" resolveDynamicRevisions="+_resolveDynamicRevisions+"
cache="+_cache;
+ }
+
+}