use of org.apache.ivy.core.retrieve.RetrieveReport in project ant-ivy by apache.
the class IvyRetrieve method doExecute.
@SuppressWarnings("deprecation")
@Override
public void doExecute() throws BuildException {
prepareAndCheck();
if (!getAllowedLogOptions().contains(getLog())) {
throw new BuildException("invalid option for 'log': " + getLog() + ". Available options are " + getAllowedLogOptions());
}
pattern = getProperty(pattern, getSettings(), "ivy.retrieve.pattern");
try {
final Filter<Artifact> artifactFilter = getArtifactFilter();
final RetrieveOptions retrieveOptions = (RetrieveOptions) new RetrieveOptions().setLog(getLog());
retrieveOptions.setConfs(splitToArray(getConf())).setDestArtifactPattern(pattern).setDestIvyPattern(ivypattern).setArtifactFilter(artifactFilter).setSync(sync).setOverwriteMode(getOverwriteMode()).setUseOrigin(isUseOrigin()).setMakeSymlinks(symlink).setResolveId(getResolveId()).setMapper(mapper == null ? null : new MapperAdapter(mapper));
// only set this if the user has explicitly enabled this deprecated option
if (symlinkmass) {
retrieveOptions.setMakeSymlinksInMass(symlinkmass);
}
final RetrieveReport report = getIvyInstance().retrieve(getResolvedMrid(), retrieveOptions);
int targetsCopied = report.getNbrArtifactsCopied();
boolean haveTargetsBeenCopied = targetsCopied > 0;
getProject().setProperty("ivy.nb.targets.copied", String.valueOf(targetsCopied));
getProject().setProperty("ivy.targets.copied", String.valueOf(haveTargetsBeenCopied));
if (getPathId() != null) {
Path path = new Path(getProject());
getProject().addReference(getPathId(), path);
for (File file : report.getRetrievedFiles()) {
path.createPathElement().setLocation(file);
}
}
if (getSetId() != null) {
FileSet fileset = new FileSet();
fileset.setProject(getProject());
getProject().addReference(getSetId(), fileset);
fileset.setDir(report.getRetrieveRoot());
for (File file : report.getRetrievedFiles()) {
PatternSet.NameEntry ne = fileset.createInclude();
ne.setName(getPath(report.getRetrieveRoot(), file));
}
}
} catch (Exception ex) {
throw new BuildException("impossible to ivy retrieve: " + ex, ex);
}
}
Aggregations