Search in sources :

Example 1 with DefaultIncludeRule

use of org.apache.ivy.core.module.descriptor.DefaultIncludeRule in project ant-ivy by apache.

the class IvyDependencyInclude method asRule.

DefaultIncludeRule asRule(IvySettings settings) {
    String matcherName = matcher == null ? PatternMatcher.EXACT : matcher;
    String namePattern = name == null ? PatternMatcher.ANY_EXPRESSION : name;
    String typePattern = type == null ? PatternMatcher.ANY_EXPRESSION : type;
    String extPattern = ext == null ? typePattern : ext;
    ArtifactId aid = new ArtifactId(new ModuleId(PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION), namePattern, typePattern, extPattern);
    return new DefaultIncludeRule(aid, settings.getMatcher(matcherName), null);
}
Also used : ModuleId(org.apache.ivy.core.module.id.ModuleId) ArtifactId(org.apache.ivy.core.module.id.ArtifactId) DefaultIncludeRule(org.apache.ivy.core.module.descriptor.DefaultIncludeRule)

Example 2 with DefaultIncludeRule

use of org.apache.ivy.core.module.descriptor.DefaultIncludeRule in project ant-ivy by apache.

the class BintrayResolverTest method testBintrayArtifacts.

@Test
public void testBintrayArtifacts() throws Exception {
    BintrayResolver resolver = new BintrayResolver();
    resolver.setName("test");
    resolver.setSettings(settings);
    assertEquals("test", resolver.getName());
    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache.ant", "ant-antunit", "1.2");
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(mrid, false);
    dd.addIncludeRule("default", new DefaultIncludeRule(new ArtifactId(mrid.getModuleId(), "ant-antunit", "javadoc", "jar"), ExactPatternMatcher.INSTANCE, null));
    dd.addIncludeRule("default", new DefaultIncludeRule(new ArtifactId(mrid.getModuleId(), "ant-antunit", "sources", "jar"), ExactPatternMatcher.INSTANCE, null));
    ResolvedModuleRevision rmr = resolver.getDependency(dd, data);
    assertNotNull(rmr);
    assertEquals(mrid, rmr.getId());
    DefaultArtifact profiler = new DefaultArtifact(mrid, rmr.getPublicationDate(), "ant-antunit", "javadoc", "jar");
    DefaultArtifact trace = new DefaultArtifact(mrid, rmr.getPublicationDate(), "ant-antunit", "sources", "jar");
    DownloadReport report = resolver.download(new Artifact[] { profiler, trace }, downloadOptions());
    assertNotNull(report);
    assertEquals(2, report.getArtifactsReports().length);
    ArtifactDownloadReport ar = report.getArtifactReport(profiler);
    assertNotNull(ar);
    assertEquals(profiler, ar.getArtifact());
    assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
    ar = report.getArtifactReport(trace);
    assertNotNull(ar);
    assertEquals(trace, ar.getArtifact());
    assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
    // test to ask to download again, should use cache
    report = resolver.download(new Artifact[] { profiler, trace }, downloadOptions());
    assertNotNull(report);
    assertEquals(2, report.getArtifactsReports().length);
    ar = report.getArtifactReport(profiler);
    assertNotNull(ar);
    assertEquals(profiler, ar.getArtifact());
    assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
    ar = report.getArtifactReport(trace);
    assertNotNull(ar);
    assertEquals(trace, ar.getArtifact());
    assertEquals(DownloadStatus.NO, ar.getDownloadStatus());
}
Also used : DownloadReport(org.apache.ivy.core.report.DownloadReport) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) ArtifactId(org.apache.ivy.core.module.id.ArtifactId) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) ResolvedModuleRevision(org.apache.ivy.core.resolve.ResolvedModuleRevision) ArtifactDownloadReport(org.apache.ivy.core.report.ArtifactDownloadReport) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) DefaultIncludeRule(org.apache.ivy.core.module.descriptor.DefaultIncludeRule) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Artifact(org.apache.ivy.core.module.descriptor.Artifact) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) Test(org.junit.Test)

Example 3 with DefaultIncludeRule

use of org.apache.ivy.core.module.descriptor.DefaultIncludeRule in project ant-ivy by apache.

the class IvyDependency method asDependencyDescriptor.

DependencyDescriptor asDependencyDescriptor(ModuleDescriptor md, String masterConf, IvySettings settings) {
    if (org == null) {
        throw new BuildException("'org' is required on ");
    }
    if (name == null) {
        throw new BuildException("'name' is required when using inline mode");
    }
    ModuleRevisionId mrid = ModuleRevisionId.newInstance(org, name, branch, rev);
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, mrid, force, changing, transitive);
    if (conf != null) {
        dd.addDependencyConfiguration(masterConf, conf);
    } else {
        dd.addDependencyConfiguration(masterConf, "*");
    }
    for (IvyDependencyConf c : confs) {
        c.addConf(dd, masterConf);
    }
    for (IvyDependencyArtifact artifact : artifacts) {
        artifact.addArtifact(dd, masterConf);
    }
    for (IvyDependencyExclude exclude : excludes) {
        DefaultExcludeRule rule = exclude.asRule(settings);
        dd.addExcludeRule(masterConf, rule);
    }
    for (IvyDependencyInclude include : includes) {
        DefaultIncludeRule rule = include.asRule(settings);
        dd.addIncludeRule(masterConf, rule);
    }
    return dd;
}
Also used : DefaultExcludeRule(org.apache.ivy.core.module.descriptor.DefaultExcludeRule) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) BuildException(org.apache.tools.ant.BuildException) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) DefaultIncludeRule(org.apache.ivy.core.module.descriptor.DefaultIncludeRule)

Aggregations

DefaultIncludeRule (org.apache.ivy.core.module.descriptor.DefaultIncludeRule)3 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)2 ArtifactId (org.apache.ivy.core.module.id.ArtifactId)2 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)2 Artifact (org.apache.ivy.core.module.descriptor.Artifact)1 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)1 DefaultExcludeRule (org.apache.ivy.core.module.descriptor.DefaultExcludeRule)1 ModuleId (org.apache.ivy.core.module.id.ModuleId)1 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)1 DownloadReport (org.apache.ivy.core.report.DownloadReport)1 ResolvedModuleRevision (org.apache.ivy.core.resolve.ResolvedModuleRevision)1 BuildException (org.apache.tools.ant.BuildException)1 Test (org.junit.Test)1