Author: xavier
Date: Fri Dec 28 04:16:22 2007
New Revision: 607221
URL: http://svn.apache.org/viewvc?rev=607221&view=rev
Log:
- store module descriptor cache location in resolution report to avoid using
cache manager for later use of this data
- simplify ResolvedModuleRevision usage by making it a class, and putting some
data separated in an ArtifactDownloadReport
- create a constant for unknown ArtifactOrigin instead of using null, to
distinguish between unknown location and not providing ArtifactOrigin in
IvyPatternHelper methods (which avoid calling getSavedArtifactOrigin many times
for nothing)
Added:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/MetadataArtifactDownloadReport.java
(with props)
Removed:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/DefaultModuleRevision.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/util/ResolvedModuleRevisionProxy.java
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/RepositoryCacheManager.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/EndArtifactDownloadEvent.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/install/InstallEngine.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolvedModuleRevision.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/NameSpaceHelper.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportParser.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
ant/ivy/core/trunk/test/java/org/apache/ivy/core/cache/CacheManagerTest.java
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MockResolver.java
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyArtifactReport.java Fri
Dec 28 04:16:22 2007
@@ -219,7 +219,7 @@
RepositoryCacheManager cache, TransformerHandler saxHandler,
Artifact artifact)
throws IOException, SAXException {
ArtifactOrigin origin = cache.getSavedArtifactOrigin(artifact);
- if (origin != null) {
+ if (origin != ArtifactOrigin.UNKNOWN) {
String originName = origin.getLocation();
boolean isOriginLocal = origin.isLocal();
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/IvyPatternHelper.java Fri
Dec 28 04:16:22 2007
@@ -436,11 +436,15 @@
origin = cacheManager.getSavedArtifactOrigin(artifact);
- if (origin == null) {
+ if (origin == ArtifactOrigin.UNKNOWN) {
Message.debug("no artifact origin found for " + artifact +
" in "
+ cacheManager);
return null;
}
+ }
+
+ if (origin == ArtifactOrigin.UNKNOWN) {
+ return null;
}
// we assume that the original filename is the last part of the
original file location
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java
Fri Dec 28 04:16:22 2007
@@ -24,6 +24,11 @@
* @see org.apache.ivy.plugins.resolver.util.ResolvedResource
*/
public class ArtifactOrigin {
+ /**
+ * ArtifactOrigin instance used when the origin is unknown.
+ */
+ public static final ArtifactOrigin UNKNOWN = new ArtifactOrigin(false,
"UNKNOWN");
+
private static final int MAGIC_HASH_VALUE = 31;
private boolean isLocal;
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheManager.java Fri
Dec 28 04:16:22 2007
@@ -33,7 +33,7 @@
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.ArtifactDownloadReport;
import org.apache.ivy.core.report.DownloadStatus;
-import org.apache.ivy.core.resolve.DefaultModuleRevision;
+import org.apache.ivy.core.report.MetadataArtifactDownloadReport;
import org.apache.ivy.core.resolve.ResolvedModuleRevision;
import org.apache.ivy.plugins.lock.LockStrategy;
import org.apache.ivy.plugins.namespace.NameSpaceHelper;
@@ -124,7 +124,8 @@
*/
public File getArchiveFileInCache(Artifact artifact, ArtifactOrigin
origin) {
File archive = new File(getRepositoryCacheRoot(),
getArchivePathInCache(artifact, origin));
- if (!archive.exists() && origin != null && origin.isLocal()) {
+ if (!archive.exists()
+ && origin != null && origin != ArtifactOrigin.UNKNOWN &&
origin.isLocal()) {
File original = new File(origin.getLocation());
if (original.exists()) {
return original;
@@ -140,7 +141,7 @@
* always return the file in the cache.
*/
public File getArchiveFileInCache(Artifact artifact, ArtifactOrigin
origin, boolean useOrigin) {
- if (useOrigin && origin != null && origin.isLocal()) {
+ if (useOrigin && origin != null && origin != ArtifactOrigin.UNKNOWN &&
origin.isLocal()) {
return new File(origin.getLocation());
} else {
return new File(getRepositoryCacheRoot(),
getArchivePathInCache(artifact, origin));
@@ -229,7 +230,7 @@
ModuleRevisionId mrid = artifact.getModuleRevisionId();
if (!lockMetadataArtifact(mrid)) {
Message.error("impossible to acquire lock for " + mrid);
- return null;
+ return ArtifactOrigin.UNKNOWN;
}
try {
PropertiesFile cdf =
getCachedDataFile(artifact.getModuleRevisionId());
@@ -239,7 +240,7 @@
if (location == null) {
// origin has not been specified, return null
- return null;
+ return ArtifactOrigin.UNKNOWN;
}
return new ArtifactOrigin(isLocal, location);
@@ -311,7 +312,7 @@
// found in cache !
try {
ModuleDescriptor depMD =
XmlModuleDescriptorParser.getInstance()
- .parseDescriptor(settings, ivyFile.toURL(), validate);
+ .parseDescriptor(settings, ivyFile.toURL(),
validate);
String resolverName = getSavedResolverName(depMD);
String artResolverName =
getSavedArtResolverName(depMD);
DependencyResolver resolver =
settings.getResolver(resolverName);
@@ -336,8 +337,17 @@
+ resolver.getName() + "): " + ivyFile);
if (expectedResolver != null
&&
expectedResolver.equals(resolver.getName())) {
- return new DefaultModuleRevision(
- resolver, artResolver, depMD, false,
false);
+ MetadataArtifactDownloadReport madr
+ = new MetadataArtifactDownloadReport(
+ depMD.getMetadataArtifact());
+ madr.setDownloadStatus(DownloadStatus.NO);
+ madr.setSearched(false);
+ madr.setLocalFile(ivyFile);
+ madr.setSize(ivyFile.length());
+ madr.setArtifactOrigin(
+
getSavedArtifactOrigin(depMD.getMetadataArtifact()));
+ return new ResolvedModuleRevision(
+ resolver, artResolver, depMD, madr);
} else {
Message.debug(
"found module in cache but with a
different resolver: "
@@ -481,7 +491,8 @@
public void originalToCachedModuleDescriptor(
DependencyResolver resolver, ResolvedResource orginalMetadataRef,
Artifact requestedMetadataArtifact,
- ModuleDescriptor md, ModuleDescriptorWriter writer) {
+ ResolvedModuleRevision rmr, ModuleDescriptorWriter writer) {
+ ModuleDescriptor md = rmr.getDescriptor();
Artifact originalMetadataArtifact =
getOriginalMetadataArtifact(requestedMetadataArtifact);
File mdFileInCache =
getIvyFileInCache(md.getResolvedModuleRevisionId());
@@ -491,11 +502,14 @@
return;
}
try {
+ File originalFileInCache =
getArchiveFileInCache(originalMetadataArtifact);
writer.write(orginalMetadataRef, md,
- getArchiveFileInCache(originalMetadataArtifact),
+ originalFileInCache,
mdFileInCache);
saveResolvers(md, resolver.getName(), resolver.getName());
+ rmr.getReport().setOriginalLocalFile(originalFileInCache);
+ rmr.getReport().setLocalFile(mdFileInCache);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
@@ -534,14 +548,16 @@
} else {
if (!options.isCheckmodified() && !options.isChanging()) {
Message.verbose("\t" + getName() + ": revision in
cache: " + mrid);
- return DefaultModuleRevision.searchedRmr(rmr);
+ rmr.getReport().setSearched(true);
+ return rmr;
}
long repLastModified = mdRef.getLastModified();
long cacheLastModified =
rmr.getDescriptor().getLastModified();
if (!rmr.getDescriptor().isDefault() && repLastModified <=
cacheLastModified) {
Message.verbose("\t" + getName() + ": revision in
cache (not updated): "
+ mrid);
- return DefaultModuleRevision.searchedRmr(rmr);
+ rmr.getReport().setSearched(true);
+ return rmr;
} else {
Message.verbose("\t" + getName() + ": revision in
cache is not up to date: "
+ mrid);
@@ -618,7 +634,19 @@
Message.verbose(mrid
+ " is changing, but has not changed: will trust
cached artifacts if any");
}
- return new DefaultModuleRevision(resolver, resolver, md, true,
true);
+
+ MetadataArtifactDownloadReport madr
+ = new
MetadataArtifactDownloadReport(md.getMetadataArtifact());
+ madr.setSearched(true);
+ madr.setDownloadStatus(report.getDownloadStatus());
+ madr.setDownloadDetails(report.getDownloadDetails());
+ madr.setArtifactOrigin(report.getArtifactOrigin());
+ madr.setDownloadTimeMillis(report.getDownloadTimeMillis());
+ madr.setOriginalLocalFile(report.getLocalFile());
+ madr.setSize(report.getSize());
+ saveArtifactOrigin(md.getMetadataArtifact(),
report.getArtifactOrigin());
+
+ return new ResolvedModuleRevision(resolver, resolver, md,
madr);
} catch (IOException ex) {
Message.warn("io problem while parsing ivy file: " +
mdRef.getResource() + ": "
+ ex.getMessage());
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/RepositoryCacheManager.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/RepositoryCacheManager.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/RepositoryCacheManager.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/RepositoryCacheManager.java
Fri Dec 28 04:16:22 2007
@@ -75,6 +75,14 @@
public abstract void saveResolvers(
ModuleDescriptor descriptor, String metadataResolverName, String
artifactResolverName);
+ /**
+ * Returns the artifact origin of the given artifact as saved in this
cache, or
+ * [EMAIL PROTECTED] ArtifactOrigin#UNKNOWN} if the origin is unknown.
+ *
+ * @param artifact
+ * the artifact for which the saved artifact origin should be
returned.
+ * @return the artifact origin of the given artifact as saved in this cache
+ */
public abstract ArtifactOrigin getSavedArtifactOrigin(Artifact artifact);
/**
@@ -121,5 +129,5 @@
public void originalToCachedModuleDescriptor(
DependencyResolver resolver, ResolvedResource orginalMetadataRef,
Artifact requestedMetadataArtifact,
- ModuleDescriptor md, ModuleDescriptorWriter writer);
+ ResolvedModuleRevision rmr, ModuleDescriptorWriter writer);
}
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/EndArtifactDownloadEvent.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/EndArtifactDownloadEvent.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/EndArtifactDownloadEvent.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/core/event/download/EndArtifactDownloadEvent.java
Fri Dec 28 04:16:22 2007
@@ -43,7 +43,7 @@
addAttribute("file", dest.getAbsolutePath());
addAttribute("duration",
String.valueOf(this.report.getDownloadTimeMillis()));
ArtifactOrigin origin = report.getArtifactOrigin();
- if (origin != null) {
+ if (origin != null && origin != ArtifactOrigin.UNKNOWN) {
addAttribute("origin", origin.getLocation());
addAttribute("local", String.valueOf(origin.isLocal()));
} else {
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/install/InstallEngine.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/install/InstallEngine.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/install/InstallEngine.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/install/InstallEngine.java
Fri Dec 28 04:16:22 2007
@@ -21,12 +21,9 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
-import org.apache.ivy.core.cache.CacheManager;
-import org.apache.ivy.core.cache.RepositoryCacheManager;
import org.apache.ivy.core.module.descriptor.Configuration;
import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
@@ -34,7 +31,6 @@
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.publish.PublishEngine;
-import org.apache.ivy.core.publish.PublishOptions;
import org.apache.ivy.core.report.ArtifactDownloadReport;
import org.apache.ivy.core.report.ResolveReport;
import org.apache.ivy.core.resolve.IvyNode;
@@ -157,11 +153,8 @@
}
// publish metadata
- // TODO cache: store metadata cache info in report and
reuse it
- RepositoryCacheManager cacheManager =
- dependencies[i].getModuleRevision().getResolver()
- .getRepositoryCacheManager();
- File localIvyFile =
cacheManager.getIvyFileInCache(depMrid);
+ File localIvyFile = dependencies[i]
+
.getModuleRevision().getReport().getLocalFile();
toResolver.publish(depmd.getMetadataArtifact(),
localIvyFile, overwrite);
// end module publish
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java
Fri Dec 28 04:16:22 2007
@@ -146,4 +146,8 @@
public void setLocalFile(File localFile) {
this.localFile = localFile;
}
+
+ public boolean isDownloaded() {
+ return DownloadStatus.SUCCESSFUL == downloadStatus;
+ }
}
Added:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/MetadataArtifactDownloadReport.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/MetadataArtifactDownloadReport.java?rev=607221&view=auto
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/MetadataArtifactDownloadReport.java
(added)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/MetadataArtifactDownloadReport.java
Fri Dec 28 04:16:22 2007
@@ -0,0 +1,63 @@
+/*
+ * 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.report;
+
+import java.io.File;
+
+import org.apache.ivy.core.module.descriptor.Artifact;
+
+public class MetadataArtifactDownloadReport extends ArtifactDownloadReport {
+ private boolean isSearched;
+
+ private File originalLocalFile;
+
+ public MetadataArtifactDownloadReport(Artifact artifact) {
+ super(artifact);
+ }
+
+ /**
+ * Returns <code>true</code> if the resolution of this metadata artifact
required at least one
+ * access to the repository, or <code>false</code> if only provisioned
data was used.
+ *
+ * @return <code>true</code> if the resolution of this metadata artifact
required at least one
+ * access to the repository
+ */
+ public boolean isSearched() {
+ return isSearched;
+ }
+
+ public void setSearched(boolean isSearched) {
+ this.isSearched = isSearched;
+ }
+
+ /**
+ * Returns the location on the local filesystem where the original
metadata artifact is
+ * provisioned, or <code>null</code> if the provisioning failed.
+ *
+ * @return the location on the local filesystem where the original
metadata artifact is
+ * provisioned.
+ */
+ public File getOriginalLocalFile() {
+ return originalLocalFile;
+ }
+
+ public void setOriginalLocalFile(File originalLocalFile) {
+ this.originalLocalFile = originalLocalFile;
+ }
+
+}
Propchange:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/MetadataArtifactDownloadReport.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/IvyNode.java Fri
Dec 28 04:16:22 2007
@@ -264,8 +264,8 @@
if (resolved.module == null) {
resolved.module = module;
}
- resolved.downloaded |= module.isDownloaded();
- resolved.searched |= module.isSearched();
+ resolved.downloaded |=
module.getReport().isDownloaded();
+ resolved.searched |=
module.getReport().isSearched();
resolved.dds.putAll(dds);
resolved.updateDataFrom(this, rootModuleConf,
true);
resolved.loadData(rootModuleConf, parent,
parentConf, conf,
@@ -292,8 +292,8 @@
return true;
}
}
- downloaded = module.isDownloaded();
- searched = module.isSearched();
+ downloaded = module.getReport().isDownloaded();
+ searched = module.getReport().isSearched();
} else {
Message.warn("\tmodule not found: " + getId());
resolver.reportFailure();
@@ -302,6 +302,7 @@
} catch (ResolveProcessException e) {
throw e;
} catch (Exception e) {
+ e.printStackTrace();
problem = e;
}
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolvedModuleRevision.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolvedModuleRevision.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolvedModuleRevision.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolvedModuleRevision.java
Fri Dec 28 04:16:22 2007
@@ -21,33 +21,102 @@
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.report.MetadataArtifactDownloadReport;
import org.apache.ivy.plugins.resolver.DependencyResolver;
/**
- *
+ * Represents a module revision provisioned on the local filesystem.
*/
-public interface ResolvedModuleRevision {
+public class ResolvedModuleRevision {
+
+ private DependencyResolver resolver;
+
+ private DependencyResolver artifactResolver;
+
+ private ModuleDescriptor descriptor;
+
+ private MetadataArtifactDownloadReport report;
+
+ public ResolvedModuleRevision(DependencyResolver resolver,
DependencyResolver artifactResolver,
+ ModuleDescriptor descriptor, MetadataArtifactDownloadReport
report) {
+ this.resolver = resolver;
+ this.artifactResolver = artifactResolver;
+ this.descriptor = descriptor;
+ this.report = report;
+ }
+
+ /**
+ * Returns the identifier of the resolved module.
+ *
+ * @return the identifier of the resolved module.
+ */
+ public ModuleRevisionId getId() {
+ return descriptor.getResolvedModuleRevisionId();
+ }
+
+
+ /**
+ * Returns the date of publication of the resolved module.
+ *
+ * @return the date of publication of the resolved module.
+ */
+ public Date getPublicationDate() {
+ return descriptor.getResolvedPublicationDate();
+ }
+
+
+ /**
+ * Returns the descriptor of the resolved module.
+ *
+ * @return the descriptor of the resolved module.
+ */
+ public ModuleDescriptor getDescriptor() {
+ return descriptor;
+ }
+
+
/**
* The resolver which resolved this ResolvedModuleRevision
*
* @return The resolver which resolved this ResolvedModuleRevision
*/
- DependencyResolver getResolver();
+ public DependencyResolver getResolver() {
+ return resolver;
+ }
/**
* The resolver to use to download artifacts
*
* @return The resolver to use to download artifacts
*/
- DependencyResolver getArtifactResolver();
+ public DependencyResolver getArtifactResolver() {
+ return artifactResolver;
+ }
- ModuleRevisionId getId();
- Date getPublicationDate();
-
- ModuleDescriptor getDescriptor();
-
- boolean isDownloaded();
+ /**
+ * Returns a report of the resolved module metadata artifact provisioning.
+ *
+ * @return a report of the resolved module metadata artifact provisioning.
+ */
+ public MetadataArtifactDownloadReport getReport() {
+ return report;
+ }
+
+
+ public boolean equals(Object obj) {
+ if (!(obj instanceof ResolvedModuleRevision)) {
+ return false;
+ }
+ return ((ResolvedModuleRevision) obj).getId().equals(getId());
+ }
+
+ public int hashCode() {
+ return getId().hashCode();
+ }
+
+ public String toString() {
+ return getId().toString();
+ }
- boolean isSearched();
}
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
Fri Dec 28 04:16:22 2007
@@ -258,13 +258,7 @@
if (destIvyPattern != null) {
ModuleRevisionId[] mrids =
parser.getRealDependencyRevisionIds();
for (int j = 0; j < mrids.length; j++) {
- ArtifactDownloadReport aReport = new
ArtifactDownloadReport(
- DefaultArtifact.newIvyArtifact(mrids[j], null));
- aReport.setDownloadStatus(DownloadStatus.SUCCESSFUL);
- // TODO cache: store metadata cache info in report and
reuse it
-
aReport.setLocalFile(settings.getResolver(mrids[j].getModuleId())
-
.getRepositoryCacheManager().getIvyFileInCache(mrids[j]));
- artifacts.add(aReport);
+ artifacts.add(parser.getMetadataArtifactReport(mrids[j]));
}
}
for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/NameSpaceHelper.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/NameSpaceHelper.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/NameSpaceHelper.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/namespace/NameSpaceHelper.java
Fri Dec 28 04:16:22 2007
@@ -26,7 +26,6 @@
import org.apache.ivy.core.module.id.ArtifactId;
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
-import org.apache.ivy.core.resolve.DefaultModuleRevision;
import org.apache.ivy.core.resolve.ResolvedModuleRevision;
public final class NameSpaceHelper {
@@ -54,8 +53,8 @@
if (md.equals(rmr.getDescriptor())) {
return rmr;
}
- return new DefaultModuleRevision(rmr.getResolver(),
rmr.getArtifactResolver(), md, rmr
- .isSearched(), rmr.isDownloaded());
+ return new ResolvedModuleRevision(
+ rmr.getResolver(), rmr.getArtifactResolver(), md, rmr.getReport());
}
public static Artifact transform(Artifact artifact, NamespaceTransformer
t) {
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportParser.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportParser.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportParser.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportParser.java
Fri Dec 28 04:16:22 2007
@@ -38,6 +38,7 @@
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.ArtifactDownloadReport;
import org.apache.ivy.core.report.DownloadStatus;
+import org.apache.ivy.core.report.MetadataArtifactDownloadReport;
import org.apache.ivy.util.extendable.ExtendableItemHelper;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@@ -45,15 +46,17 @@
public class XmlReportParser {
private static class SaxXmlReportParser {
- private List mrids;
+ private List/*<ModuleRevisionId>*/ mrids;
- private List defaultMrids;
+ private List/*<ModuleRevisionId>*/ defaultMrids;
- private List realMrids;
+ private List/*<ModuleRevisionId>*/ realMrids;
- private List artifacts;
+ private List/*<Artifact>*/ artifacts;
- private List artifactReports;
+ private List/*<ArtifactDownloadReport>*/ artifactReports;
+
+ private Map/*<ModuleRevisionId,MetadataArtifactDownloadReport>*/
metadataReports;
private ModuleRevisionId mRevisionId;
@@ -65,6 +68,7 @@
mrids = new ArrayList();
defaultMrids = new ArrayList();
realMrids = new ArrayList();
+ metadataReports = new HashMap();
this.report = report;
}
@@ -122,6 +126,11 @@
if (isDefault) {
defaultMrids.add(mrid);
} else {
+ Artifact metadataArtifact =
+ DefaultArtifact.newIvyArtifact(mrid,
pubdate);
+ MetadataArtifactDownloadReport madr =
+ new
MetadataArtifactDownloadReport(metadataArtifact);
+ metadataReports.put(mrid, madr);
realMrids.add(mrid);
}
try {
@@ -133,6 +142,39 @@
+ attributes.getValue("pubdate"));
}
}
+ } else if ("metadata-artifact".equals(qName)) {
+ if (skip) {
+ return;
+ }
+ MetadataArtifactDownloadReport madr =
+ (MetadataArtifactDownloadReport)
metadataReports.get(mrid);
+ if (madr != null) {
+ madr.setDownloadStatus(
+
DownloadStatus.fromString(attributes.getValue("status")));
+
madr.setDownloadDetails(attributes.getValue("details"));
+
madr.setSize(Long.parseLong(attributes.getValue("size")));
+
madr.setDownloadTimeMillis(Long.parseLong(attributes.getValue("time")));
+
madr.setSearched(Boolean.parseBoolean(attributes.getValue("searched")));
+ if (attributes.getValue("location") != null) {
+ madr.setLocalFile(new
File(attributes.getValue("location")));
+ }
+ if (attributes.getValue("original-local-location")
!= null) {
+ madr.setOriginalLocalFile(
+ new
File(attributes.getValue("original-local-location")));
+ }
+ if (attributes.getValue("origin-location") !=
null) {
+ if
(ArtifactOrigin.UNKNOWN.getLocation().equals(
+
attributes.getValue("origin-location"))) {
+
madr.setArtifactOrigin(ArtifactOrigin.UNKNOWN);
+ } else {
+ madr.setArtifactOrigin(
+ new ArtifactOrigin(
+ Boolean.parseBoolean(
+
attributes.getValue("origin-is-local")),
+
attributes.getValue("origin-location")));
+ }
+ }
+ }
} else if ("artifact".equals(qName)) {
if (skip) {
return;
@@ -160,10 +202,15 @@
ArtifactDownloadReport aReport =
(ArtifactDownloadReport)
revisionArtifacts.get(revisionArtifacts.size() -
1);
- aReport.setArtifactOrigin(
- new ArtifactOrigin(
-
Boolean.parseBoolean(attributes.getValue("is-local")),
- attributes.getValue("location")));
+ if (ArtifactOrigin.UNKNOWN.getLocation().equals(
+ attributes.getValue("location"))) {
+ aReport.setArtifactOrigin(ArtifactOrigin.UNKNOWN);
+ } else {
+ aReport.setArtifactOrigin(
+ new ArtifactOrigin(
+
Boolean.parseBoolean(attributes.getValue("is-local")),
+ attributes.getValue("location")));
+ }
} else if ("info".equals(qName)) {
String organisation =
attributes.getValue("organisation");
String name = attributes.getValue("module");
@@ -228,6 +275,10 @@
public ModuleRevisionId getResolvedModule() {
return mRevisionId;
}
+
+ public MetadataArtifactDownloadReport
getMetadataArtifactReport(ModuleRevisionId id) {
+ return (MetadataArtifactDownloadReport) metadataReports.get(id);
+ }
}
private SaxXmlReportParser parser = null;
@@ -267,6 +318,10 @@
public ModuleRevisionId[] getRealDependencyRevisionIds() {
return (ModuleRevisionId[]) parser.getRealModuleRevisionIds().toArray(
new ModuleRevisionId[parser.getRealModuleRevisionIds().size()]);
+ }
+
+ public MetadataArtifactDownloadReport
getMetadataArtifactReport(ModuleRevisionId id) {
+ return parser.getMetadataArtifactReport(id);
}
/**
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java
Fri Dec 28 04:16:22 2007
@@ -35,6 +35,7 @@
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.ArtifactDownloadReport;
import org.apache.ivy.core.report.ConfigurationResolveReport;
+import org.apache.ivy.core.report.MetadataArtifactDownloadReport;
import org.apache.ivy.core.resolve.IvyNode;
import org.apache.ivy.core.resolve.IvyNodeCallers.Caller;
import org.apache.ivy.core.resolve.IvyNodeEviction.EvictionData;
@@ -171,6 +172,33 @@
+ XMLHelper.escape(licenses[i].getName()) + "\""
+ lurl + "/>");
}
+ }
+ if (dep.getModuleRevision() != null) {
+ MetadataArtifactDownloadReport madr =
dep.getModuleRevision().getReport();
+ out.print("\t\t\t\t<metadata-artifact");
+ out.print(" status=\""
+ + XMLHelper.escape(madr.getDownloadStatus().toString()) +
"\"");
+ out.print(" details=\"" +
XMLHelper.escape(madr.getDownloadDetails()) + "\"");
+ out.print(" size=\"" + madr.getSize() + "\"");
+ out.print(" time=\"" + madr.getDownloadTimeMillis() + "\"");
+ if (madr.getLocalFile() != null) {
+ out.print(" location=\""
+ + XMLHelper.escape(madr.getLocalFile().getAbsolutePath())
+ "\"");
+ }
+
+ out.print(" searched=\"" + madr.isSearched() + "\"");
+ if (madr.getOriginalLocalFile() != null) {
+ out.print(" original-local-location=\""
+ +
XMLHelper.escape(madr.getOriginalLocalFile().getAbsolutePath()) + "\"");
+ }
+
+ ArtifactOrigin origin = madr.getArtifactOrigin();
+ if (origin != null) {
+ out.print(" origin-is-local=\"" +
String.valueOf(origin.isLocal()) + "\"");
+ out.print(" origin-location=\"" +
XMLHelper.escape(origin.getLocation()) + "\"");
+ }
+ out.println("/>");
+
}
if (dep.isEvicted(report.getConfiguration())) {
EvictionData ed = dep.getEvictedData(report.getConfiguration());
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
Fri Dec 28 04:16:22 2007
@@ -54,7 +54,7 @@
import org.apache.ivy.core.report.ArtifactDownloadReport;
import org.apache.ivy.core.report.DownloadReport;
import org.apache.ivy.core.report.DownloadStatus;
-import org.apache.ivy.core.resolve.DefaultModuleRevision;
+import org.apache.ivy.core.report.MetadataArtifactDownloadReport;
import org.apache.ivy.core.resolve.DownloadOptions;
import org.apache.ivy.core.resolve.IvyNode;
import org.apache.ivy.core.resolve.ResolveData;
@@ -171,8 +171,6 @@
try {
clearIvyAttempts();
clearArtifactAttempts();
- boolean downloaded = false;
- boolean searched = false;
ModuleRevisionId systemMrid = systemDd.getDependencyRevisionId();
ModuleRevisionId nsMrid = nsDd.getDependencyRevisionId();
@@ -215,9 +213,9 @@
}
}
checkInterrupted();
+ ResolvedModuleRevision rmr = null;
ResolvedResource ivyRef = findIvyFileRef(nsDd, data);
checkInterrupted();
- searched = true;
// get module descriptor
final ModuleDescriptorParser parser;
@@ -255,9 +253,14 @@
nsMd.setResolvedModuleRevisionId(ModuleRevisionId.newInstance(nsMrid,
artifactRef.getRevision()));
}
+ systemMd = toSystem(nsMd);
+ MetadataArtifactDownloadReport madr =
+ new
MetadataArtifactDownloadReport(systemMd.getMetadataArtifact());
+ madr.setDownloadStatus(DownloadStatus.NO);
+ madr.setSearched(true);
+ rmr = new ResolvedModuleRevision(this, this, systemMd,
madr);
}
} else {
- ResolvedModuleRevision rmr = null;
if (ivyRef instanceof MDResolvedResource) {
rmr = ((MDResolvedResource)
ivyRef).getResolvedModuleRevision();
}
@@ -267,7 +270,7 @@
return null;
}
}
- if (!rmr.isDownloaded()) {
+ if (!rmr.getReport().isDownloaded()) {
return toSystem(rmr);
} else {
nsMd = rmr.getDescriptor();
@@ -280,10 +283,10 @@
checkDescriptorConsistency(systemMrid, systemMd,
ivyRef);
checkDescriptorConsistency(nsMrid, nsMd, ivyRef);
} else {
- if (nsMd instanceof DefaultModuleDescriptor) {
- String revision = getRevision(ivyRef, nsMrid,
nsMd);
- ((DefaultModuleDescriptor)
nsMd).setModuleRevisionId(ModuleRevisionId
- .newInstance(nsMrid, revision));
+ if (systemMd instanceof DefaultModuleDescriptor) {
+ String revision = getRevision(ivyRef, systemMrid,
systemMd);
+ ((DefaultModuleDescriptor)
systemMd).setModuleRevisionId(
+ ModuleRevisionId.newInstance(systemMrid,
revision));
} else {
Message.warn(
"consistency disabled with instance of non
DefaultModuleDescriptor..."
@@ -292,17 +295,23 @@
checkDescriptorConsistency(systemMrid, systemMd,
ivyRef);
}
}
+ MetadataArtifactDownloadReport madr =
+ new
MetadataArtifactDownloadReport(systemMd.getMetadataArtifact());
+
madr.setDownloadStatus(rmr.getReport().getDownloadStatus());
+
madr.setDownloadDetails(rmr.getReport().getDownloadDetails());
+
madr.setArtifactOrigin(rmr.getReport().getArtifactOrigin());
+
madr.setDownloadTimeMillis(rmr.getReport().getDownloadTimeMillis());
+ madr.setSize(rmr.getReport().getSize());
+
madr.setOriginalLocalFile(rmr.getReport().getOriginalLocalFile());
+ madr.setSearched(true);
+ rmr = new ResolvedModuleRevision(this, this, systemMd,
madr);
}
}
- if (systemMd == null) {
- systemMd = toSystem(nsMd);
- }
-
// resolve revision
- ModuleRevisionId resolvedMrid = nsMrid;
+ ModuleRevisionId resolvedMrid = systemMrid;
if (isDynamic) {
- resolvedMrid = nsMd.getResolvedModuleRevisionId();
+ resolvedMrid = systemMd.getResolvedModuleRevisionId();
if (resolvedMrid.getRevision() == null
|| resolvedMrid.getRevision().length() == 0) {
if (ivyRef.getRevision() == null ||
ivyRef.getRevision().length() == 0) {
@@ -316,10 +325,7 @@
Message.verbose("\t\t[" + toSystem(resolvedMrid).getRevision()
+ "] "
+ systemMrid.getModuleId());
}
- nsMd.setResolvedModuleRevisionId(resolvedMrid);
-
- // keep system md in sync with ns md
- systemMd.setResolvedModuleRevisionId(toSystem(resolvedMrid));
+ systemMd.setResolvedModuleRevisionId(resolvedMrid);
// check module descriptor revision
if (!getSettings().getVersionMatcher().accept(systemMrid,
systemMd)) {
@@ -342,14 +348,13 @@
+ systemMrid);
return null;
}
- nsMd.setResolvedPublicationDate(new Date(pubDate));
systemMd.setResolvedPublicationDate(new Date(pubDate));
}
- if (!nsMd.isDefault()
+ if (!systemMd.isDefault()
&& data.getSettings().logNotConvertedExclusionRule()
- && nsMd instanceof DefaultModuleDescriptor) {
- DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) nsMd;
+ && systemMd instanceof DefaultModuleDescriptor) {
+ DefaultModuleDescriptor dmd = (DefaultModuleDescriptor)
systemMd;
if (dmd.isNamespaceUseful()) {
Message.warn(
"the module descriptor "
@@ -372,7 +377,7 @@
ivyRef.getResource());
cacheManager.originalToCachedModuleDescriptor(this, ivyRef,
requestedMetadataArtifact,
- systemMd, new ModuleDescriptorWriter() {
+ rmr, new ModuleDescriptorWriter() {
public void write(ResolvedResource originalMdResource,
ModuleDescriptor md,
File src, File dest)
throws IOException, ParseException {
@@ -393,7 +398,7 @@
}
});
- return new DefaultModuleRevision(this, this, systemMd, searched,
downloaded);
+ return rmr;
} finally {
IvyContext.popContext();
}
@@ -451,7 +456,8 @@
} else {
Message.verbose("\t" + getName() + ": revision already
resolved: "
+ resolvedMrid);
- return
DefaultModuleRevision.searchedRmr(node.getModuleRevision());
+ node.getModuleRevision().getReport().setSearched(true);
+ return node.getModuleRevision();
}
}
}
@@ -491,9 +497,14 @@
protected ResourceMDParser getDefaultRMDParser(final ModuleId mid) {
return new ResourceMDParser() {
public MDResolvedResource parse(Resource resource, String rev) {
- return new MDResolvedResource(resource, rev, new
DefaultModuleRevision(
- BasicResolver.this, BasicResolver.this,
DefaultModuleDescriptor
- .newDefaultInstance(new ModuleRevisionId(mid,
rev)), false, false));
+ DefaultModuleDescriptor md =
+ DefaultModuleDescriptor.newDefaultInstance(new
ModuleRevisionId(mid, rev));
+ MetadataArtifactDownloadReport madr =
+ new
MetadataArtifactDownloadReport(md.getMetadataArtifact());
+ madr.setDownloadStatus(DownloadStatus.NO);
+ madr.setSearched(true);
+ return new MDResolvedResource(resource, rev, new
ResolvedModuleRevision(
+ BasicResolver.this, BasicResolver.this, md, madr));
}
};
}
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
Fri Dec 28 04:16:22 2007
@@ -38,7 +38,6 @@
import org.apache.ivy.plugins.latest.ArtifactInfo;
import org.apache.ivy.plugins.latest.LatestStrategy;
import org.apache.ivy.plugins.resolver.util.HasLatestStrategy;
-import org.apache.ivy.plugins.resolver.util.ResolvedModuleRevisionProxy;
import org.apache.ivy.plugins.resolver.util.ResolvedResource;
import org.apache.ivy.util.Message;
@@ -156,7 +155,8 @@
private ResolvedModuleRevision resolvedRevision(ResolvedModuleRevision mr)
{
if (isDual() && mr != null) {
- return new ResolvedModuleRevisionProxy(mr, this);
+ return new ResolvedModuleRevision(
+ mr.getResolver(), this, mr.getDescriptor(), mr.getReport());
} else {
return mr;
}
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
Fri Dec 28 04:16:22 2007
@@ -28,7 +28,6 @@
import org.apache.ivy.core.resolve.DownloadOptions;
import org.apache.ivy.core.resolve.ResolveData;
import org.apache.ivy.core.resolve.ResolvedModuleRevision;
-import org.apache.ivy.plugins.resolver.util.ResolvedModuleRevisionProxy;
import org.apache.ivy.plugins.resolver.util.ResolvedResource;
import org.apache.ivy.util.Message;
@@ -78,7 +77,8 @@
return null;
}
} else {
- return new ResolvedModuleRevisionProxy(mr, this);
+ return new ResolvedModuleRevision(
+ mr.getResolver(), this, mr.getDescriptor(), mr.getReport());
}
}
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/cache/CacheManagerTest.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/cache/CacheManagerTest.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/core/cache/CacheManagerTest.java
(original)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/core/cache/CacheManagerTest.java
Fri Dec 28 04:16:22 2007
@@ -68,7 +68,7 @@
artifact = createArtifact("org", "module", "rev", "name", "type2",
"ext");
found = cacheManager.getSavedArtifactOrigin(artifact);
- assertNull(found);
+ assertEquals(ArtifactOrigin.UNKNOWN, found);
}
public void testUniqueness() {
@@ -76,27 +76,27 @@
artifact = createArtifact("org1", "module", "rev", "name", "type",
"ext");
ArtifactOrigin found = cacheManager.getSavedArtifactOrigin(artifact);
- assertNull(found);
+ assertEquals(ArtifactOrigin.UNKNOWN, found);
artifact = createArtifact("org", "module1", "rev", "name", "type",
"ext");
found = cacheManager.getSavedArtifactOrigin(artifact);
- assertNull(found);
+ assertEquals(ArtifactOrigin.UNKNOWN, found);
artifact = createArtifact("org", "module", "rev1", "name", "type",
"ext");
found = cacheManager.getSavedArtifactOrigin(artifact);
- assertNull(found);
+ assertEquals(ArtifactOrigin.UNKNOWN, found);
artifact = createArtifact("org", "module", "rev", "name1", "type",
"ext");
found = cacheManager.getSavedArtifactOrigin(artifact);
- assertNull(found);
+ assertEquals(ArtifactOrigin.UNKNOWN, found);
artifact = createArtifact("org", "module", "rev", "name", "type1",
"ext");
found = cacheManager.getSavedArtifactOrigin(artifact);
- assertNull(found);
+ assertEquals(ArtifactOrigin.UNKNOWN, found);
artifact = createArtifact("org", "module", "rev", "name", "type",
"ext1");
found = cacheManager.getSavedArtifactOrigin(artifact);
- assertNull(found);
+ assertEquals(ArtifactOrigin.UNKNOWN, found);
}
protected Artifact createArtifact(String org, String module, String rev,
String name,
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MockResolver.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MockResolver.java?rev=607221&r1=607220&r2=607221&view=diff
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MockResolver.java
(original)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/MockResolver.java
Fri Dec 28 04:16:22 2007
@@ -19,7 +19,6 @@
import java.io.File;
import java.io.IOException;
-import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
@@ -29,9 +28,9 @@
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
-import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.DownloadReport;
+import org.apache.ivy.core.report.MetadataArtifactDownloadReport;
import org.apache.ivy.core.resolve.DownloadOptions;
import org.apache.ivy.core.resolve.ResolveData;
import org.apache.ivy.core.resolve.ResolvedModuleRevision;
@@ -54,39 +53,10 @@
final MockResolver r = new MockResolver();
r.setName(name);
if (findRevision) {
- r.rmr = new ResolvedModuleRevision() {
- public DependencyResolver getResolver() {
- return r;
- }
-
- public ModuleRevisionId getId() {
- return mrid;
- }
-
- public Date getPublicationDate() {
- return publicationDate;
- }
-
- public ModuleDescriptor getDescriptor() {
- return new DefaultModuleDescriptor(mrid, "integration",
new Date(), isdefault);
- }
-
- public boolean isDownloaded() {
- return true;
- }
-
- public boolean isSearched() {
- return true;
- }
-
- public DependencyResolver getArtifactResolver() {
- return r;
- }
-
- public URL getLocalMDUrl() {
- return null;
- }
- };
+ DefaultModuleDescriptor md = new DefaultModuleDescriptor(
+ mrid, "integration", publicationDate, isdefault);
+ r.rmr = new ResolvedModuleRevision(
+ r, r, md, new
MetadataArtifactDownloadReport(md.getMetadataArtifact()));
}
return r;
}