org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor Java Examples

The following examples show how to use org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileSystemResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testRelativePath() throws Exception {
    FileSystemResolver resolver = new FileSystemResolver();
    resolver.setName("test");
    resolver.setSettings(settings);
    assertEquals("test", resolver.getName());

    resolver.addIvyPattern(new File("src/java").getAbsolutePath() + "/../../" + REL_IVY_PATTERN);
    resolver.addArtifactPattern(settings.getBaseDir() + "/src/../test/repositories/1/"
            + "[organisation]/[module]/[type]s/[artifact]-[revision].[type]");

    resolver.setLatestStrategy(new LatestRevisionStrategy());

    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "2.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(
            ModuleRevisionId.newInstance("org1", "mod1.1", "latest.integration"), false), data);
    assertNotNull(rmr);

    assertEquals(mrid, rmr.getId());
    Date pubdate = new GregorianCalendar(2005, 1, 15, 11, 0, 0).getTime();
    assertEquals(pubdate, rmr.getPublicationDate());
}
 
Example #2
Source File: ReflectiveDependencyDescriptorFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public DependencyDescriptor create(DependencyDescriptor source, ModuleRevisionId targetId) {
    if (!(source instanceof DefaultDependencyDescriptor)) {
        throw new IllegalArgumentException("I can only create descriptors out of DefaultDependencyDescriptor");
    }
    DefaultDependencyDescriptor out = new DefaultDependencyDescriptor(moduleDescriptor(source), targetId, source.getDynamicConstraintDependencyRevisionId(), source.isForce(), source.isChanging(), source.isTransitive());

    setProperty(out, "parentId", getProperty(source, "parentId"));
    setProperty(out, "namespace", source.getNamespace());
    ((Map) getProperty(out, "confs")).putAll((Map) getProperty(source, "confs"));

    Map sourceExcludeRules = (Map) getProperty(source, "excludeRules");
    setProperty(out, "excludeRules", sourceExcludeRules == null? null: new LinkedHashMap(sourceExcludeRules));

    Map sourceIncludeRules = (Map) getProperty(source, "includeRules");
    setProperty(out, "includeRules", sourceIncludeRules == null ? null : new LinkedHashMap(sourceIncludeRules));

    Map dependencyArtifacts = (Map) getProperty(source, "dependencyArtifacts");
    setProperty(out, "dependencyArtifacts", dependencyArtifacts == null? null: new LinkedHashMap(dependencyArtifacts));

    setProperty(out, "sourceModule", source.getSourceModule());

    return out;
}
 
Example #3
Source File: BintrayResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testErrorReport() throws Exception {
    BintrayResolver resolver = new BintrayResolver();
    resolver.setSubject("unknown");
    resolver.setRepo("unknown");
    resolver.setName("test");
    resolver.setM2compatible(true);
    resolver.setSettings(settings);
    assertEquals("test", resolver.getName());

    MockMessageLogger mockMessageImpl = new MockMessageLogger();
    IvyContext.getContext().getIvy().getLoggerEngine().setDefaultLogger(mockMessageImpl);

    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org.apache", "commons-fileupload",
        "1.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid,
            false), data);
    assertNull(rmr);

    mockMessageImpl
            .assertLogContains("trying https://dl.bintray.com/unknown/unknown/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.jar");
    mockMessageImpl
            .assertLogContains("tried https://dl.bintray.com/unknown/unknown/org/apache/commons-fileupload/1.0/commons-fileupload-1.0.jar");
}
 
Example #4
Source File: ChainResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testDual() throws Exception {
    ChainResolver chain = new ChainResolver();
    chain.setName("chain");
    chain.setSettings(settings);
    chain.setDual(true);
    MockResolver[] resolvers = new MockResolver[] {
            MockResolver.buildMockResolver(settings, "1", false, null),
            MockResolver.buildMockResolver(settings, "2", true, null),
            MockResolver.buildMockResolver(settings, "3", true, null)};
    for (MockResolver resolver : resolvers) {
        chain.add(resolver);
    }
    assertResolversSizeAndNames(chain, resolvers.length);

    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(
            ModuleRevisionId.newInstance("org", "mod", "rev"), false);
    ResolvedModuleRevision rmr = chain.getDependency(dd, data);
    assertNotNull(rmr);
    assertEquals("2", rmr.getResolver().getName());
    assertEquals("chain", rmr.getArtifactResolver().getName());
}
 
