Java Code Examples for org.apache.ivy.core.module.descriptor.ModuleDescriptor#getConfigurationsNames()

The following examples show how to use org.apache.ivy.core.module.descriptor.ModuleDescriptor#getConfigurationsNames() . 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: XmlModuleDescriptorWriter.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private static String getConfs(ModuleDescriptor md, Artifact artifact) {
    StringBuilder ret = new StringBuilder();
    for (String conf : md.getConfigurationsNames()) {
        if (Arrays.asList(md.getArtifacts(conf)).contains(artifact)) {
            ret.append(conf).append(",");
        }
    }
    if (ret.length() > 0) {
        ret.setLength(ret.length() - 1);
    }
    return ret.toString();
}
 
Example 2
Source File: BasicResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
protected ResolvedResource findFirstArtifactRef(ModuleDescriptor md, DependencyDescriptor dd,
        ResolveData data) {
    for (String configName : md.getConfigurationsNames()) {
        for (Artifact artifact : md.getArtifacts(configName)) {
            ResolvedResource ret = getArtifactRef(artifact, data.getDate());
            if (ret != null) {
                return ret;
            }
        }
    }
    return null;
}
 
Example 3
Source File: IvyPublishTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testPublishNotAllConfigs() throws IOException, ParseException {
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-multiconf.xml");
    IvyResolve res = new IvyResolve();
    res.setProject(project);
    res.execute();

    publish.setPubrevision("1.2");
    publish.setResolver("1");
    publish.setConf("compile");
    publish.setUpdate(true);
    File art = new File("build/test/publish/resolve-simple-1.2.jar");
    FileUtil.copy(new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"), art, null);
    publish.execute();

    // should have do the ivy delivering
    assertTrue(new File("build/test/publish/ivy-1.2.xml").exists());

    // should have published the files with "1" resolver
    assertTrue(new File("test/repositories/1/apache/resolve-simple/ivys/ivy-1.2.xml").exists());
    assertTrue(new File("test/repositories/1/apache/resolve-simple/jars/resolve-simple-1.2.jar")
            .exists());

    // should have updated published ivy version
    ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(
        new IvySettings(),
        new File("test/repositories/1/apache/resolve-simple/ivys/ivy-1.2.xml").toURI().toURL(),
        false);
    assertEquals("1.2", md.getModuleRevisionId().getRevision());

    // should only contain the default configuration
    String[] configs = md.getConfigurationsNames();
    assertEquals("Number of configurations not correct", 1, configs.length);
    assertEquals("Compile configuration not present", "compile", configs[0]);
}
 
Example 4
Source File: IvyPostResolveTask.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
private String[] getConfsToResolve(ModuleDescriptor reference, String conf, String[] rconfs) {
    Message.debug("calculating configurations to resolve");

    if (reference == null) {
        Message.debug("module not yet resolved, all confs still need to be resolved");
        if (conf == null) {
            return new String[] {"*"};
        }
        return splitToArray(conf);
    }

    if (conf == null) {
        Message.debug("module already resolved, no configuration to resolve");
        return new String[0];
    }

    String[] confs;
    if ("*".equals(conf)) {
        confs = reference.getConfigurationsNames();
    } else {
        confs = splitToArray(conf);
    }

    Set<String> rconfsSet = new HashSet<>();

    // for each resolved configuration, check if the report still exists
    ResolutionCacheManager cache = getSettings().getResolutionCacheManager();
    for (String resolvedConf : rconfs) {
        String resolveId = getResolveId();
        if (resolveId == null) {
            resolveId = ResolveOptions.getDefaultResolveId(reference);
        }
        File report = cache.getConfigurationResolveReportInCache(resolveId, resolvedConf);
        // if the report does not exist any longer, we have to recreate it...
        if (report.exists()) {
            rconfsSet.add(resolvedConf);
        }
    }

    Set<String> confsSet = new HashSet<>(Arrays.asList(confs));
    Message.debug("resolved configurations:   " + rconfsSet);
    Message.debug("asked configurations:      " + confsSet);
    confsSet.removeAll(rconfsSet);
    Message.debug("to resolve configurations: " + confsSet);
    return confsSet.toArray(new String[confsSet.size()]);
}