Search in sources :

Example 6 with ResolveOptions

use of org.apache.ivy.core.resolve.ResolveOptions in project ant-ivy by apache.

the class IvyArtifactReport method doExecute.

public void doExecute() throws BuildException {
    prepareAndCheck();
    if (tofile == null) {
        throw new BuildException("no destination file name: please provide it through parameter 'tofile'");
    }
    pattern = getProperty(pattern, getSettings(), "ivy.retrieve.pattern");
    try {
        String[] confs = splitToArray(getConf());
        ModuleDescriptor md = null;
        if (getResolveId() == null) {
            md = getResolvedDescriptor(getOrganisation(), getModule(), false);
        } else {
            md = getResolvedDescriptor(getResolveId());
        }
        IvyNode[] dependencies = getIvyInstance().getResolveEngine().getDependencies(md, ((ResolveOptions) new ResolveOptions().setLog(getLog())).setConfs(confs).setResolveId(getResolveId()).setValidate(doValidate(getSettings())), null);
        Map<ArtifactDownloadReport, Set<String>> artifactsToCopy = getIvyInstance().getRetrieveEngine().determineArtifactsToCopy(ModuleRevisionId.newInstance(getOrganisation(), getModule(), getRevision()), pattern, ((RetrieveOptions) new RetrieveOptions().setLog(getLog())).setConfs(confs).setResolveId(getResolveId()));
        Map<ModuleRevisionId, Set<ArtifactDownloadReport>> moduleRevToArtifactsMap = new HashMap<>();
        for (ArtifactDownloadReport artifact : artifactsToCopy.keySet()) {
            Set<ArtifactDownloadReport> moduleRevArtifacts = moduleRevToArtifactsMap.get(artifact.getArtifact().getModuleRevisionId());
            if (moduleRevArtifacts == null) {
                moduleRevArtifacts = new HashSet<>();
                moduleRevToArtifactsMap.put(artifact.getArtifact().getModuleRevisionId(), moduleRevArtifacts);
            }
            moduleRevArtifacts.add(artifact);
        }
        generateXml(dependencies, moduleRevToArtifactsMap, artifactsToCopy);
    } catch (ParseException e) {
        log(e.getMessage(), Project.MSG_ERR);
        throw new BuildException("syntax errors in ivy file: " + e, e);
    } catch (IOException e) {
        throw new BuildException("impossible to generate report: " + e, e);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) RetrieveOptions(org.apache.ivy.core.retrieve.RetrieveOptions) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) IOException(java.io.IOException) ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) BuildException(org.apache.tools.ant.BuildException) ParseException(java.text.ParseException) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) IvyNode(org.apache.ivy.core.resolve.IvyNode)

Example 7 with ResolveOptions

use of org.apache.ivy.core.resolve.ResolveOptions in project ant-ivy by apache.

the class FileSystemResolverTest method setUp.

@Before
public void setUp() {
    settings = new IvySettings();
    engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
    cache = new File("build/cache");
    data = new ResolveData(engine, new ResolveOptions());
    cache.mkdirs();
    settings.setDefaultCache(cache);
    cacheManager = (DefaultRepositoryCacheManager) settings.getDefaultRepositoryCacheManager();
}
Also used : ResolveEngine(org.apache.ivy.core.resolve.ResolveEngine) SortEngine(org.apache.ivy.core.sort.SortEngine) ResolveData(org.apache.ivy.core.resolve.ResolveData) EventManager(org.apache.ivy.core.event.EventManager) IvySettings(org.apache.ivy.core.settings.IvySettings) File(java.io.File) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) Before(org.junit.Before)

Example 8 with ResolveOptions

use of org.apache.ivy.core.resolve.ResolveOptions in project ant-ivy by apache.

the class IBiblioMavenSnapshotsResolutionTest method testSnapshotResolution.

/**
 * Tests that an Ivy module that depends on regular and timestamped snapshots of Maven
 * artifacts, when resolved using a {@link IBiblioResolver} and with
 * {@link MavenTimedSnapshotVersionMatcher} configured in {@link IvySettings}, is resolved
 * correctly for such snapshot dependencies.
 *
 * @throws Exception
 *             if something goes wrong
 */