Example #5
Source File: FileSystemResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testLatestTime() throws Exception {
    FileSystemResolver resolver = new FileSystemResolver();
    resolver.setName("test");
    resolver.setSettings(settings);
    assertEquals("test", resolver.getName());

    resolver.addIvyPattern(IVY_PATTERN);
    resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/"
            + "[organisation]/[module]/[type]s/[artifact]-[revision].[type]");

    resolver.setLatestStrategy(new LatestTimeStrategy());

    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "2.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(
            ModuleRevisionId.newInstance("org1", "mod1.1", "latest.integration"), false), data);
    assertNotNull(rmr);

    assertEquals(mrid, rmr.getId());
    Date pubdate = new GregorianCalendar(2005, 1, 15, 11, 0, 0).getTime();
    assertEquals(pubdate, rmr.getPublicationDate());
}
 
Example #6
Source File: ChainResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
/**
 * Test case for IVY-207.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-207">IVY-207</a>
 */
@Test
public void testReturnFirstWithCheckModifiedAndDefaultAndCacheAndRealResolver()
        throws Exception {
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(
            ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), false);

    // 1 ---- we first do a first resolve which puts a default file in cache
    chainToPutDefaultModuleInCache().getDependency(dd, data);

    // 2 ---- now we ask to resolve dependencies with a chain in return first mode, in which the
    // first resolver is not able to find the module, but the second is
    ChainResolver chain = returnFirstChain();
    chain.setCheckmodified(true);

    ResolvedModuleRevision rmr = chain.getDependency(dd, data);
    assertNotNull(rmr);
    assertFalse(rmr.getDescriptor().isDefault());
    assertEquals("2", rmr.getResolver().getName());
}
 
Example #7
Source File: URLResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testLatestFileWithOpaqueURL() throws Exception {
    URLResolver resolver = new URLResolver();
    resolver.setSettings(settings);
    String rootpath = new File("test/repositories/1").getAbsoluteFile().toURI().toURL()
            .toExternalForm();
    resolver.addIvyPattern(rootpath + "/[organisation]/[module]/ivys/ivy-[revision].xml");
    resolver.addArtifactPattern(rootpath
            + "/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
    resolver.setName("test");
    assertEquals("test", resolver.getName());

    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "2.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(
            ModuleRevisionId.newInstance("org1", "mod1.1", "latest.integration"), false), data);
    assertNotNull(rmr);

    assertEquals(mrid, rmr.getId());
    Date pubdate = new GregorianCalendar(2005, 1, 15, 11, 0, 0).getTime();
    assertEquals(pubdate, rmr.getPublicationDate());
}
 
Example #8
Source File: ReflectiveDependencyDescriptorFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public DependencyDescriptor create(DependencyDescriptor source, ModuleRevisionId targetId) {
    if (!(source instanceof DefaultDependencyDescriptor)) {
        throw new IllegalArgumentException("I can only create descriptors out of DefaultDependencyDescriptor");
    }
    DefaultDependencyDescriptor out = new DefaultDependencyDescriptor(moduleDescriptor(source), targetId, source.getDynamicConstraintDependencyRevisionId(), source.isForce(), source.isChanging(), source.isTransitive());

    setProperty(out, "parentId", getProperty(source, "parentId"));
    setProperty(out, "namespace", source.getNamespace());
    ((Map) getProperty(out, "confs")).putAll((Map) getProperty(source, "confs"));

    Map sourceExcludeRules = (Map) getProperty(source, "excludeRules");
    setProperty(out, "excludeRules", sourceExcludeRules == null? null: new LinkedHashMap(sourceExcludeRules));

    Map sourceIncludeRules = (Map) getProperty(source, "includeRules");
    setProperty(out, "includeRules", sourceIncludeRules == null ? null : new LinkedHashMap(sourceIncludeRules));

    Map dependencyArtifacts = (Map) getProperty(source, "dependencyArtifacts");
    setProperty(out, "dependencyArtifacts", dependencyArtifacts == null? null: new LinkedHashMap(dependencyArtifacts));

    setProperty(out, "sourceModule", source.getSourceModule());

    return out;
}
 
