You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ja...@apache.org on 2018/08/19 14:35:08 UTC
ant-ivy git commit: In continuation of commit
7131e1c028e0035de548c6b37e1e8c9624417440,
make sure the ArtifactOrigin's location is treated as a URL consistently in
relevant places
Repository: ant-ivy
Updated Branches:
refs/heads/master 7131e1c02 -> ecc271c49
In continuation of commit 7131e1c028e0035de548c6b37e1e8c9624417440, make sure the ArtifactOrigin's location is treated as a URL consistently in relevant places
Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/ecc271c4
Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/ecc271c4
Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/ecc271c4
Branch: refs/heads/master
Commit: ecc271c49247604b5a6396a46ef83fc6b94be594
Parents: 7131e1c
Author: Jaikiran Pai <ja...@apache.org>
Authored: Sun Aug 19 20:02:35 2018 +0530
Committer: Jaikiran Pai <ja...@apache.org>
Committed: Sun Aug 19 20:04:01 2018 +0530
----------------------------------------------------------------------
.../apache/ivy/core/cache/ArtifactOrigin.java | 20 ++++++++++++++++++++
.../cache/DefaultRepositoryCacheManager.java | 4 ++--
2 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/ecc271c4/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java b/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java
index e65a683..e2a5d47 100644
--- a/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java
+++ b/src/java/org/apache/ivy/core/cache/ArtifactOrigin.java
@@ -20,6 +20,9 @@ package org.apache.ivy.core.cache;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.util.Checks;
+import java.net.MalformedURLException;
+import java.net.URL;
+
/**
* This class contains information about the origin of an artifact.
*
@@ -110,6 +113,23 @@ public class ArtifactOrigin {
this.location = location;
}
+ // the "location" of an ArtifactOrigin is expected to be URL. However,
+ // in certain versions of Ivy we used to save just the path as the location
+ // instead of the URL form. Here we try and read it as a URL. If it can be
+ // read as a URL, we return the URL#getPath. However, if it can't be read
+ // as a URL, then considering backward compatibility, we treat the "location"
+ // as a path and return it back.
+ String getLocationPath() {
+ if (this.location == null) {
+ return null;
+ }
+ try {
+ return new URL(this.location).getPath();
+ } catch (MalformedURLException e) {
+ return this.location;
+ }
+ }
+
/**
* Return the artifact that this location is pointing at.
*
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/ecc271c4/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java b/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
index 91257b0..1eb562f 100644
--- a/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
+++ b/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
@@ -384,7 +384,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
public File getArchiveFileInCache(Artifact artifact, ArtifactOrigin origin) {
File archive = new File(getRepositoryCacheRoot(), getArchivePathInCache(artifact, origin));
if (!archive.exists() && !ArtifactOrigin.isUnknown(origin) && origin.isLocal()) {
- File original = Checks.checkAbsolute(origin.getLocation(), artifact
+ File original = Checks.checkAbsolute(origin.getLocationPath(), artifact
+ " origin location");
if (original.exists()) {
return original;
@@ -406,7 +406,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
*/
private File getArchiveFileInCache(Artifact artifact, ArtifactOrigin origin, boolean useOrigin) {
if (useOrigin && !ArtifactOrigin.isUnknown(origin) && origin.isLocal()) {
- return Checks.checkAbsolute(origin.getLocation(), artifact + " origin location");
+ return Checks.checkAbsolute(origin.getLocationPath(), artifact + " origin location");
}
return new File(getRepositoryCacheRoot(), getArchivePathInCache(artifact, origin));
}