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/06/05 12:02:43 UTC
svn commit: r544459 [9/36] - 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/check/ src/java/org/apache/ivy/core/deliver/...
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRevisionId.java Tue Jun 5 05:02:27 2007
@@ -26,84 +26,105 @@
import org.apache.ivy.core.IvyPatternHelper;
import org.apache.ivy.util.extendable.UnmodifiableExtendableItem;
-
-
/**
*
*/
public class ModuleRevisionId extends UnmodifiableExtendableItem {
private static final String ENCODE_SEPARATOR = ModuleId.ENCODE_SEPARATOR;
+
private static final String ENCODE_PREFIX = "+";
+
private static final String NULL_ENCODE = "@#:NULL:#@";
-
+
public static ModuleRevisionId newInstance(String organisation, String name, String revision) {
return new ModuleRevisionId(new ModuleId(organisation, name), revision);
}
- public static ModuleRevisionId newInstance(String organisation, String name, String revision, Map extraAttributes) {
+
+ public static ModuleRevisionId newInstance(String organisation, String name, String revision,
+ Map extraAttributes) {
return new ModuleRevisionId(new ModuleId(organisation, name), revision, extraAttributes);
}
- public static ModuleRevisionId newInstance(String organisation, String name, String branch, String revision) {
+
+ public static ModuleRevisionId newInstance(String organisation, String name, String branch,
+ String revision) {
return new ModuleRevisionId(new ModuleId(organisation, name), branch, revision);
}
- public static ModuleRevisionId newInstance(String organisation, String name, String branch, String revision, Map extraAttributes) {
- return new ModuleRevisionId(new ModuleId(organisation, name), branch, revision, extraAttributes);
+
+ public static ModuleRevisionId newInstance(String organisation, String name, String branch,
+ String revision, Map extraAttributes) {
+ return new ModuleRevisionId(new ModuleId(organisation, name), branch, revision,
+ extraAttributes);
}
- public static ModuleRevisionId newInstance(ModuleRevisionId mrid, String rev) {
- return new ModuleRevisionId(mrid.getModuleId(), mrid.getBranch(), rev, mrid.getExtraAttributes());
- }
-
+
+ public static ModuleRevisionId newInstance(ModuleRevisionId mrid, String rev) {
+ return new ModuleRevisionId(mrid.getModuleId(), mrid.getBranch(), rev, mrid
+ .getExtraAttributes());
+ }
+
private ModuleId moduleId;
+
private String branch;
+
private String revision;
+
private int hash;
-
+
public ModuleRevisionId(ModuleId moduleId, String revision) {
this(moduleId, null, revision, null);
}
+
public ModuleRevisionId(ModuleId moduleId, String branch, String revision) {
this(moduleId, branch, revision, null);
}
+
public ModuleRevisionId(ModuleId moduleId, String revision, Map extraAttributes) {
- this(moduleId, null, revision, extraAttributes);
+ this(moduleId, null, revision, extraAttributes);
}
+
public ModuleRevisionId(ModuleId moduleId, String branch, String revision, Map extraAttributes) {
super(null, extraAttributes);
this.moduleId = moduleId;
- this.branch = branch == null ? IvyContext.getContext().getSettings().getDefaultBranch(moduleId) : branch;
+ this.branch = branch == null ? IvyContext.getContext().getSettings().getDefaultBranch(
+ moduleId) : branch;
this.revision = revision == null ? Ivy.getWorkingRevision() : revision;
- hash = _hashCode(); //stored for performance reasons, hashCode is very used in many maps
+ hash = _hashCode(); // stored for performance reasons, hashCode is very used in many maps
setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY, this.moduleId.getOrganisation());
setStandardAttribute(IvyPatternHelper.MODULE_KEY, this.moduleId.getName());
setStandardAttribute(IvyPatternHelper.BRANCH_KEY, this.branch);
setStandardAttribute(IvyPatternHelper.REVISION_KEY, this.revision);
}
-
+
public ModuleId getModuleId() {
return moduleId;
}
+
public String getName() {
return getModuleId().getName();
}
+
public String getOrganisation() {
return getModuleId().getOrganisation();
}
+
public String getRevision() {
return revision;
}
-
+
public boolean equals(Object obj) {
- if (! (obj instanceof ModuleRevisionId)) {
+ if (!(obj instanceof ModuleRevisionId)) {
return false;
}
- ModuleRevisionId other = (ModuleRevisionId)obj;
+ ModuleRevisionId other = (ModuleRevisionId) obj;
return other.getRevision().equals(getRevision())
- && (other.getBranch() == null ? getBranch() == null : other.getBranch().equals(getBranch()))
- && other.getModuleId().equals(getModuleId())
- && other.getExtraAttributes().equals(getExtraAttributes());
+ && (other.getBranch() == null ? getBranch() == null : other.getBranch().equals(
+ getBranch())) && other.getModuleId().equals(getModuleId())
+ && other.getExtraAttributes().equals(getExtraAttributes());
}
+
public int hashCode() {
return hash;
}
+
public int _hashCode() {
int hash = 31;
hash = hash * 13 + (getBranch() == null ? 0 : getBranch().hashCode());
@@ -112,63 +133,73 @@
hash = hash * 13 + getAttributes().hashCode();
return hash;
}
-
+
public String toString() {
- return "[ "+ moduleId.getOrganisation()+" | "+ moduleId.getName()+(branch == null || branch.length() == 0 ?"":" | "+ branch)+" | "+(revision == null?"NONE": revision)+" ]";
+ return "[ " + moduleId.getOrganisation() + " | " + moduleId.getName()
+ + (branch == null || branch.length() == 0 ? "" : " | " + branch) + " | "
+ + (revision == null ? "NONE" : revision) + " ]";
}
-
+
public String encodeToString() {
StringBuffer buf = new StringBuffer();
Map attributes = getAttributes();
for (Iterator iter = attributes.keySet().iterator(); iter.hasNext();) {
- String attName = (String)iter.next();
+ String attName = (String) iter.next();
String value = (String) attributes.get(attName);
value = value == null ? NULL_ENCODE : value;
- buf.append(ENCODE_PREFIX).append(attName).append(ENCODE_SEPARATOR).append(ENCODE_PREFIX).append(value).append(ENCODE_SEPARATOR);
+ buf.append(ENCODE_PREFIX).append(attName).append(ENCODE_SEPARATOR)
+ .append(ENCODE_PREFIX).append(value).append(ENCODE_SEPARATOR);
}
return buf.toString();
}
-
+
public static ModuleRevisionId decode(String encoded) {
String[] parts = encoded.split(ENCODE_SEPARATOR);
if (parts.length % 2 != 0) {
- throw new IllegalArgumentException("badly encoded module revision id: '"+encoded+"'");
+ throw new IllegalArgumentException("badly encoded module revision id: '" + encoded
+ + "'");
}
Map attributes = new HashMap();
- for (int i = 0; i < parts.length; i+=2) {
+ for (int i = 0; i < parts.length; i += 2) {
String attName = parts[i];
if (!attName.startsWith(ENCODE_PREFIX)) {
- throw new IllegalArgumentException("badly encoded module revision id: '"+encoded+"': "+attName+" doesn't start with "+ENCODE_PREFIX);
+ throw new IllegalArgumentException("badly encoded module revision id: '" + encoded
+ + "': " + attName + " doesn't start with " + ENCODE_PREFIX);
} else {
attName = attName.substring(1);
}
- String attValue = parts[i+1];
+ String attValue = parts[i + 1];
if (!attValue.startsWith(ENCODE_PREFIX)) {
- throw new IllegalArgumentException("badly encoded module revision id: '"+encoded+"': "+attValue+" doesn't start with "+ENCODE_PREFIX);
+ throw new IllegalArgumentException("badly encoded module revision id: '" + encoded
+ + "': " + attValue + " doesn't start with " + ENCODE_PREFIX);
} else {
attValue = attValue.substring(1);
}
if (NULL_ENCODE.equals(attValue)) {
- attValue = null;
+ attValue = null;
}
attributes.put(attName, attValue);
}
- String org = (String)attributes.remove(IvyPatternHelper.ORGANISATION_KEY);
- String mod = (String)attributes.remove(IvyPatternHelper.MODULE_KEY);
- String rev = (String)attributes.remove(IvyPatternHelper.REVISION_KEY);
- String branch = (String)attributes.remove(IvyPatternHelper.BRANCH_KEY);
+ String org = (String) attributes.remove(IvyPatternHelper.ORGANISATION_KEY);
+ String mod = (String) attributes.remove(IvyPatternHelper.MODULE_KEY);
+ String rev = (String) attributes.remove(IvyPatternHelper.REVISION_KEY);
+ String branch = (String) attributes.remove(IvyPatternHelper.BRANCH_KEY);
if (org == null) {
- throw new IllegalArgumentException("badly encoded module revision id: '"+encoded+"': no organisation");
+ throw new IllegalArgumentException("badly encoded module revision id: '" + encoded
+ + "': no organisation");
}
if (mod == null) {
- throw new IllegalArgumentException("badly encoded module revision id: '"+encoded+"': no module name");
+ throw new IllegalArgumentException("badly encoded module revision id: '" + encoded
+ + "': no module name");
}
if (rev == null) {
- throw new IllegalArgumentException("badly encoded module revision id: '"+encoded+"': no revision");
+ throw new IllegalArgumentException("badly encoded module revision id: '" + encoded
+ + "': no revision");
}
return newInstance(org, mod, branch, rev, attributes);
}
- public String getBranch() {
- return branch;
- }
+
+ public String getBranch() {
+ return branch;
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/status/Status.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/status/Status.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/status/Status.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/status/Status.java Tue Jun 5 05:02:27 2007
@@ -19,24 +19,29 @@
public class Status {
private String name;
+
private boolean integration;
-
+
public Status() {
}
-
+
public Status(String name, boolean integration) {
this.name = name;
this.integration = integration;
}
+
public boolean isIntegration() {
return integration;
}
+
public void setIntegration(boolean integration) {
this.integration = integration;
}
+
public String getName() {
return name;
}
+
public void setName(String name) {
this.name = name;
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/status/StatusManager.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/status/StatusManager.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/status/StatusManager.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/module/status/StatusManager.java Tue Jun 5 05:02:27 2007
@@ -28,29 +28,29 @@
import org.apache.ivy.core.IvyContext;
import org.apache.ivy.util.Message;
-
/**
- * Note: update methods (such as addStatus) should only be called BEFORE any call to accessor methods
- *
+ * Note: update methods (such as addStatus) should only be called BEFORE any call to accessor
+ * methods
*/
public class StatusManager {
public static StatusManager newDefaultInstance() {
- return new StatusManager(new Status[] {
- new Status("release", false),
- new Status("milestone", false),
- new Status("integration", true)}, "integration");
+ return new StatusManager(new Status[] {new Status("release", false),
+ new Status("milestone", false), new Status("integration", true)}, "integration");
}
-
+
public static StatusManager getCurrent() {
return IvyContext.getContext().getSettings().getStatusManager();
}
-
+
private List status = new ArrayList();
+
private String defaultStatus;
-
+
// for easier querying only
private Map statusPriorityMap;
+
private Map statusIntegrationMap;
+
private String deliveryStatusListString;
public StatusManager(Status[] status, String defaultStatus) {
@@ -59,10 +59,10 @@
computeMaps();
}
-
+
public StatusManager() {
}
-
+
public void addStatus(Status status) {
this.status.add(status);
}
@@ -70,27 +70,27 @@
public void setDefaultStatus(String defaultStatus) {
this.defaultStatus = defaultStatus;
}
-
+
public List getStatuses() {
return status;
}
-
+
private void computeMaps() {
if (status.isEmpty()) {
throw new IllegalStateException("badly configured statuses: no status found");
}
statusPriorityMap = new HashMap();
for (ListIterator iter = status.listIterator(); iter.hasNext();) {
- Status status = (Status)iter.next();
+ Status status = (Status) iter.next();
statusPriorityMap.put(status.getName(), new Integer(iter.previousIndex()));
}
statusIntegrationMap = new HashMap();
for (Iterator iter = status.iterator(); iter.hasNext();) {
- Status status = (Status)iter.next();
+ Status status = (Status) iter.next();
statusIntegrationMap.put(status.getName(), Boolean.valueOf(status.isIntegration()));
}
}
-
+
public boolean isStatus(String status) {
if (statusPriorityMap == null) {
computeMaps();
@@ -104,19 +104,19 @@
}
Integer priority = (Integer) statusPriorityMap.get(status);
if (priority == null) {
- Message.debug("unknown status "+status+": assuming lowest priority");
+ Message.debug("unknown status " + status + ": assuming lowest priority");
return Integer.MAX_VALUE;
}
return priority.intValue();
}
-
+
public boolean isIntegration(String status) {
if (statusIntegrationMap == null) {
computeMaps();
}
Boolean isIntegration = (Boolean) statusIntegrationMap.get(status);
if (isIntegration == null) {
- Message.debug("unknown status "+status+": assuming integration");
+ Message.debug("unknown status " + status + ": assuming integration");
return true;
}
return isIntegration.booleanValue();
@@ -126,13 +126,13 @@
if (deliveryStatusListString == null) {
StringBuffer ret = new StringBuffer();
for (Iterator iter = status.iterator(); iter.hasNext();) {
- Status status = (Status)iter.next();
+ Status status = (Status) iter.next();
if (!status.isIntegration()) {
- ret.append(status.getName()).append(",");
+ ret.append(status.getName()).append(",");
}
}
if (ret.length() > 0) {
- ret.deleteCharAt(ret.length()-1);
+ ret.deleteCharAt(ret.length() - 1);
}
deliveryStatusListString = ret.toString();
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishEngine.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishEngine.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishEngine.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishEngine.java Tue Jun 5 05:02:27 2007
@@ -48,141 +48,151 @@
import org.xml.sax.SAXException;
public class PublishEngine {
- private IvySettings settings;
-
+ private IvySettings settings;
+
public PublishEngine(IvySettings settings) {
- this.settings = settings;
- }
+ this.settings = settings;
+ }
+
/**
- * Publishes a module to the repository.
- *
- * The publish can update the ivy file to publish if update is set to true. In this case it will use
- * the given pubrevision, pubdate and status. If pubdate is null it will default to the current date.
- * If status is null it will default to the current ivy file status (which itself defaults to integration if none is found).
- * If update is false, then if the revision is not the same in the ivy file than the one expected (given as parameter),
- * this method will fail with an IllegalArgumentException.
- * pubdate and status are not used if update is false.
- * extra artifacts can be used to publish more artifacts than actually declared in the ivy file.
- * This can be useful to publish additional metadata or reports.
- * The extra artifacts array can be null (= no extra artifacts), and if non null only the name, type, ext url
- * and extra attributes of the artifacts are really used. Other methods can return null safely.
- *
+ * Publishes a module to the repository. The publish can update the ivy file to publish if
+ * update is set to true. In this case it will use the given pubrevision, pubdate and status. If
+ * pubdate is null it will default to the current date. If status is null it will default to the
+ * current ivy file status (which itself defaults to integration if none is found). If update is
+ * false, then if the revision is not the same in the ivy file than the one expected (given as
+ * parameter), this method will fail with an IllegalArgumentException. pubdate and status are
+ * not used if update is false. extra artifacts can be used to publish more artifacts than
+ * actually declared in the ivy file. This can be useful to publish additional metadata or
+ * reports. The extra artifacts array can be null (= no extra artifacts), and if non null only
+ * the name, type, ext url and extra attributes of the artifacts are really used. Other methods
+ * can return null safely.
*/
- public Collection publish(ModuleRevisionId mrid, Collection srcArtifactPattern, String resolverName, PublishOptions options) throws IOException {
- Message.info(":: publishing :: "+mrid.getModuleId());
- Message.verbose("\tvalidate = "+options.isValidate());
+ public Collection publish(ModuleRevisionId mrid, Collection srcArtifactPattern,
+ String resolverName, PublishOptions options) throws IOException {
+ Message.info(":: publishing :: " + mrid.getModuleId());
+ Message.verbose("\tvalidate = " + options.isValidate());
long start = System.currentTimeMillis();
-
+
options.setSrcIvyPattern(settings.substitute(options.getSrcIvyPattern()));
if (options.getPubrevision() == null) {
- options.setPubrevision(mrid.getRevision());
+ options.setPubrevision(mrid.getRevision());
}
ModuleRevisionId pubmrid = ModuleRevisionId.newInstance(mrid, options.getPubrevision());
File ivyFile;
if (options.getSrcIvyPattern() != null) {
- ivyFile = new File(IvyPatternHelper.substitute(options.getSrcIvyPattern(), DefaultArtifact.newIvyArtifact(pubmrid, new Date())));
- if (!ivyFile.exists()) {
- throw new IllegalArgumentException("ivy file to publish not found for "+mrid+": call deliver before ("+ivyFile+")");
- }
+ ivyFile = new File(IvyPatternHelper.substitute(options.getSrcIvyPattern(),
+ DefaultArtifact.newIvyArtifact(pubmrid, new Date())));
+ if (!ivyFile.exists()) {
+ throw new IllegalArgumentException("ivy file to publish not found for " + mrid
+ + ": call deliver before (" + ivyFile + ")");
+ }
} else {
- CacheManager cacheManager = getCacheManager(options);
- ivyFile = cacheManager.getResolvedIvyFileInCache(mrid);
- if (!ivyFile.exists()) {
- throw new IllegalStateException("ivy file not found in cache for "+mrid+": please resolve dependencies before publishing ("+ivyFile+")");
- }
+ CacheManager cacheManager = getCacheManager(options);
+ ivyFile = cacheManager.getResolvedIvyFileInCache(mrid);
+ if (!ivyFile.exists()) {
+ throw new IllegalStateException("ivy file not found in cache for " + mrid
+ + ": please resolve dependencies before publishing (" + ivyFile + ")");
+ }
}
-
+
// let's find the resolved module descriptor
ModuleDescriptor md = null;
URL ivyFileURL = null;
try {
- ivyFileURL = ivyFile.toURL();
- md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, ivyFileURL, false);
- if (options.getSrcIvyPattern() != null) {
- if (options.isUpdate()) {
- File tmp = File.createTempFile("ivy", ".xml");
- tmp.deleteOnExit();
-
- String[] confs = ConfigurationUtils.replaceWildcards(options.getConfs(), md);
- Set confsToRemove = new HashSet(Arrays.asList(md.getConfigurationsNames()));
- confsToRemove.removeAll(Arrays.asList(confs));
-
- try {
- XmlModuleDescriptorUpdater.update(
- settings,
- ivyFileURL,
- tmp,
- new HashMap(),
- options.getStatus()==null?md.getStatus():options.getStatus(),
- options.getPubrevision(),
- options.getPubdate()==null?new Date():options.getPubdate(),
- null,
- true,
- (String[]) confsToRemove.toArray(new String[confsToRemove.size()]));
- ivyFile = tmp;
- // we parse the new file to get updated module descriptor
- md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, ivyFile.toURL(), false);
- options.setSrcIvyPattern(ivyFile.getAbsolutePath());
- } catch (SAXException e) {
- throw new IllegalStateException("bad ivy file for "+mrid+": "+ivyFile+": "+e);
- }
- } else if (!options.getPubrevision().equals(md.getModuleRevisionId().getRevision())) {
- throw new IllegalArgumentException("cannot publish "+ivyFile+" as "+options.getPubrevision()+": bad revision found in ivy file (Revision: "+md.getModuleRevisionId().getRevision()+"). Use forcedeliver or update.");
- }
- } else {
- md.setResolvedModuleRevisionId(pubmrid);
- }
+ ivyFileURL = ivyFile.toURL();
+ md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, ivyFileURL,
+ false);
+ if (options.getSrcIvyPattern() != null) {
+ if (options.isUpdate()) {
+ File tmp = File.createTempFile("ivy", ".xml");
+ tmp.deleteOnExit();
+
+ String[] confs = ConfigurationUtils.replaceWildcards(options.getConfs(), md);
+ Set confsToRemove = new HashSet(Arrays.asList(md.getConfigurationsNames()));
+ confsToRemove.removeAll(Arrays.asList(confs));
+
+ try {
+ XmlModuleDescriptorUpdater.update(settings, ivyFileURL, tmp, new HashMap(),
+ options.getStatus() == null ? md.getStatus() : options.getStatus(),
+ options.getPubrevision(), options.getPubdate() == null ? new Date()
+ : options.getPubdate(), null, true, (String[]) confsToRemove
+ .toArray(new String[confsToRemove.size()]));
+ ivyFile = tmp;
+ // we parse the new file to get updated module descriptor
+ md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
+ ivyFile.toURL(), false);
+ options.setSrcIvyPattern(ivyFile.getAbsolutePath());
+ } catch (SAXException e) {
+ throw new IllegalStateException("bad ivy file for " + mrid + ": " + ivyFile
+ + ": " + e);
+ }
+ } else if (!options.getPubrevision().equals(md.getModuleRevisionId().getRevision())) {
+ throw new IllegalArgumentException("cannot publish " + ivyFile + " as "
+ + options.getPubrevision()
+ + ": bad revision found in ivy file (Revision: "
+ + md.getModuleRevisionId().getRevision()
+ + "). Use forcedeliver or update.");
+ }
+ } else {
+ md.setResolvedModuleRevisionId(pubmrid);
+ }
} catch (MalformedURLException e) {
- throw new RuntimeException("malformed url obtained for file "+ivyFile);
+ throw new RuntimeException("malformed url obtained for file " + ivyFile);
} catch (ParseException e) {
- throw new IllegalStateException("bad ivy file for "+mrid+": "+ivyFile+": "+e);
+ throw new IllegalStateException("bad ivy file for " + mrid + ": " + ivyFile + ": " + e);
}
-
+
DependencyResolver resolver = settings.getResolver(resolverName);
if (resolver == null) {
- throw new IllegalArgumentException("unknown resolver "+resolverName);
+ throw new IllegalArgumentException("unknown resolver " + resolverName);
}
-
+
// collect all declared artifacts of this module
Collection missing = publish(md, srcArtifactPattern, resolver, options);
- Message.verbose("\tpublish done ("+(System.currentTimeMillis()-start)+"ms)");
+ Message.verbose("\tpublish done (" + (System.currentTimeMillis() - start) + "ms)");
return missing;
}
- public Collection publish(ModuleDescriptor md, Collection srcArtifactPattern, DependencyResolver resolver, PublishOptions options) throws IOException {
+ public Collection publish(ModuleDescriptor md, Collection srcArtifactPattern,
+ DependencyResolver resolver, PublishOptions options) throws IOException {
Collection missing = new ArrayList();
Set artifactsSet = new HashSet();
- String[] confs = options.getConfs();
- if (confs == null || (confs.length == 1 && "*".equals(confs[0]))) {
- confs = md.getConfigurationsNames();
- }
+ String[] confs = options.getConfs();
+ if (confs == null || (confs.length == 1 && "*".equals(confs[0]))) {
+ confs = md.getConfigurationsNames();
+ }
- for (int i = 0; i < confs.length; i++) {
+ for (int i = 0; i < confs.length; i++) {
Artifact[] artifacts = md.getArtifacts(confs[i]);
for (int j = 0; j < artifacts.length; j++) {
artifactsSet.add(artifacts[j]);
}
}
- Artifact[] extraArtifacts = options.getExtraArtifacts();
+ Artifact[] extraArtifacts = options.getExtraArtifacts();
if (extraArtifacts != null) {
- for (int i = 0; i < extraArtifacts.length; i++) {
- artifactsSet.add(new MDArtifact(md, extraArtifacts[i].getName(), extraArtifacts[i].getType(), extraArtifacts[i].getExt(), extraArtifacts[i].getUrl(), extraArtifacts[i].getExtraAttributes()));
- }
+ for (int i = 0; i < extraArtifacts.length; i++) {
+ artifactsSet.add(new MDArtifact(md, extraArtifacts[i].getName(), extraArtifacts[i]
+ .getType(), extraArtifacts[i].getExt(), extraArtifacts[i].getUrl(),
+ extraArtifacts[i].getExtraAttributes()));
+ }
}
// for each declared published artifact in this descriptor, do:
for (Iterator iter = artifactsSet.iterator(); iter.hasNext();) {
Artifact artifact = (Artifact) iter.next();
- // 1) copy the artifact using src patterns and resolver
+ // 1) copy the artifact using src patterns and resolver
boolean published = false;
- for (Iterator iterator = srcArtifactPattern.iterator(); iterator.hasNext() && !published;) {
- String pattern = (String) iterator.next();
- published = publish(artifact, settings.substitute(pattern), resolver, options.isOverwrite());
- }
+ for (Iterator iterator = srcArtifactPattern.iterator(); iterator.hasNext()
+ && !published;) {
+ String pattern = (String) iterator.next();
+ published = publish(artifact, settings.substitute(pattern), resolver, options
+ .isOverwrite());
+ }
if (!published) {
- Message.info("missing artifact "+artifact+":");
+ Message.info("missing artifact " + artifact + ":");
for (Iterator iterator = srcArtifactPattern.iterator(); iterator.hasNext();) {
- String pattern = (String) iterator.next();
- Message.info("\t"+new File(IvyPatternHelper.substitute(pattern, artifact))+" file does not exist");
+ String pattern = (String) iterator.next();
+ Message.info("\t" + new File(IvyPatternHelper.substitute(pattern, artifact))
+ + " file does not exist");
}
missing.add(artifact);
}
@@ -190,17 +200,21 @@
if (options.getSrcIvyPattern() != null) {
Artifact artifact = MDArtifact.newIvyArtifact(md);
if (!publish(artifact, options.getSrcIvyPattern(), resolver, options.isOverwrite())) {
- Message.info("missing ivy file for "+md.getModuleRevisionId()+": "
- + new File(IvyPatternHelper.substitute(options.getSrcIvyPattern(), artifact))
- + " file does not exist");
+ Message.info("missing ivy file for "
+ + md.getModuleRevisionId()
+ + ": "
+ + new File(IvyPatternHelper
+ .substitute(options.getSrcIvyPattern(), artifact))
+ + " file does not exist");
missing.add(artifact);
}
}
return missing;
}
- private boolean publish(Artifact artifact, String srcArtifactPattern, DependencyResolver resolver, boolean overwrite) throws IOException {
- IvyContext.getContext().checkInterrupted();
+ private boolean publish(Artifact artifact, String srcArtifactPattern,
+ DependencyResolver resolver, boolean overwrite) throws IOException {
+ IvyContext.getContext().checkInterrupted();
File src = new File(IvyPatternHelper.substitute(srcArtifactPattern, artifact));
if (src.exists()) {
resolver.publish(artifact, src, overwrite);
@@ -210,15 +224,14 @@
}
}
-
- private CacheManager getCacheManager(PublishOptions options) {
- CacheManager cacheManager = options.getCache();
- if (cacheManager == null) { // ensure that a cache is configured
- cacheManager = IvyContext.getContext().getCacheManager();
- options.setCache(cacheManager);
+ private CacheManager getCacheManager(PublishOptions options) {
+ CacheManager cacheManager = options.getCache();
+ if (cacheManager == null) { // ensure that a cache is configured
+ cacheManager = IvyContext.getContext().getCacheManager();
+ options.setCache(cacheManager);
} else {
- IvyContext.getContext().setCache(cacheManager.getCache());
+ IvyContext.getContext().setCache(cacheManager.getCache());
}
- return cacheManager;
- }
+ return cacheManager;
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishOptions.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishOptions.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishOptions.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/publish/PublishOptions.java Tue Jun 5 05:02:27 2007
@@ -23,125 +23,129 @@
import org.apache.ivy.core.module.descriptor.Artifact;
/**
- * A set of options used during publish related tasks
+ * A set of options used during publish related tasks The publish can update the ivy file to publish
+ * if update is set to true. In this case it will use the given pubrevision, pubdate and status. If
+ * pudate is null it will default to the current date. If status is null it will default to the
+ * current ivy file status (which itself defaults to integration if none is found). If update is
+ * false, then if the revision is not the same in the ivy file than the one expected (given as
+ * parameter), this method will fail with an IllegalArgumentException. pubdate and status are not
+ * used if update is false. extra artifacts can be used to publish more artifacts than actually
+ * declared in the ivy file. This can be useful to publish additional metadata or reports. The extra
+ * artifacts array can be null (= no extra artifacts), and if non null only the name, type, ext url
+ * and extra attributes of the artifacts are really used. Other methods (on the artifacts) can
+ * return null safely.
*
- * The publish can update the ivy file to publish if update is set to true. In this case it will use
- * the given pubrevision, pubdate and status. If pudate is null it will default to the current date.
- * If status is null it will default to the current ivy file status (which itself defaults to integration if none is found).
- * If update is false, then if the revision is not the same in the ivy file than the one expected (given as parameter),
- * this method will fail with an IllegalArgumentException.
- * pubdate and status are not used if update is false.
- * extra artifacts can be used to publish more artifacts than actually declared in the ivy file.
- * This can be useful to publish additional metadata or reports.
- * The extra artifacts array can be null (= no extra artifacts), and if non null only the name, type, ext url
- * and extra attributes of the artifacts are really used. Other methods (on the artifacts) can return null safely.
- *
* @see PublishEngine
*/
public class PublishOptions {
- private CacheManager cache;
- private String srcIvyPattern;
-
- private String pubrevision;
- private String status;
- private Date pubdate;
-
- private Artifact[] extraArtifacts;
- private boolean validate;
- private boolean overwrite;
- private boolean update;
-
- private String[] confs;
-
- public CacheManager getCache() {
- return cache;
- }
-
- public PublishOptions setCache(CacheManager cache) {
- this.cache = cache;
- return this;
- }
-
- public String[] getConfs() {
- return confs;
- }
-
- public PublishOptions setConfs(String[] confs) {
- this.confs = confs;
- return this;
- }
-
- public Artifact[] getExtraArtifacts() {
- return extraArtifacts;
- }
-
- public PublishOptions setExtraArtifacts(Artifact[] extraArtifacts) {
- this.extraArtifacts = extraArtifacts;
- return this;
- }
-
- public boolean isOverwrite() {
- return overwrite;
- }
-
- public PublishOptions setOverwrite(boolean overwrite) {
- this.overwrite = overwrite;
- return this;
- }
-
- public Date getPubdate() {
- return pubdate;
- }
-
- public PublishOptions setPubdate(Date pubdate) {
- this.pubdate = pubdate;
- return this;
- }
-
- public String getPubrevision() {
- return pubrevision;
- }
-
- public PublishOptions setPubrevision(String pubrevision) {
- this.pubrevision = pubrevision;
- return this;
- }
-
- public String getSrcIvyPattern() {
- return srcIvyPattern;
- }
-
- public PublishOptions setSrcIvyPattern(String srcIvyPattern) {
- this.srcIvyPattern = srcIvyPattern;
- return this;
- }
-
- public String getStatus() {
- return status;
- }
-
- public PublishOptions setStatus(String status) {
- this.status = status;
- return this;
- }
-
- public boolean isUpdate() {
- return update;
- }
-
- public PublishOptions setUpdate(boolean update) {
- this.update = update;
- return this;
- }
-
- public boolean isValidate() {
- return validate;
- }
-
- public PublishOptions setValidate(boolean validate) {
- this.validate = validate;
- return this;
- }
-
-
+ private CacheManager cache;
+
+ private String srcIvyPattern;
+
+ private String pubrevision;
+
+ private String status;
+
+ private Date pubdate;
+
+ private Artifact[] extraArtifacts;
+
+ private boolean validate;
+
+ private boolean overwrite;
+
+ private boolean update;
+
+ private String[] confs;
+
+ public CacheManager getCache() {
+ return cache;
+ }
+
+ public PublishOptions setCache(CacheManager cache) {
+ this.cache = cache;
+ return this;
+ }
+
+ public String[] getConfs() {
+ return confs;
+ }
+
+ public PublishOptions setConfs(String[] confs) {
+ this.confs = confs;
+ return this;
+ }
+
+ public Artifact[] getExtraArtifacts() {
+ return extraArtifacts;
+ }
+
+ public PublishOptions setExtraArtifacts(Artifact[] extraArtifacts) {
+ this.extraArtifacts = extraArtifacts;
+ return this;
+ }
+
+ public boolean isOverwrite() {
+ return overwrite;
+ }
+
+ public PublishOptions setOverwrite(boolean overwrite) {
+ this.overwrite = overwrite;
+ return this;
+ }
+
+ public Date getPubdate() {
+ return pubdate;
+ }
+
+ public PublishOptions setPubdate(Date pubdate) {
+ this.pubdate = pubdate;
+ return this;
+ }
+
+ public String getPubrevision() {
+ return pubrevision;
+ }
+
+ public PublishOptions setPubrevision(String pubrevision) {
+ this.pubrevision = pubrevision;
+ return this;
+ }
+
+ public String getSrcIvyPattern() {
+ return srcIvyPattern;
+ }
+
+ public PublishOptions setSrcIvyPattern(String srcIvyPattern) {
+ this.srcIvyPattern = srcIvyPattern;
+ return this;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public PublishOptions setStatus(String status) {
+ this.status = status;
+ return this;
+ }
+
+ public boolean isUpdate() {
+ return update;
+ }
+
+ public PublishOptions setUpdate(boolean update) {
+ this.update = update;
+ return this;
+ }
+
+ public boolean isValidate() {
+ return validate;
+ }
+
+ public PublishOptions setValidate(boolean validate) {
+ this.validate = validate;
+ return this;
+ }
+
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java Tue Jun 5 05:02:27 2007
@@ -25,42 +25,54 @@
*/
public class ArtifactDownloadReport {
private Artifact artifact;
+
private ArtifactOrigin origin;
+
private DownloadStatus downloadStatus;
+
private long size;
-
+
public ArtifactDownloadReport(Artifact artifact) {
- this.artifact = artifact;
+ this.artifact = artifact;
}
+
public DownloadStatus getDownloadStatus() {
return downloadStatus;
}
+
public void setDownloadStatus(DownloadStatus downloadStatus) {
this.downloadStatus = downloadStatus;
}
+
public String getName() {
return artifact.getName();
}
+
public String getType() {
return artifact.getType();
}
- public Artifact getArtifact() {
- return artifact;
- }
+
+ public Artifact getArtifact() {
+ return artifact;
+ }
+
public String getExt() {
return artifact.getExt();
}
+
public long getSize() {
return size;
}
-
+
public void setSize(long size) {
this.size = size;
}
- public void setArtifactOrigin(ArtifactOrigin origin) {
- this.origin = origin;
- }
- public ArtifactOrigin getArtifactOrigin() {
- return origin;
- }
+
+ public void setArtifactOrigin(ArtifactOrigin origin) {
+ this.origin = origin;
+ }
+
+ public ArtifactOrigin getArtifactOrigin() {
+ return origin;
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/ConfigurationResolveReport.java Tue Jun 5 05:02:27 2007
@@ -43,72 +43,81 @@
import org.apache.ivy.plugins.report.XmlReportParser;
import org.apache.ivy.util.Message;
-
/**
*
*/
public class ConfigurationResolveReport {
private ModuleDescriptor md;
- private String conf;
- private Date date;
- private Map dependencyReports = new HashMap();
- private Map dependencies = new LinkedHashMap();
- private ResolveEngine resolveEngine;
- private Map modulesIdsMap = new LinkedHashMap();
- private List modulesIds;
- private List previousDeps;
-
- public ConfigurationResolveReport(ResolveEngine resolveEngine, ModuleDescriptor md, String conf, Date date, ResolveOptions options) {
- this.resolveEngine = resolveEngine;
- this.md = md;
- this.conf = conf;
- this.date = date;
-
- // parse previous deps from previous report file if any
- CacheManager cache = options.getCache();
- String resolveId = options.getResolveId();
+
+ private String conf;
+
+ private Date date;
+
+ private Map dependencyReports = new HashMap();
+
+ private Map dependencies = new LinkedHashMap();
+
+ private ResolveEngine resolveEngine;
+
+ private Map modulesIdsMap = new LinkedHashMap();
+
+ private List modulesIds;
+
+ private List previousDeps;
+
+ public ConfigurationResolveReport(ResolveEngine resolveEngine, ModuleDescriptor md,
+ String conf, Date date, ResolveOptions options) {
+ this.resolveEngine = resolveEngine;
+ this.md = md;
+ this.conf = conf;
+ this.date = date;
+
+ // parse previous deps from previous report file if any
+ CacheManager cache = options.getCache();
+ String resolveId = options.getResolveId();
File previousReportFile = cache.getConfigurationResolveReportInCache(resolveId, conf);
- if (previousReportFile.exists()) {
- try {
- XmlReportParser parser = new XmlReportParser();
- parser.parse(previousReportFile);
- previousDeps = Arrays.asList(parser.getDependencyRevisionIds());
- } catch (Exception e) {
- Message.warn("Error while parsing configuration resolve report " + previousReportFile.getAbsolutePath());
- e.printStackTrace();
- previousDeps = null;
- }
+ if (previousReportFile.exists()) {
+ try {
+ XmlReportParser parser = new XmlReportParser();
+ parser.parse(previousReportFile);
+ previousDeps = Arrays.asList(parser.getDependencyRevisionIds());
+ } catch (Exception e) {
+ Message.warn("Error while parsing configuration resolve report "
+ + previousReportFile.getAbsolutePath());
+ e.printStackTrace();
+ previousDeps = null;
+ }
} else {
- previousDeps = null;
+ previousDeps = null;
}
}
-
- public boolean hasChanged() {
- if (previousDeps == null) {
- return true;
- }
- return !new HashSet(previousDeps).equals(getModuleRevisionIds());
- }
+
+ public boolean hasChanged() {
+ if (previousDeps == null) {
+ return true;
+ }
+ return !new HashSet(previousDeps).equals(getModuleRevisionIds());
+ }
/**
- * Returns all non evicted and non error dependency mrids
- * The returned set is ordered so that a dependency will always
- * be found before their own dependencies
+ * Returns all non evicted and non error dependency mrids The returned set is ordered so that a
+ * dependency will always be found before their own dependencies
+ *
* @return all non evicted and non error dependency mrids
*/
public Set getModuleRevisionIds() {
- Set mrids = new LinkedHashSet();
- for (Iterator iter = getDependencies().iterator(); iter.hasNext();) {
- IvyNode node = (IvyNode) iter.next();
+ Set mrids = new LinkedHashSet();
+ for (Iterator iter = getDependencies().iterator(); iter.hasNext();) {
+ IvyNode node = (IvyNode) iter.next();
if (!node.isEvicted(getConfiguration()) && !node.hasProblem()) {
mrids.add(node.getResolvedId());
}
- }
- return mrids;
- }
+ }
+ return mrids;
+ }
- public void addDependency(IvyNode node) {
+ public void addDependency(IvyNode node) {
dependencies.put(node.getId(), node);
dependencies.put(node.getResolvedId(), node);
dependencyReports.put(node, Collections.EMPTY_LIST);
@@ -124,147 +133,156 @@
if (artifactReport != null) {
adrs.add(artifactReport);
} else {
- Message.debug("no report found for "+artifacts[i]);
+ Message.debug("no report found for " + artifacts[i]);
}
}
dependencyReports.put(node, adrs);
}
+ public String getConfiguration() {
+ return conf;
+ }
+
+ public Date getDate() {
+ return date;
+ }
- public String getConfiguration() {
- return conf;
- }
- public Date getDate() {
- return date;
- }
- public ModuleDescriptor getModuleDescriptor() {
- return md;
- }
- public IvyNode[] getUnresolvedDependencies() {
+ public ModuleDescriptor getModuleDescriptor() {
+ return md;
+ }
+
+ public IvyNode[] getUnresolvedDependencies() {
List unresolved = new ArrayList();
for (Iterator iter = getDependencies().iterator(); iter.hasNext();) {
- IvyNode node = (IvyNode)iter.next();
+ IvyNode node = (IvyNode) iter.next();
if (node.hasProblem()) {
unresolved.add(node);
}
}
- return (IvyNode[])unresolved.toArray(new IvyNode[unresolved.size()]);
- }
+ return (IvyNode[]) unresolved.toArray(new IvyNode[unresolved.size()]);
+ }
private Collection getDependencies() {
return new LinkedHashSet(dependencies.values());
}
+
public IvyNode[] getEvictedNodes() {
List evicted = new ArrayList();
for (Iterator iter = getDependencies().iterator(); iter.hasNext();) {
- IvyNode node = (IvyNode)iter.next();
+ IvyNode node = (IvyNode) iter.next();
if (node.isEvicted(conf)) {
evicted.add(node);
}
}
- return (IvyNode[])evicted.toArray(new IvyNode[evicted.size()]);
+ return (IvyNode[]) evicted.toArray(new IvyNode[evicted.size()]);
}
+
public IvyNode[] getDownloadedNodes() {
List downloaded = new ArrayList();
for (Iterator iter = getDependencies().iterator(); iter.hasNext();) {
- IvyNode node = (IvyNode)iter.next();
+ IvyNode node = (IvyNode) iter.next();
if (node.isDownloaded() && node.getRealNode() == node) {
downloaded.add(node);
}
}
- return (IvyNode[])downloaded.toArray(new IvyNode[downloaded.size()]);
+ return (IvyNode[]) downloaded.toArray(new IvyNode[downloaded.size()]);
}
+
public IvyNode[] getSearchedNodes() {
List downloaded = new ArrayList();
for (Iterator iter = getDependencies().iterator(); iter.hasNext();) {
- IvyNode node = (IvyNode)iter.next();
+ IvyNode node = (IvyNode) iter.next();
if (node.isSearched() && node.getRealNode() == node) {
downloaded.add(node);
}
}
- return (IvyNode[])downloaded.toArray(new IvyNode[downloaded.size()]);
+ return (IvyNode[]) downloaded.toArray(new IvyNode[downloaded.size()]);
+ }
+
+ public ArtifactDownloadReport[] getDownloadReports(ModuleRevisionId mrid) {
+ Collection col = (Collection) dependencyReports.get(getDependency(mrid));
+ if (col == null) {
+ return new ArtifactDownloadReport[0];
+ }
+ return (ArtifactDownloadReport[]) col.toArray(new ArtifactDownloadReport[col.size()]);
}
- public ArtifactDownloadReport[] getDownloadReports(ModuleRevisionId mrid) {
- Collection col = (Collection) dependencyReports.get(getDependency(mrid));
- if (col == null) {
- return new ArtifactDownloadReport[0];
- }
- return (ArtifactDownloadReport[]) col.toArray(new ArtifactDownloadReport[col.size()]);
- }
-
- public IvyNode getDependency(ModuleRevisionId mrid) {
- return (IvyNode) dependencies.get(mrid);
- }
-
- /**
- * gives all the modules ids concerned by this report, from the most dependent to the least one
- * @return a list of ModuleId
- */
- public List getModuleIds() {
- if (modulesIds == null) {
- List sortedDependencies = resolveEngine.getSortEngine().sortNodes(getDependencies());
+ public IvyNode getDependency(ModuleRevisionId mrid) {
+ return (IvyNode) dependencies.get(mrid);
+ }
+
+ /**
+ * gives all the modules ids concerned by this report, from the most dependent to the least one
+ *
+ * @return a list of ModuleId
+ */
+ public List getModuleIds() {
+ if (modulesIds == null) {
+ List sortedDependencies = resolveEngine.getSortEngine().sortNodes(getDependencies());
Collections.reverse(sortedDependencies);
- for (Iterator iter = sortedDependencies.iterator(); iter.hasNext();) {
+ for (Iterator iter = sortedDependencies.iterator(); iter.hasNext();) {
IvyNode dependency = (IvyNode) iter.next();
- ModuleId mid = dependency.getResolvedId().getModuleId();
- Collection deps = (Collection) modulesIdsMap.get(mid);
- if (deps == null) {
- deps = new HashSet();
- modulesIdsMap.put(mid, deps);
- }
- deps.add(dependency);
- }
- modulesIds = new ArrayList(modulesIdsMap.keySet());
- }
- return Collections.unmodifiableList(modulesIds);
- }
-
- public Collection getNodes(ModuleId mid) {
- if (modulesIds == null) {
- getModuleIds();
- }
- return (Collection) modulesIdsMap.get(mid);
- }
-
- public ResolveEngine getResolveEngine() {
- return resolveEngine;
- }
+ ModuleId mid = dependency.getResolvedId().getModuleId();
+ Collection deps = (Collection) modulesIdsMap.get(mid);
+ if (deps == null) {
+ deps = new HashSet();
+ modulesIdsMap.put(mid, deps);
+ }
+ deps.add(dependency);
+ }
+ modulesIds = new ArrayList(modulesIdsMap.keySet());
+ }
+ return Collections.unmodifiableList(modulesIds);
+ }
+
+ public Collection getNodes(ModuleId mid) {
+ if (modulesIds == null) {
+ getModuleIds();
+ }
+ return (Collection) modulesIdsMap.get(mid);
+ }
+
+ public ResolveEngine getResolveEngine() {
+ return resolveEngine;
+ }
public int getArtifactsNumber() {
int total = 0;
for (Iterator iter = dependencyReports.values().iterator(); iter.hasNext();) {
- Collection reports = (Collection)iter.next();
- total += reports==null?0:reports.size();
+ Collection reports = (Collection) iter.next();
+ total += reports == null ? 0 : reports.size();
}
return total;
}
+
public ArtifactDownloadReport[] getDownloadedArtifactsReports() {
List result = new ArrayList();
for (Iterator iter = dependencyReports.values().iterator(); iter.hasNext();) {
- Collection reports = (Collection)iter.next();
+ Collection reports = (Collection) iter.next();
for (Iterator iterator = reports.iterator(); iterator.hasNext();) {
- ArtifactDownloadReport adr = (ArtifactDownloadReport)iterator.next();
+ ArtifactDownloadReport adr = (ArtifactDownloadReport) iterator.next();
if (adr.getDownloadStatus() == DownloadStatus.SUCCESSFUL) {
result.add(adr);
}
}
}
- return (ArtifactDownloadReport[])result.toArray(new ArtifactDownloadReport[result.size()]);
+ return (ArtifactDownloadReport[]) result.toArray(new ArtifactDownloadReport[result.size()]);
}
+
public ArtifactDownloadReport[] getFailedArtifactsReports() {
List result = new ArrayList();
for (Iterator iter = dependencyReports.values().iterator(); iter.hasNext();) {
- Collection reports = (Collection)iter.next();
+ Collection reports = (Collection) iter.next();
for (Iterator iterator = reports.iterator(); iterator.hasNext();) {
- ArtifactDownloadReport adr = (ArtifactDownloadReport)iterator.next();
+ ArtifactDownloadReport adr = (ArtifactDownloadReport) iterator.next();
if (adr.getDownloadStatus() == DownloadStatus.FAILED) {
result.add(adr);
}
}
}
- return (ArtifactDownloadReport[])result.toArray(new ArtifactDownloadReport[result.size()]);
+ return (ArtifactDownloadReport[]) result.toArray(new ArtifactDownloadReport[result.size()]);
}
+
public boolean hasError() {
return getUnresolvedDependencies().length > 0 || getFailedArtifactsReports().length > 0;
}
@@ -272,6 +290,5 @@
public int getNodesNumber() {
return getDependencies().size();
}
-
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/DownloadReport.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/DownloadReport.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/DownloadReport.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/DownloadReport.java Tue Jun 5 05:02:27 2007
@@ -17,7 +17,6 @@
*/
package org.apache.ivy.core.report;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -31,27 +30,28 @@
*/
public class DownloadReport {
private Map artifacts = new HashMap();
-
+
public void addArtifactReport(ArtifactDownloadReport adr) {
artifacts.put(adr.getArtifact(), adr);
}
-
+
public ArtifactDownloadReport[] getArtifactsReports() {
- return (ArtifactDownloadReport[]) artifacts.values().toArray(new ArtifactDownloadReport[artifacts.size()]);
+ return (ArtifactDownloadReport[]) artifacts.values().toArray(
+ new ArtifactDownloadReport[artifacts.size()]);
}
public ArtifactDownloadReport[] getArtifactsReports(DownloadStatus status) {
List ret = new ArrayList(artifacts.size());
for (Iterator iter = artifacts.values().iterator(); iter.hasNext();) {
- ArtifactDownloadReport adr = (ArtifactDownloadReport)iter.next();
+ ArtifactDownloadReport adr = (ArtifactDownloadReport) iter.next();
if (adr.getDownloadStatus() == status) {
ret.add(adr);
}
}
- return (ArtifactDownloadReport[])ret.toArray(new ArtifactDownloadReport[ret.size()]);
+ return (ArtifactDownloadReport[]) ret.toArray(new ArtifactDownloadReport[ret.size()]);
}
- public ArtifactDownloadReport getArtifactReport(Artifact artifact) {
- return (ArtifactDownloadReport) artifacts.get(artifact);
- }
+ public ArtifactDownloadReport getArtifactReport(Artifact artifact) {
+ return (ArtifactDownloadReport) artifacts.get(artifact);
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/DownloadStatus.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/DownloadStatus.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/DownloadStatus.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/DownloadStatus.java Tue Jun 5 05:02:27 2007
@@ -22,16 +22,20 @@
*/
public class DownloadStatus {
private String name;
+
private DownloadStatus(String name) {
this.name = name;
}
-
+
/**
* means that download was not required
*/
public static final DownloadStatus NO = new DownloadStatus("no");
+
public static final DownloadStatus SUCCESSFUL = new DownloadStatus("successful");
+
public static final DownloadStatus FAILED = new DownloadStatus("failed");
+
public String toString() {
return name;
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java Tue Jun 5 05:02:27 2007
@@ -34,41 +34,53 @@
import org.apache.ivy.plugins.report.ReportOutputter;
import org.apache.ivy.util.filter.Filter;
-
/**
* Represents a whole resolution report for a module
*/
public class ResolveReport {
private ModuleDescriptor md;
+
private Map confReports = new LinkedHashMap();
- private List problemMessages;
- private List dependencies; // the list of all dependencies resolved, ordered from the more dependent to the less dependent
- private List artifacts;
- private long resolveTime;
- private long downloadTime;
- private String resolveId;
-
+
+ private List problemMessages;
+
+ private List dependencies; // the list of all dependencies resolved, ordered from the more
+
+ // dependent to the less dependent
+
+ private List artifacts;
+
+ private long resolveTime;
+
+ private long downloadTime;
+
+ private String resolveId;
+
public ResolveReport(ModuleDescriptor md) {
this(md, ResolveOptions.getDefaultResolveId(md));
}
-
+
public ResolveReport(ModuleDescriptor md, String resolveId) {
- this.md = md;
- this.resolveId = resolveId;
+ this.md = md;
+ this.resolveId = resolveId;
}
+
public void addReport(String conf, ConfigurationResolveReport report) {
confReports.put(conf, report);
}
+
public ConfigurationResolveReport getConfigurationReport(String conf) {
return (ConfigurationResolveReport) confReports.get(conf);
}
+
public String[] getConfigurations() {
return (String[]) confReports.keySet().toArray(new String[confReports.size()]);
}
+
public boolean hasError() {
boolean hasError = false;
for (Iterator it = confReports.values().iterator(); it.hasNext() && !hasError;) {
- ConfigurationResolveReport report = (ConfigurationResolveReport)it.next();
+ ConfigurationResolveReport report = (ConfigurationResolveReport) it.next();
hasError |= report.hasError();
}
return hasError;
@@ -79,136 +91,153 @@
outputters[i].output(this, cache);
}
}
-
+
public ModuleDescriptor getModuleDescriptor() {
return md;
}
-
+
public IvyNode[] getEvictedNodes() {
Collection all = new HashSet();
for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
- ConfigurationResolveReport report = (ConfigurationResolveReport)iter.next();
+ ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
all.addAll(Arrays.asList(report.getEvictedNodes()));
}
- return (IvyNode[])all.toArray(new IvyNode[all.size()]);
+ return (IvyNode[]) all.toArray(new IvyNode[all.size()]);
}
+
public IvyNode[] getUnresolvedDependencies() {
Collection all = new HashSet();
for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
- ConfigurationResolveReport report = (ConfigurationResolveReport)iter.next();
+ ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
all.addAll(Arrays.asList(report.getUnresolvedDependencies()));
}
- return (IvyNode[])all.toArray(new IvyNode[all.size()]);
+ return (IvyNode[]) all.toArray(new IvyNode[all.size()]);
}
+
public ArtifactDownloadReport[] getFailedArtifactsReports() {
Collection all = new HashSet();
for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
- ConfigurationResolveReport report = (ConfigurationResolveReport)iter.next();
+ ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
all.addAll(Arrays.asList(report.getFailedArtifactsReports()));
}
- return (ArtifactDownloadReport[])all.toArray(new ArtifactDownloadReport[all.size()]);
+ return (ArtifactDownloadReport[]) all.toArray(new ArtifactDownloadReport[all.size()]);
+ }
+
+ public boolean hasChanged() {
+ for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
+ ConfigurationResolveReport report = (ConfigurationResolveReport) iter.next();
+ if (report.hasChanged()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void setProblemMessages(List problems) {
+ problemMessages = problems;
}
- public boolean hasChanged() {
+
+ public List getProblemMessages() {
+ return problemMessages;
+ }
+
+ public List getAllProblemMessages() {
+ List ret = new ArrayList(problemMessages);
for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
- ConfigurationResolveReport report = (ConfigurationResolveReport)iter.next();
- if (report.hasChanged()) {
- return true;
- }
- }
- return false;
- }
- public void setProblemMessages(List problems) {
- problemMessages = problems;
- }
- public List getProblemMessages() {
- return problemMessages;
- }
- public List getAllProblemMessages() {
- List ret = new ArrayList(problemMessages);
- for (Iterator iter = confReports.values().iterator(); iter.hasNext();) {
- ConfigurationResolveReport r = (ConfigurationResolveReport) iter.next();
- IvyNode[] unresolved = r.getUnresolvedDependencies();
- for (int i = 0; i < unresolved.length; i++) {
- String errMsg = unresolved[i].getProblemMessage();
- if (errMsg.length() > 0) {
- ret.add("unresolved dependency: "+unresolved[i].getId()+": "+errMsg);
- } else {
- ret.add("unresolved dependency: "+unresolved[i].getId());
- }
- }
- ArtifactDownloadReport[] adrs = r.getFailedArtifactsReports();
- for (int i = 0; i < adrs.length; i++) {
- ret.add("download failed: "+adrs[i].getArtifact());
- }
- }
- return ret;
- }
- public void setDependencies(List dependencies, Filter artifactFilter) {
- this.dependencies = dependencies;
+ ConfigurationResolveReport r = (ConfigurationResolveReport) iter.next();
+ IvyNode[] unresolved = r.getUnresolvedDependencies();
+ for (int i = 0; i < unresolved.length; i++) {
+ String errMsg = unresolved[i].getProblemMessage();
+ if (errMsg.length() > 0) {
+ ret.add("unresolved dependency: " + unresolved[i].getId() + ": " + errMsg);
+ } else {
+ ret.add("unresolved dependency: " + unresolved[i].getId());
+ }
+ }
+ ArtifactDownloadReport[] adrs = r.getFailedArtifactsReports();
+ for (int i = 0; i < adrs.length; i++) {
+ ret.add("download failed: " + adrs[i].getArtifact());
+ }
+ }
+ return ret;
+ }
+
+ public void setDependencies(List dependencies, Filter artifactFilter) {
+ this.dependencies = dependencies;
// collect list of artifacts
artifacts = new ArrayList();
for (Iterator iter = dependencies.iterator(); iter.hasNext();) {
- IvyNode dependency = (IvyNode) iter.next();
- if (!dependency.isCompletelyEvicted() && !dependency.hasProblem()) {
- artifacts.addAll(Arrays.asList(dependency.getSelectedArtifacts(artifactFilter)));
- }
- // update the configurations reports with the dependencies
- // these reports will be completed later with download information, if any
- String[] dconfs = dependency.getRootModuleConfigurations();
- for (int j = 0; j < dconfs.length; j++) {
- ConfigurationResolveReport configurationReport = getConfigurationReport(dconfs[j]);
- if (configurationReport != null) {
- configurationReport.addDependency(dependency);
- }
- }
- }
- }
- /**
- * Returns the list of all dependencies concerned by this report as a List of IvyNode
- * ordered from the more dependent to the least one
- * @return
- */
- public List getDependencies() {
- return dependencies;
- }
- /**
- * Returns the list of all artifacts which should be downloaded per this resolve
- * To know if the artifact have actually been downloaded use information found
- * in ConfigurationResolveReport.
- * @return
- */
- public List getArtifacts() {
- return artifacts;
- }
- /**
- * gives all the modules ids concerned by this report, from the most dependent to the least one
- * @return a list of ModuleId
- */
- public List getModuleIds() {
- List ret = new ArrayList();
- List sortedDependencies = new ArrayList(dependencies);
- for (Iterator iter = sortedDependencies.iterator(); iter.hasNext();) {
- IvyNode dependency = (IvyNode) iter.next();
- ModuleId mid = dependency.getResolvedId().getModuleId();
- if (!ret.contains(mid)) {
- ret.add(mid);
- }
- }
- return ret;
- }
- public void setResolveTime(long elapsedTime) {
- resolveTime = elapsedTime;
- }
- public long getResolveTime() {
- return resolveTime;
- }
- public void setDownloadTime(long elapsedTime) {
- downloadTime = elapsedTime;
- }
- public long getDownloadTime() {
- return downloadTime;
- }
- public String getResolveId() {
- return resolveId;
- }
+ IvyNode dependency = (IvyNode) iter.next();
+ if (!dependency.isCompletelyEvicted() && !dependency.hasProblem()) {
+ artifacts.addAll(Arrays.asList(dependency.getSelectedArtifacts(artifactFilter)));
+ }
+ // update the configurations reports with the dependencies
+ // these reports will be completed later with download information, if any
+ String[] dconfs = dependency.getRootModuleConfigurations();
+ for (int j = 0; j < dconfs.length; j++) {
+ ConfigurationResolveReport configurationReport = getConfigurationReport(dconfs[j]);
+ if (configurationReport != null) {
+ configurationReport.addDependency(dependency);
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the list of all dependencies concerned by this report as a List of IvyNode ordered
+ * from the more dependent to the least one
+ *
+ * @return
+ */
+ public List getDependencies() {
+ return dependencies;
+ }
+
+ /**
+ * Returns the list of all artifacts which should be downloaded per this resolve To know if the
+ * artifact have actually been downloaded use information found in ConfigurationResolveReport.
+ *
+ * @return
+ */
+ public List getArtifacts() {
+ return artifacts;
+ }
+
+ /**
+ * gives all the modules ids concerned by this report, from the most dependent to the least one
+ *
+ * @return a list of ModuleId
+ */
+ public List getModuleIds() {
+ List ret = new ArrayList();
+ List sortedDependencies = new ArrayList(dependencies);
+ for (Iterator iter = sortedDependencies.iterator(); iter.hasNext();) {
+ IvyNode dependency = (IvyNode) iter.next();
+ ModuleId mid = dependency.getResolvedId().getModuleId();
+ if (!ret.contains(mid)) {
+ ret.add(mid);
+ }
+ }
+ return ret;
+ }
+
+ public void setResolveTime(long elapsedTime) {
+ resolveTime = elapsedTime;
+ }
+
+ public long getResolveTime() {
+ return resolveTime;
+ }
+
+ public void setDownloadTime(long elapsedTime) {
+ downloadTime = elapsedTime;
+ }
+
+ public long getDownloadTime() {
+ return downloadTime;
+ }
+
+ public String getResolveId() {
+ return resolveId;
+ }
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/DefaultModuleRevision.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/DefaultModuleRevision.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/DefaultModuleRevision.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/DefaultModuleRevision.java Tue Jun 5 05:02:27 2007
@@ -24,19 +24,24 @@
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.plugins.resolver.DependencyResolver;
-
/**
*
*/
public class DefaultModuleRevision implements ResolvedModuleRevision {
private DependencyResolver resolver;
+
private DependencyResolver artifactResolver;
+
private ModuleDescriptor descriptor;
+
private boolean isDownloaded;
+
private boolean isSearched;
+
private URL localMDUrl;
-
- public DefaultModuleRevision(DependencyResolver resolver, DependencyResolver artifactResolver, ModuleDescriptor descriptor, boolean searched, boolean downloaded, URL localMDUrl) {
+
+ public DefaultModuleRevision(DependencyResolver resolver, DependencyResolver artifactResolver,
+ ModuleDescriptor descriptor, boolean searched, boolean downloaded, URL localMDUrl) {
this.resolver = resolver;
this.artifactResolver = artifactResolver;
this.descriptor = descriptor;
@@ -48,7 +53,7 @@
public DependencyResolver getResolver() {
return resolver;
}
-
+
public DependencyResolver getArtifactResolver() {
return artifactResolver;
}
@@ -60,22 +65,22 @@
public ModuleRevisionId getId() {
return descriptor.getResolvedModuleRevisionId();
}
-
+
public Date getPublicationDate() {
return descriptor.getResolvedPublicationDate();
}
-
+
public boolean equals(Object obj) {
- if (! (obj instanceof ResolvedModuleRevision)) {
+ if (!(obj instanceof ResolvedModuleRevision)) {
return false;
}
- return ((ResolvedModuleRevision)obj).getId().equals(getId());
+ return ((ResolvedModuleRevision) obj).getId().equals(getId());
}
-
+
public int hashCode() {
return getId().hashCode();
}
-
+
public String toString() {
return getId().toString();
}
@@ -88,8 +93,8 @@
return isSearched;
}
- public URL getLocalMDUrl() {
- return localMDUrl;
- }
-
+ public URL getLocalMDUrl() {
+ return localMDUrl;
+ }
+
}
Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/DownloadOptions.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/DownloadOptions.java?view=diff&rev=544459&r1=544458&r2=544459
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/DownloadOptions.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/DownloadOptions.java Tue Jun 5 05:02:27 2007
@@ -24,39 +24,44 @@
import org.apache.ivy.core.settings.IvySettings;
public class DownloadOptions {
- private IvySettings settings;
- private CacheManager cacheManager;
- private EventManager eventManager = null; // can be null
- private boolean useOrigin = false;
-
- public DownloadOptions(IvySettings settings, File cache) {
- this(settings, new CacheManager(settings, cache));
- }
-
- public DownloadOptions(IvySettings settings, CacheManager cacheManager) {
- this(settings, cacheManager, null, false);
- }
-
- public DownloadOptions(IvySettings settings, CacheManager cacheManager, EventManager eventManager, boolean useOrigin) {
- this.settings = settings;
- this.cacheManager = cacheManager;
- this.eventManager = eventManager;
- this.useOrigin = useOrigin;
- }
-
- public IvySettings getSettings() {
- return settings;
- }
- public boolean isUseOrigin() {
- return useOrigin;
- }
-
- public CacheManager getCacheManager() {
- return cacheManager;
- }
-
- public EventManager getEventManager() {
- return eventManager;
- }
-
+ private IvySettings settings;
+
+ private CacheManager cacheManager;
+
+ private EventManager eventManager = null; // can be null
+
+ private boolean useOrigin = false;
+
+ public DownloadOptions(IvySettings settings, File cache) {
+ this(settings, new CacheManager(settings, cache));
+ }
+
+ public DownloadOptions(IvySettings settings, CacheManager cacheManager) {
+ this(settings, cacheManager, null, false);
+ }
+
+ public DownloadOptions(IvySettings settings, CacheManager cacheManager,
+ EventManager eventManager, boolean useOrigin) {
+ this.settings = settings;
+ this.cacheManager = cacheManager;
+ this.eventManager = eventManager;
+ this.useOrigin = useOrigin;
+ }
+
+ public IvySettings getSettings() {
+ return settings;
+ }
+
+ public boolean isUseOrigin() {
+ return useOrigin;
+ }
+
+ public CacheManager getCacheManager() {
+ return cacheManager;
+ }
+
+ public EventManager getEventManager() {
+ return eventManager;
+ }
+
}