Example #9
Source File: ReflectiveDependencyDescriptorFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public DependencyDescriptor create(DependencyDescriptor source, ModuleRevisionId targetId) {
    if (!(source instanceof DefaultDependencyDescriptor)) {
        throw new IllegalArgumentException("I can only create descriptors out of DefaultDependencyDescriptor");
    }
    DefaultDependencyDescriptor out = new DefaultDependencyDescriptor(moduleDescriptor(source), targetId, source.getDynamicConstraintDependencyRevisionId(), source.isForce(), source.isChanging(), source.isTransitive());

    setProperty(out, "parentId", getProperty(source, "parentId"));
    setProperty(out, "namespace", source.getNamespace());
    ((Map) getProperty(out, "confs")).putAll((Map) getProperty(source, "confs"));

    Map sourceExcludeRules = (Map) getProperty(source, "excludeRules");
    setProperty(out, "excludeRules", sourceExcludeRules == null? null: new LinkedHashMap(sourceExcludeRules));

    Map sourceIncludeRules = (Map) getProperty(source, "includeRules");
    setProperty(out, "includeRules", sourceIncludeRules == null ? null : new LinkedHashMap(sourceIncludeRules));

    Map dependencyArtifacts = (Map) getProperty(source, "dependencyArtifacts");
    setProperty(out, "dependencyArtifacts", dependencyArtifacts == null? null: new LinkedHashMap(dependencyArtifacts));

    setProperty(out, "sourceModule", source.getSourceModule());

    return out;
}
 
Example #10
Source File: URLResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testLatestFile() throws Exception {
    URLResolver resolver = new URLResolver();
    resolver.setSettings(settings);
    String rootpath = new File("test/repositories/1").toURI().toURL().toExternalForm();
    resolver.addIvyPattern(rootpath + "[organisation]/[module]/ivys/ivy-[revision].xml");
    resolver.addArtifactPattern(rootpath
            + "[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
    resolver.setName("test");
    assertEquals("test", resolver.getName());

    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "2.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(
            ModuleRevisionId.newInstance("org1", "mod1.1", "latest.integration"), false), data);
    assertNotNull(rmr);

    assertEquals(mrid, rmr.getId());
    Date pubdate = new GregorianCalendar(2005, 1, 15, 11, 0, 0).getTime();
    assertEquals(pubdate, rmr.getPublicationDate());
}
 
Example #11
Source File: FileSystemResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testLatestRevision() throws Exception {
    FileSystemResolver resolver = new FileSystemResolver();
    resolver.setName("test");
    resolver.setSettings(settings);
    assertEquals("test", resolver.getName());

    resolver.addIvyPattern(IVY_PATTERN);
    resolver.addArtifactPattern(settings.getBaseDir() + "/test/repositories/1/"
            + "[organisation]/[module]/[type]s/[artifact]-[revision].[type]");

    resolver.setLatestStrategy(new LatestRevisionStrategy());

    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "2.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(
            ModuleRevisionId.newInstance("org1", "mod1.1", "latest.integration"), false), data);
    assertNotNull(rmr);

    assertEquals(mrid, rmr.getId());
    Date pubdate = new GregorianCalendar(2005, 1, 15, 11, 0, 0).getTime();
    assertEquals(pubdate, rmr.getPublicationDate());
}
 
Example #12
Source File: FileSystemResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that <code>SHA-256</code> algorithm can be used for checksums on resolvers
 *
 * @throws Exception if something goes wrong
 */