@Test
public void testSnapshotResolution() throws Exception {
    final IvySettings settings = this.ivy.getSettings();
    assertNotNull("Maven timestamped snapshot revision version matcher is absent", settings.getVersionMatcher(new MavenTimedSnapshotVersionMatcher().getName()));
    final ResolveOptions resolveOptions = new ResolveOptions();
    resolveOptions.setConfs(new String[] { "default" });
    final ResolveReport report = ivy.resolve(new File("test/repositories/2/maven-snapshot-deps-test/ivy-with-maven-snapshot-deps.xml"), resolveOptions);
    assertNotNull("Resolution report was null", report);
    assertFalse("Resolution report has error(s)", report.hasError());
    final ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull("Module descriptor in resolution report was null", md);
    final ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache.ivy", "maven-snapshot-deps-test", "1.2.3");
    assertEquals("Unexpected module resolved", mrid, md.getModuleRevisionId());
    final ConfigurationResolveReport crr = report.getConfigurationReport("default");
    final ModuleRevisionId exactRevision = ModuleRevisionId.newInstance("org.apache.ivy.maven-snapshot-test", "exact-revision", "2.3.4");
    final ArtifactDownloadReport[] dr1 = crr.getDownloadReports(exactRevision);
    assertNotNull("Artifact download report missing for dependency " + exactRevision, dr1);
    assertEquals("Unexpected number of artifact download report for dependency " + exactRevision, dr1.length, 1);
    final ArtifactDownloadReport exactRevDownloadReport = dr1[0];
    assertEquals("Unexpected download status for dependency " + exactRevision, exactRevDownloadReport.getDownloadStatus(), DownloadStatus.SUCCESSFUL);
    final ModuleRevisionId regularSnapshot = ModuleRevisionId.newInstance("org.apache.ivy.maven-snapshot-test", "regular-snapshot", "1.2.3-SNAPSHOT");
    final ArtifactDownloadReport[] dr2 = crr.getDownloadReports(regularSnapshot);
    assertNotNull("Artifact download report missing for dependency " + regularSnapshot, dr2);
    assertEquals("Unexpected number of artifact download report for dependency " + regularSnapshot, dr2.length, 1);
    final ArtifactDownloadReport regularSnapshotDownloadReport = dr2[0];
    assertEquals("Unexpected download status for dependency " + regularSnapshot, regularSnapshotDownloadReport.getDownloadStatus(), DownloadStatus.SUCCESSFUL);
    final ModuleRevisionId timestampedSnapshot = ModuleRevisionId.newInstance("org.apache.ivy.maven-snapshot-test", "timestamped-snapshot", "5.6.7-20170911.130943-1");
    final ArtifactDownloadReport[] dr3 = crr.getDownloadReports(timestampedSnapshot);
    assertNotNull("Artifact download report missing for dependency " + timestampedSnapshot, dr3);
    assertEquals("Unexpected number of artifact download report for dependency " + timestampedSnapshot, dr3.length, 1);
    final ArtifactDownloadReport timestampedSnapshotDownloadReport = dr3[0];
    assertEquals("Unexpected download status for dependency " + timestampedSnapshot, timestampedSnapshotDownloadReport.getDownloadStatus(), DownloadStatus.SUCCESSFUL);
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) ResolveReport(org.apache.ivy.core.report.ResolveReport) IvySettings(org.apache.ivy.core.settings.IvySettings) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) ConfigurationResolveReport(org.apache.ivy.core.report.ConfigurationResolveReport) MavenTimedSnapshotVersionMatcher(org.apache.ivy.plugins.version.MavenTimedSnapshotVersionMatcher) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) File(java.io.File) Test(org.junit.Test)

Example 9 with ResolveOptions

use of org.apache.ivy.core.resolve.ResolveOptions in project ant-ivy by apache.

the class IBiblioResolverTest method setUp.

@Before
public void setUp() {
    settings = new IvySettings();
    engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
    data = new ResolveData(engine, new ResolveOptions());
    TestHelper.createCache();
    settings.setDefaultCache(TestHelper.cache);
}
Also used : ResolveEngine(org.apache.ivy.core.resolve.ResolveEngine) SortEngine(org.apache.ivy.core.sort.SortEngine) ResolveData(org.apache.ivy.core.resolve.ResolveData) EventManager(org.apache.ivy.core.event.EventManager) IvySettings(org.apache.ivy.core.settings.IvySettings) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) Before(org.junit.Before)

Example 10 with ResolveOptions

use of org.apache.ivy.core.resolve.ResolveOptions in project ant-ivy by apache.

the class JarResolverTest method setUp.

@Before
public void setUp() {
    settings = new IvySettings();
    engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
    cache = new File("build/cache");
    data = new ResolveData(engine, new ResolveOptions());
    cache.mkdirs();
    settings.setDefaultCache(cache);
    cacheManager = (DefaultRepositoryCacheManager) settings.getDefaultRepositoryCacheManager();
}
Also used : ResolveEngine(org.apache.ivy.core.resolve.ResolveEngine) SortEngine(org.apache.ivy.core.sort.SortEngine) ResolveData(org.apache.ivy.core.resolve.ResolveData) EventManager(org.apache.ivy.core.event.EventManager) IvySettings(org.apache.ivy.core.settings.IvySettings) File(java.io.File) ResolveOptions(org.apache.ivy.core.resolve.ResolveOptions) Before(org.junit.Before)

Aggregations

ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)36 File (java.io.File)23 IvySettings (org.apache.ivy.core.settings.IvySettings)21 ResolveData (org.apache.ivy.core.resolve.ResolveData)19 Before (org.junit.Before)16 ResolveReport (org.apache.ivy.core.report.ResolveReport)13 ResolveEngine (org.apache.ivy.core.resolve.ResolveEngine)13 EventManager (org.apache.ivy.core.event.EventManager)12 SortEngine (org.apache.ivy.core.sort.SortEngine)12 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)10 IOException (java.io.IOException)7 ParseException (java.text.ParseException)6 Ivy (org.apache.ivy.Ivy)6 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)6 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)6 URL (java.net.URL)5 HashSet (java.util.HashSet)5 RepositoryCacheManager (org.apache.ivy.core.cache.RepositoryCacheManager)5 BuildException (org.apache.tools.ant.BuildException)5 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)3