public void download(Artifact artifact, Resource resource, File dest) throws IOException { if (dest.exists()) { dest.delete(); } File part = new File(dest.getAbsolutePath() + ".part"); if (resource.getName().equals(String.valueOf(artifact.getUrl()))) { if (part.getParentFile() != null) { part.getParentFile().mkdirs(); } extartifactrep.get(resource.getName(), part); } else { getAndCheck(resource, part); } if (!part.renameTo(dest)) { throw new IOException("impossible to move part file to definitive one: " + part + " -> " + dest); } } };
public ResolvedResource findArtifactRef(Artifact artifact, Date date) { URL url = artifact.getUrl(); if (url == null) { // not an artifact resolved by this resolver return null; } Message.verbose("\tusing url for " + artifact + ": " + url); logArtifactAttempt(artifact, url.toExternalForm()); Resource resource = new URLResource(url); return new ResolvedResource(resource, artifact.getModuleRevisionId().getRevision()); }
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); } }
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].getQualifiedExtraAttributes()));
public static Artifact cloneWithAnotherTypeAndExt(Artifact artifact, String newType, String newExt) { return new DefaultArtifact(ArtifactRevisionId.newInstance(artifact.getModuleRevisionId(), artifact.getName(), newType, newExt, artifact.getQualifiedExtraAttributes()), artifact.getPublicationDate(), artifact.getUrl(), artifact.isMetadata()); }
public static Artifact cloneWithAnotherName(Artifact artifact, String name) { return new DefaultArtifact(ArtifactRevisionId.newInstance(artifact.getModuleRevisionId(), name, artifact.getType(), artifact.getExt(), artifact.getQualifiedExtraAttributes()), artifact.getPublicationDate(), artifact.getUrl(), artifact.isMetadata()); }
public static Artifact cloneWithAnotherMrid(Artifact artifact, ModuleRevisionId mrid) { return new DefaultArtifact(ArtifactRevisionId.newInstance(mrid, artifact.getName(), artifact.getType(), artifact.getExt(), artifact.getQualifiedExtraAttributes()), artifact.getPublicationDate(), artifact.getUrl(), artifact.isMetadata()); }
public static Artifact transform(Artifact artifact, NamespaceTransformer t) { if (t.isIdentity()) { return artifact; } ModuleRevisionId mrid = t.transform(artifact.getModuleRevisionId()); if (artifact.getModuleRevisionId().equals(mrid)) { return artifact; } return new DefaultArtifact(mrid, artifact.getPublicationDate(), artifact.getName(), artifact.getType(), artifact.getExt(), artifact.getUrl(), artifact.getQualifiedExtraAttributes()); }