@Test
public void testSHA256Checksum() throws Exception {
    final FileSystemResolver resolver = new FileSystemResolver();
    resolver.setName("sha256-checksum-resolver");
    resolver.setSettings(settings);

    resolver.addIvyPattern(settings.getBaseDir()
            + "/test/repositories/checksums/[module]/[revision]/[artifact]-[revision].[ext]");
    resolver.addArtifactPattern(settings.getBaseDir()
            + "/test/repositories/checksums/[module]/[revision]/[artifact]-[revision].[ext]");

    resolver.setChecksums("SHA-256");
    final ModuleRevisionId mrid = ModuleRevisionId.newInstance("test", "allright", "2.0");
    final ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull("Resolved module revision was null for " + mrid, rmr);
    final DownloadReport dr = resolver.download(rmr.getDescriptor().getAllArtifacts(), getDownloadOptions());
    final ArtifactDownloadReport[] successfulDownloadReports = dr.getArtifactsReports(DownloadStatus.SUCCESSFUL);
    assertNotNull("No artifacts were downloaded successfully", successfulDownloadReports);
    assertEquals("Unexpected number of successfully downloaded artifacts", 1, successfulDownloadReports.length);
    final ArtifactDownloadReport successfulDownloadReport = successfulDownloadReports[0];
    final Artifact downloadedArtifact = successfulDownloadReport.getArtifact();
    assertEquals("Unexpected organization of downloaded artifact", "test", downloadedArtifact.getModuleRevisionId().getOrganisation());
    assertEquals("Unexpected module of downloaded artifact", "allright", downloadedArtifact.getModuleRevisionId().getModuleId().getName());
    assertEquals("Unexpected revision of downloaded artifact", "2.0", downloadedArtifact.getModuleRevisionId().getRevision());
}
 
Example #13
Source File: AbstractModuleDescriptorParser.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private void addExtendingConfigurations(String conf, DefaultDependencyDescriptor dd,
        boolean useDefaultMappingToGuessRightOperand) {
    Set<String> configsToAdd = new HashSet<>();
    for (Configuration config : md.getConfigurations()) {
        for (String ext : config.getExtends()) {
            if (conf.equals(ext)) {
                String configName = config.getName();
                configsToAdd.add(configName);
                addExtendingConfigurations(configName, dd,
                        useDefaultMappingToGuessRightOperand);
            }
        }
    }

    parseDepsConfs(configsToAdd.toArray(new String[configsToAdd.size()]),
            dd, useDefaultMappingToGuessRightOperand);
}
 
Example #14
Source File: ChainResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
/**
 * Test case for IVY-389.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-389">IVY-389</a>
 */
@Test
public void testReturnFirstWithDefaultAndCacheAndRealResolver() throws Exception {
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(
            ModuleRevisionId.newInstance("org1", "mod1.1", "1.0"), false);

    // 1 ---- we first do a first resolve which puts a default file in cache
    chainToPutDefaultModuleInCache().getDependency(dd, data);

    // 2 ---- now we ask to resolve dependencies with a chain in return first mode with check
    // modified = false, in which the first resolver is not able to find the module, but the
    // second is
    ChainResolver chain = returnFirstChain();

    ResolvedModuleRevision rmr = chain.getDependency(dd, data);
    assertNotNull(rmr);
    // the module returned should be the default one found in cache since check modified is
    // false
    assertTrue(rmr.getDescriptor().isDefault());
}
 
Example #15
Source File: UpdateSiteAndIbiblioResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testArtifactRef() throws ParseException {

    // Simple Dependency for ibiblio
    ModuleRevisionId mrid1 = ModuleRevisionId.newInstance("log4j", "log4j", "1.2.16");
    ResolvedModuleRevision rmr1 = chain.getDependency(new DefaultDependencyDescriptor(mrid1,
            false), data);

    // Simple Dependency for updatesite
    ModuleRevisionId mrid2 = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE,
        "org.apache.ivy", "2.0.0.final_20090108225011");
    ResolvedModuleRevision rmr2 = chain.getDependency(new DefaultDependencyDescriptor(mrid2,
            false), data);

    assertNotNull(rmr1);
    assertNotNull(rmr2);

    Artifact[] artifacts1 = rmr1.getDescriptor().getArtifacts("default");
    Artifact[] artifacts2 = rmr2.getDescriptor().getArtifacts("default");

    chain.exists(artifacts2[0]);
    chain.exists(artifacts1[0]);
}
 
