@Test public void init() { assertSame(testPom, artifactPom.getPom()); assertEquals(expectedArtifact, artifactPom.getArtifact()); assertEquals(expectedFile, artifactPom.getArtifactFile()); checkPom( expectedArtifact.getModuleRevisionId().getOrganisation(), expectedArtifact.getName(), expectedArtifact.getType(), expectedArtifact.getModuleRevisionId().getRevision(), expectedArtifact.getExtraAttribute(DependencyManager.CLASSIFIER)); }
protected ResolvedResource getArtifactRef(Artifact artifact, Date date) { IvyContext.getContext().set(getName() + ".artifact", artifact); try { ResolvedResource ret = findArtifactRef(artifact, date); if (ret == null && artifact.getUrl() != null) { URL url = artifact.getUrl(); Message.verbose("\tusing url for " + artifact + ": " + url); logArtifactAttempt(artifact, url.toExternalForm()); Resource resource; if ("file".equals(url.getProtocol())) { File f; try { f = new File(new URI(url.toExternalForm())); } catch (URISyntaxException e) { // unexpected, try to get the best of it f = new File(url.getPath()); } resource = new FileResource(new FileRepository(), f); } else { resource = new URLResource(url); } ret = new ResolvedResource(resource, artifact.getModuleRevisionId().getRevision()); } return ret; } finally { IvyContext.getContext().set(getName() + ".artifact", null); } }
private File downloadTimestampedVersion(Artifact artifact, String timestampedVersion) throws IOException { final ModuleRevisionId artifactModuleRevisionId = artifact.getModuleRevisionId(); final ModuleRevisionId moduleRevisionId = ModuleRevisionId.newInstance( artifactModuleRevisionId.getOrganisation(), artifactModuleRevisionId.getName(), artifactModuleRevisionId.getRevision(), WrapUtil.toMap("timestamp", timestampedVersion)); final Artifact artifactWithResolvedModuleRevisionId = DefaultArtifact.cloneWithAnotherMrid(artifact, moduleRevisionId); return download(artifactWithResolvedModuleRevisionId); }
@Test public void initWithCustomPomSettings() { testPom.setArtifactId(expectedArtifact.getName() + "X"); testPom.setGroupId(expectedArtifact.getModuleRevisionId().getOrganisation() + "X"); testPom.setVersion(expectedArtifact.getModuleRevisionId().getRevision() + "X"); testPom.setPackaging(expectedArtifact.getType() + "X"); testPom.setClassifier(expectedArtifact.getExtraAttribute(DependencyManager.CLASSIFIER) + "X"); artifactPom = new DefaultArtifactPom(testPom, expectedArtifact, expectedFile); assertEquals(expectedArtifact, artifactPom.getArtifact()); assertEquals(expectedFile, artifactPom.getArtifactFile()); checkPom( testPom.getGroupId(), testPom.getArtifactId(), testPom.getPackaging(), testPom.getVersion(), testPom.getClassifier()); }