mirror of https://github.com/apache/ant-ivy
Treat the ArtifactOrigin's location as a URL (as already stated in its javadoc).
Should solve issues, especially on Windows OS, like the one reported in https://www.mail-archive.com/ivy-user@ant.apache.org/msg06324.html
This commit is contained in:
parent
556022e02a
commit
7131e1c028
|
|
@ -19,7 +19,6 @@ package org.apache.ivy.core.cache;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
|
@ -1011,7 +1010,7 @@ public class DefaultRepositoryCacheManager implements RepositoryCacheManager, Iv
|
|||
if (useOrigin && artifactRes.isLocal()) {
|
||||
if (artifactRes instanceof LocalizableResource) {
|
||||
origin.setLocation(((LocalizableResource) artifactRes).getFile()
|
||||
.getAbsolutePath());
|
||||
.toURI().toURL().toExternalForm());
|
||||
}
|
||||
saveArtifactOrigin(artifact, origin);
|
||||
archiveFile = getArchiveFileInCache(artifact, origin);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.ivy.Ivy;
|
||||
|
|
@ -48,6 +49,7 @@ import org.apache.ivy.util.Message;
|
|||
import org.apache.tools.ant.Project;
|
||||
import org.apache.tools.ant.taskdefs.Delete;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
|
@ -192,6 +194,23 @@ public class DefaultRepositoryCacheManagerTest {
|
|||
assertEquals(rmr11, rmrFromCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the {@link ArtifactOrigin#getLocation()} and {@link ArtifactOrigin#setLocation(String)} values
|
||||
* are treated as {@link URL} while saving and retrieving the artifact origin information
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testArtificationOriginalLocation() throws Exception {
|
||||
final Artifact simpleArtifact = createArtifact("org", "dummy", "1.0.0", "hello", "jar", "jar");
|
||||
final URL location = new File("dummylocation").toURI().toURL();
|
||||
final ArtifactOrigin originatedFrom = new ArtifactOrigin(simpleArtifact, true, location.toExternalForm());
|
||||
cacheManager.saveArtifactOrigin(simpleArtifact, originatedFrom);
|
||||
final ArtifactOrigin restored = cacheManager.getSavedArtifactOrigin(simpleArtifact);
|
||||
Assert.assertNotNull("Location of artifact origin wasn't expected to be null", restored.getLocation());
|
||||
Assert.assertEquals("Unexpected artifact origin location", location, new URL(restored.getLocation()));
|
||||
}
|
||||
|
||||
private static DefaultArtifact createArtifact(String org, String module, String rev,
|
||||
String name, String type, String ext) {
|
||||
ModuleId mid = new ModuleId(org, module);
|
||||
|
|
|
|||
Loading…
Reference in New Issue