Example #16
Source File: IvyConfigurationProvider.java    From walkmod-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void addArtifact(String groupId, String artifactId, String version) throws Exception {

		artifacts.add(groupId+":"+artifactId+":"+version);

		String[] dep = null;
		dep = new String[] { groupId, artifactId, version };
		if (md == null) {
			md = DefaultModuleDescriptor.newDefaultInstance(ModuleRevisionId.newInstance(dep[0], dep[1] + "-caller",
					"working"));
		}
		DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, ModuleRevisionId.newInstance(dep[0],
				dep[1], dep[2]), false, false, true);
		md.addDependency(dd);
		ExcludeRule er = new DefaultExcludeRule(new ArtifactId(new ModuleId("org.walkmod", "walkmod-core"),
				PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION),
				ExactPatternMatcher.INSTANCE, null);
		dd.addExcludeRule(null, er);
	}
 
Example #17
Source File: DualResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testResolve() throws Exception {
    DualResolver dual = new DualResolver();
    MockResolver ivyResolver = MockResolver.buildMockResolver(settings, "ivy", true,
        new GregorianCalendar(2005, 1, 20).getTime());
    MockResolver artifactResolver = MockResolver.buildMockResolver(settings, "artifact",
        false, new GregorianCalendar(2005, 1, 20).getTime());
    dual.setIvyResolver(ivyResolver);
    dual.setArtifactResolver(artifactResolver);
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(
            ModuleRevisionId.newInstance("org", "mod", "rev"), false);
    ResolvedModuleRevision rmr = dual.getDependency(dd, data);

    assertNotNull(rmr);
    assertEquals(dual, rmr.getArtifactResolver());
    assertEquals(Collections.<DependencyDescriptor> singletonList(dd), ivyResolver.askedDeps);
    assertTrue(artifactResolver.askedDeps.isEmpty());
}
 
Example #18
Source File: DualResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testResolveFromArtifact() throws Exception {
    DualResolver dual = new DualResolver();
    MockResolver ivyResolver = MockResolver.buildMockResolver(settings, "ivy", false,
        new GregorianCalendar(2005, 1, 20).getTime());
    MockResolver artifactResolver = MockResolver.buildMockResolver(settings, "artifact", true,
        new GregorianCalendar(2005, 1, 20).getTime());
    dual.setIvyResolver(ivyResolver);
    dual.setArtifactResolver(artifactResolver);
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(
            ModuleRevisionId.newInstance("org", "mod", "rev"), false);
    ResolvedModuleRevision rmr = dual.getDependency(dd, data);

    assertNotNull(rmr);
    assertEquals(artifactResolver, rmr.getResolver());
    assertEquals(Collections.<DependencyDescriptor> singletonList(dd), ivyResolver.askedDeps);
    assertEquals(Collections.<DependencyDescriptor> singletonList(dd), artifactResolver.askedDeps);
}
 
Example #19
Source File: DualResolverTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testResolveFail() throws Exception {
    DualResolver dual = new DualResolver();
    MockResolver ivyResolver = MockResolver.buildMockResolver(settings, "ivy", false,
        new GregorianCalendar(2005, 1, 20).getTime());
    MockResolver artifactResolver = MockResolver.buildMockResolver(settings, "artifact",
        false, new GregorianCalendar(2005, 1, 20).getTime());
    dual.setIvyResolver(ivyResolver);
    dual.setArtifactResolver(artifactResolver);
    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(
            ModuleRevisionId.newInstance("org", "mod", "rev"), false);
    ResolvedModuleRevision rmr = dual.getDependency(dd, data);

    assertNull(rmr);
    assertEquals(Collections.<DependencyDescriptor> singletonList(dd), ivyResolver.askedDeps);
    assertEquals(Collections.<DependencyDescriptor> singletonList(dd), artifactResolver.askedDeps);
}
 
