use of org.apache.tools.ant.types.Path 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);
}
}
use of org.apache.tools.ant.types.Path in project ant-ivy by apache.
the class IvyBuildListTest method getFiles.
private String[] getFiles(IvyBuildList buildlist) {
buildlist.setReference("ordered.build.files");
buildlist.execute();
Object o = buildlist.getProject().getReference("ordered.build.files");
assertNotNull(o);
assertTrue(o instanceof Path);
Path path = (Path) o;
String[] files = path.list();
assertNotNull(files);
return files;
}
use of org.apache.tools.ant.types.Path in project ant-ivy by apache.
the class IvyCachePathTest method testInline1.
@Test
public void testInline1() {
// we first resolve another ivy file
IvyResolve resolve = new IvyResolve();
resolve.setProject(project);
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-latest.xml"));
resolve.execute();
assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists());
// then we resolve a dependency directly
path.setOrganisation("org1");
path.setModule("mod1.2");
path.setRevision("2.0");
path.setInline(true);
path.setPathid("simple-pathid");
path.execute();
Object ref = project.getReference("simple-pathid");
assertNotNull(ref);
assertTrue(ref instanceof Path);
Path p = (Path) ref;
assertEquals(1, p.size());
assertEquals(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").getAbsolutePath(), new File(p.list()[0]).getAbsolutePath());
}
use of org.apache.tools.ant.types.Path in project ant-ivy by apache.
the class IvyCachePathTest method testWithResolveIdWithoutResolve.
@Test
public void testWithResolveIdWithoutResolve() {
Project otherProject = TestHelper.newProject();
otherProject.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
IvyResolve resolve = new IvyResolve();
resolve.setProject(otherProject);
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
resolve.setResolveId("withResolveId");
resolve.execute();
// resolve another ivy file
resolve = new IvyResolve();
resolve.setProject(project);
resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-latest.xml"));
resolve.execute();
path.setResolveId("withResolveId");
path.setPathid("withresolveid-pathid");
path.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml"));
path.execute();
Object ref = project.getReference("withresolveid-pathid");
assertNotNull(ref);
assertTrue(ref instanceof Path);
Path p = (Path) ref;
assertEquals(1, p.size());
assertEquals(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", "jar", "jar").getAbsolutePath(), new File(p.list()[0]).getAbsolutePath());
}
use of org.apache.tools.ant.types.Path in project ant-ivy by apache.
the class IvyCachePathTest method testEmptyConf.
@Test
public void testEmptyConf() {
project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-108.xml");
path.setPathid("emptyconf-pathid");
path.setConf("empty");
path.execute();
Object ref = project.getReference("emptyconf-pathid");
assertNotNull(ref);
assertTrue(ref instanceof Path);
Path p = (Path) ref;
assertEquals(0, p.size());
}
Aggregations