Example #20
Source File: MirroredURLResolverTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testFail() throws Exception {
    DependencyResolver resolver = settings.getResolver("fail");
    assertNotNull(resolver);
    assertTrue(resolver instanceof MirroredURLResolver);
    MirroredURLResolver mirrored = (MirroredURLResolver) resolver;

    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(
            ModuleRevisionId.newInstance("commons-lang", "commons-lang", "2.4"), false);
    ResolvedModuleRevision rmr = mirrored.getDependency(dd, data);
    assertNull(rmr);
}
 
Example #21
Source File: P2DescriptorTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testResolvePacked() throws Exception {
    settings.setDefaultResolver("p2-with-packed");

    ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE, "org.junit",
        "4.10.0.v4_10_0_v20120426-0900");

    ResolvedModuleRevision rmr = p2WithPackedResolver.getDependency(
        new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
    assertEquals(mrid, rmr.getId());

    assertEquals(1, rmr.getDescriptor().getAllArtifacts().length);

    DownloadOptions options = new DownloadOptions();
    DownloadReport report = p2WithPackedResolver.download(
        rmr.getDescriptor().getAllArtifacts(), options);
    assertNotNull(report);

    assertEquals(1, report.getArtifactsReports().length);

    Artifact artifact = rmr.getDescriptor().getAllArtifacts()[0];
    ArtifactDownloadReport ar = report.getArtifactReport(artifact);
    assertNotNull(ar);

    assertEquals(artifact, ar.getArtifact());
    assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
    assertNotNull(ar.getUnpackedLocalFile());
}
 
Example #22
Source File: P2DescriptorTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testResolveZipped() throws Exception {
    settings.setDefaultResolver("p2-zipped");

    ModuleRevisionId mrid = ModuleRevisionId.newInstance(BundleInfo.BUNDLE_TYPE,
        "org.apache.ant", "1.8.3.v20120321-1730");

    ResolvedModuleRevision rmr = p2ZippedResolver.getDependency(
        new DefaultDependencyDescriptor(mrid, false), data);
    assertNotNull(rmr);
    assertEquals(mrid, rmr.getId());

    assertEquals(2, rmr.getDescriptor().getAllArtifacts().length);

    DownloadOptions options = new DownloadOptions();
    DownloadReport report = p2ZippedResolver.download(rmr.getDescriptor().getAllArtifacts(),
        options);
    assertNotNull(report);

    assertEquals(2, report.getArtifactsReports().length);

    for (int i = 0; i < 2; i++) {
        Artifact artifact = rmr.getDescriptor().getAllArtifacts()[i];
        ArtifactDownloadReport ar = report.getArtifactReport(artifact);
        assertNotNull(ar);

        assertEquals(artifact, ar.getArtifact());
        assertEquals(DownloadStatus.SUCCESSFUL, ar.getDownloadStatus());
        // only the binary get unpacked
        if (ar.getArtifact().getType().equals("source")) {
            assertNull(ar.getUnpackedLocalFile());
        } else {
            assertNotNull(ar.getUnpackedLocalFile());
        }
    }
}
 
Example #23
Source File: AbstractIvyDependencyDescriptorFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void addExcludes(String configuration, Set<ExcludeRule> excludeRules,
                         DefaultDependencyDescriptor dependencyDescriptor) {
    for (ExcludeRule excludeRule : excludeRules) {
        dependencyDescriptor.addExcludeRule(configuration, excludeRuleConverter.createExcludeRule(configuration,
                excludeRule));
    }
}
 
Example #24
Source File: IvyRepResolverTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * Test case for IVY-625. Must fail if no ivyroot specified.
 *
 * @throws Exception if something goes wrong
 * @see <a href="https://issues.apache.org/jira/browse/IVY-625">IVY-625</a>
 */
@Test
public void testMandatoryRoot() throws Exception {
    expExc.expect(IllegalStateException.class);
    expExc.expectMessage("ivyroot");

    IvyRepResolver resolver = new IvyRepResolver();
    resolver.setName("test");
    resolver.setSettings(settings);

    ModuleRevisionId mrid = ModuleRevisionId.newInstance("apache", "commons-cli", "1.0");

    resolver.getDependency(new DefaultDependencyDescriptor(mrid, false), data);
}
 
Example #25
Source File: AbstractModuleDescriptorParser.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
protected void parseDepsConfs(String confs, DefaultDependencyDescriptor dd,
        boolean useDefaultMappingToGuessRightOperand, boolean evaluateConditions) {
    if (confs == null) {
        return;
    }

    String[] conf = confs.trim().split("\\s*;\\s*");
    parseDepsConfs(conf, dd, useDefaultMappingToGuessRightOperand, evaluateConditions);
}
 
Example #26
Source File: PomModuleDescriptorBuilder.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public void addMappingConfs(DefaultDependencyDescriptor dd, boolean isOptional) {
    if (isOptional) {
        dd.addDependencyConfiguration("optional", "compile(*)");
        dd.addDependencyConfiguration("optional", "provided(*)");
        dd.addDependencyConfiguration("optional", "master(*)");

    } else {
        dd.addDependencyConfiguration("runtime", "compile(*)");
        dd.addDependencyConfiguration("runtime", "runtime(*)");
        dd.addDependencyConfiguration("runtime", "master(*)");
    }
}
 
Example #27
Source File: PomModuleDescriptorBuilder.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public void addMappingConfs(DefaultDependencyDescriptor dd, boolean isOptional) {
    if (isOptional) {
        dd.addDependencyConfiguration("optional", "compile(*)");
        dd.addDependencyConfiguration("optional", "provided(*)");
        dd.addDependencyConfiguration("optional", "runtime(*)");
        dd.addDependencyConfiguration("optional", "master(*)");
    } else {
        dd.addDependencyConfiguration("provided", "compile(*)");
        dd.addDependencyConfiguration("provided", "provided(*)");
        dd.addDependencyConfiguration("provided", "runtime(*)");
        dd.addDependencyConfiguration("provided", "master(*)");
    }
}
 
Example #28
Source File: PomModuleDescriptorBuilder.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public void addMappingConfs(DefaultDependencyDescriptor dd, boolean isOptional) {
    if (isOptional) {
        dd.addDependencyConfiguration("optional", "compile(*)");
        // dd.addDependencyConfiguration("optional", "provided(*)");
        dd.addDependencyConfiguration("optional", "master(*)");

    } else {
        dd.addDependencyConfiguration("compile", "compile(*)");
        // dd.addDependencyConfiguration("compile", "provided(*)");
        dd.addDependencyConfiguration("compile", "master(*)");
        dd.addDependencyConfiguration("runtime", "runtime(*)");
    }
}
 
Example #29
Source File: JarResolverTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimpleFile() throws Exception {
    JarResolver resolver = new JarResolver();
    resolver.setName("jarresolver1");
    resolver.setFile(new File("test/jar-repos/jarrepo1.jar").getAbsolutePath());
    resolver.addIvyPattern("[organisation]/[module]/ivys/ivy-[revision].xml");
    resolver.addArtifactPattern("[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
    resolver.setSettings(settings);

    ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
    ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid,
            false), data);
    assertNotNull(rmr);
}
 
Example #30
Source File: RepositoryManagementEngine.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private void loadModuleRevision(ModuleRevisionId mrid) throws Exception {
    ResolvedModuleRevision module = settings.getResolver(mrid).getDependency(
        new DefaultDependencyDescriptor(mrid, false), newResolveData());
    if (module == null) {
        Message.warn("module not found while listed: " + mrid);
    } else {
        revisions.put(module.getId(), module.getDescriptor());
        getAllRevisions(module.getId()).add(module.getDescriptor());
    }
    Message.progress();
}