Java Code Examples for org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor#addDependencyConfiguration()

The following examples show how to use org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor#addDependencyConfiguration() . 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: 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 2
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 3
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 4
Source File: BundleInfoAdapter.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private static void requirementAsDependency(DefaultModuleDescriptor md, BundleInfo bundleInfo,
        Set<String> exportedPkgNames) {
    for (BundleRequirement requirement : bundleInfo.getRequirements()) {
        String type = requirement.getType();
        String name = requirement.getName();

        if (BundleInfo.PACKAGE_TYPE.equals(type) && exportedPkgNames.contains(name)) {
            // don't declare package exported by the current bundle
            continue;
        }

        if (BundleInfo.EXECUTION_ENVIRONMENT_TYPE.equals(type)) {
            // execution environment are handled elsewhere
            continue;
        }

        ModuleRevisionId ddmrid = asMrid(type, name, requirement.getVersion());
        DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(ddmrid, false);

        String conf = CONF_NAME_DEFAULT;
        if (BundleInfo.PACKAGE_TYPE.equals(type)) {
            // declare the configuration for the package
            conf = CONF_USE_PREFIX + name;
            md.addConfiguration(new Configuration(CONF_USE_PREFIX + name, PUBLIC,
                    "Exported package " + name, new String[] {CONF_NAME_DEFAULT}, true, null));
            dd.addDependencyConfiguration(conf, conf);
        }

        if ("optional".equals(requirement.getResolution())) {
            dd.addDependencyConfiguration(CONF_NAME_OPTIONAL, conf);
            dd.addDependencyConfiguration(CONF_NAME_TRANSITIVE_OPTIONAL,
                CONF_NAME_TRANSITIVE_OPTIONAL);
        } else {
            dd.addDependencyConfiguration(CONF_NAME_DEFAULT, conf);
        }

        md.addDependency(dd);
    }

}
 
Example 5
Source File: AbstractOSGiResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private MDResolvedResource buildResolvedCapabilityMd(DependencyDescriptor dd,
        ModuleDescriptor md) {
    String org = dd.getDependencyRevisionId().getOrganisation();
    String name = dd.getDependencyRevisionId().getName();
    String rev = md.getExtraInfoContentByTagName(BundleInfoAdapter.EXTRA_INFO_EXPORT_PREFIX
            + name);
    ModuleRevisionId capabilityRev = ModuleRevisionId.newInstance(org, name, rev,
        Collections.singletonMap(CAPABILITY_EXTRA_ATTR, md.getModuleRevisionId().toString()));

    DefaultModuleDescriptor capabilityMd = new DefaultModuleDescriptor(capabilityRev,
            getSettings().getStatusManager().getDefaultStatus(), new Date());

    String useConf = BundleInfoAdapter.CONF_USE_PREFIX + dd.getDependencyRevisionId().getName();

    capabilityMd.addConfiguration(BundleInfoAdapter.CONF_DEFAULT);
    capabilityMd.addConfiguration(BundleInfoAdapter.CONF_OPTIONAL);
    capabilityMd.addConfiguration(BundleInfoAdapter.CONF_TRANSITIVE_OPTIONAL);
    capabilityMd.addConfiguration(new Configuration(useConf));

    DefaultDependencyDescriptor capabilityDD = new DefaultDependencyDescriptor(
            md.getModuleRevisionId(), false);
    capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_DEFAULT,
        BundleInfoAdapter.CONF_NAME_DEFAULT);
    capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_OPTIONAL,
        BundleInfoAdapter.CONF_NAME_OPTIONAL);
    capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_TRANSITIVE_OPTIONAL,
        BundleInfoAdapter.CONF_NAME_TRANSITIVE_OPTIONAL);
    capabilityDD.addDependencyConfiguration(useConf, useConf);
    capabilityMd.addDependency(capabilityDD);

    MetadataArtifactDownloadReport report = new MetadataArtifactDownloadReport(null);
    report.setDownloadStatus(DownloadStatus.NO);
    report.setSearched(true);
    ResolvedModuleRevision rmr = new ResolvedModuleRevision(this, this, capabilityMd, report);
    return new MDResolvedResource(null, capabilityMd.getRevision(), rmr);
}
 
Example 6
Source File: IvyDependencyConf.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
void addConf(DefaultDependencyDescriptor dd, String masterConf) {
    if (mapped != null) {
        for (String map : splitToArray(mapped)) {
            dd.addDependencyConfiguration(masterConf, map);
        }
    }
    for (IvyDependencyConfMapped m : mappeds) {
        dd.addDependencyConfiguration(masterConf, m.name);
    }
}
 
Example 7
Source File: TestPerformance.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
private void generateModules(int nbModules, int minDependencies, int maxDependencies,
        int minVersions, int maxVersions) throws IOException {
    int nb = 0;
    int curDep = 1;
    int varDeps = maxDependencies - minDependencies;
    int varVersions = maxVersions - minVersions;
    Random r = new Random(System.currentTimeMillis());

    while (nb < nbModules) {
        int deps = minDependencies + r.nextInt(varDeps + 1);
        int versions = minVersions + r.nextInt(varVersions + 1);

        int prevCurDep = curDep;
        for (int ver = 0; ver < versions; ver++) {
            DefaultModuleDescriptor md = new DefaultModuleDescriptor(
                    ModuleRevisionId.newInstance("apache", "mod" + nb, "1." + ver),
                    "integration", new Date());

            curDep = prevCurDep;
            for (int i = 0; i < deps && curDep < nbModules; i++) {
                int d;
                if (i % 2 == 1) {
                    d = nb + i;
                    if (d >= prevCurDep) {
                        d = curDep;
                        curDep++;
                    }
                } else {
                    d = curDep;
                    curDep++;
                }
                DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(
                        md,
                        ModuleRevisionId.newInstance("apache", "mod" + d, "latest.integration"),
                        false, false, true);
                dd.addDependencyConfiguration("default", "default");
                md.addDependency(dd);
            }
            XmlModuleDescriptorWriter.write(md, new File("build/test/perf/mod" + nb + "/ivy-1."
                    + ver + ".xml"));
            FileUtil.copy(new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"),
                new File("build/test/perf/mod" + nb + "/mod" + nb + "-1." + ver + ".jar"), null);
        }
        nb++;
    }
}
 
Example 8
Source File: GradlePomModuleDescriptorParser.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void doParsePom(DescriptorParseContext parserSettings, GradlePomModuleDescriptorBuilder mdBuilder, PomReader pomReader) throws IOException, SAXException {
    if (pomReader.hasParent()) {
        //Is there any other parent properties?

        ModuleVersionIdentifier parentId = DefaultModuleVersionIdentifier.newId(
                pomReader.getParentGroupId(),
                pomReader.getParentArtifactId(),
                pomReader.getParentVersion());
        PomReader parentPomReader = parseOtherPom(parserSettings, parentId);
        pomReader.setPomParent(parentPomReader);
    }
    pomReader.resolveGAV();

    String groupId = pomReader.getGroupId();
    String artifactId = pomReader.getArtifactId();
    String version = pomReader.getVersion();
    mdBuilder.setModuleRevId(groupId, artifactId, version);

    mdBuilder.setHomePage(pomReader.getHomePage());
    mdBuilder.setDescription(pomReader.getDescription());
    mdBuilder.setLicenses(pomReader.getLicenses());

    ModuleRevisionId relocation = pomReader.getRelocation();

    if (relocation != null) {
        if (groupId != null && artifactId != null
                && artifactId.equals(relocation.getName())
                && groupId.equals(relocation.getOrganisation())) {
            LOGGER.error("POM relocation to an other version number is not fully supported in Gradle : {} relocated to {}.",
                    mdBuilder.getModuleDescriptor().getModuleRevisionId(), relocation);
            LOGGER.warn("Please update your dependency to directly use the correct version '{}'.", relocation);
            LOGGER.warn("Resolution will only pick dependencies of the relocated element.  Artifacts and other metadata will be ignored.");
            PomReader relocatedModule = parseOtherPom(parserSettings, DefaultModuleVersionIdentifier.newId(relocation));

            Collection<PomDependencyData> pomDependencyDataList = relocatedModule.getDependencies().values();
            for(PomDependencyData pomDependencyData : pomDependencyDataList) {
                mdBuilder.addDependency(pomDependencyData);
            }

        } else {
            LOGGER.info(mdBuilder.getModuleDescriptor().getModuleRevisionId()
                    + " is relocated to " + relocation
                    + ". Please update your dependencies.");
            LOGGER.debug("Relocated module will be considered as a dependency");
            DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(mdBuilder.getModuleDescriptor(), relocation, true, false, true);
            /* Map all public dependencies */
            Configuration[] m2Confs = GradlePomModuleDescriptorBuilder.MAVEN2_CONFIGURATIONS;
            for (Configuration m2Conf : m2Confs) {
                if (Visibility.PUBLIC.equals(m2Conf.getVisibility())) {
                    dd.addDependencyConfiguration(m2Conf.getName(), m2Conf.getName());
                }
            }
            mdBuilder.addDependency(dd);
        }
    } else {
        overrideDependencyMgtsWithImported(parserSettings, pomReader);

        for (PomDependencyData dependency : pomReader.getDependencies().values()) {
            mdBuilder.addDependency(dependency);
        }
    }
}
 
Example 9
Source File: PomModuleDescriptorBuilder.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public void addMappingConfs(DefaultDependencyDescriptor dd, boolean isOptional) {
    // optional doesn't make sense in the system scope
    dd.addDependencyConfiguration("system", "master(*)");
}
 
Example 10
Source File: PomModuleDescriptorBuilder.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public void addMappingConfs(DefaultDependencyDescriptor dd, boolean isOptional) {
    // optional doesn't make sense in the test scope
    dd.addDependencyConfiguration("test", "runtime(*)");
    dd.addDependencyConfiguration("test", "master(*)");
}
 
Example 11
Source File: SampleIvyRunner.java    From jeka with Apache License 2.0 4 votes vote down vote up
public void retrieve() {
    final IBiblioResolver dependencyResolver = new IBiblioResolver();
    dependencyResolver
    .setRoot("http://i-net1102e-prod:8081/nexus/content/groups/bnppf-secured");
    dependencyResolver.setM2compatible(true);
    dependencyResolver.setUseMavenMetadata(true);
    dependencyResolver.setName("nexus"); // Name is necessary to avoid NPE

    final IvySettings ivySettings = new IvySettings();
    ivySettings.addResolver(dependencyResolver);
    ivySettings.setDefaultResolver("nexus"); // Setting a default resolver
    // is necessary

    final Ivy ivy = Ivy.newInstance(ivySettings);
    ivy.getLoggerEngine().setDefaultLogger(new DefaultMessageLogger(Message.MSG_DEBUG));

    final ModuleRevisionId thisModuleRevisionId = ModuleRevisionId.newInstance("mygroupId",
            "myartifactId-envelope", "myversion");

    final ModuleRevisionId dependee = ModuleRevisionId.newInstance("org.springframework",
            "spring-jdbc", "3.0.0.RELEASE");
    // final ModuleRevisionId dependee =
    // ModuleRevisionId.newInstance("org.hibernate",
    // "hibernate-core", "3.6.10.Final");

    // 1st create an ivy module (this always(!) has a "default"
    // configuration already)
    final DefaultModuleDescriptor moduleDescriptor = DefaultModuleDescriptor
            .newDefaultInstance(thisModuleRevisionId);

    // don't go transitive here, if you want the single artifact
    final boolean transitive = true;
    final DefaultDependencyDescriptor dependencyDescriptor = new DefaultDependencyDescriptor(
            moduleDescriptor, dependee, false, false, transitive);

    // map to master to just get the code jar. See generated ivy module xmls
    // from maven repo
    // on how configurations are mapped into ivy. Or check
    // e.g.
    // http://lightguard-jp.blogspot.de/2009/04/ivy-configurations-when-pulling-from.html
    // dependencyDescriptor.addDependencyConfiguration("default", "master");

    // To get more than 1 artifact i need to declare "compile" and not
    // "master"
    dependencyDescriptor.addDependencyConfiguration("default", "compile");

    moduleDescriptor.addDependency(dependencyDescriptor);

    // now resolve
    final ResolveOptions resolveOptions = new ResolveOptions()
    .setConfs(new String[] { "default" });
    resolveOptions.setTransitive(transitive);
    ResolveReport reportResolver;
    try {
        reportResolver = ivy.resolve(moduleDescriptor, resolveOptions);
    } catch (final Exception e1) {
        throw new RuntimeException(e1);
    }
    if (reportResolver.hasError()) {
        System.out
        .println("*************************************************************************");
        System.out.println(reportResolver);

        throw new RuntimeException(reportResolver.getAllProblemMessages().toString());
    }
    for (final ArtifactDownloadReport artifactDownloadReport : reportResolver
            .getAllArtifactsReports()) {
        System.out.println("*********************************"
                + artifactDownloadReport.getLocalFile());

    }

    final String filePattern = new File("jeka/output/downloaded-libs").getAbsolutePath()
            + "/[artifact](-[classifier]).[ext]";
    final RetrieveOptions retrieveOptions = new RetrieveOptions()
    .setConfs(new String[] { "default" });
    try {
        ivy.retrieve(moduleDescriptor.getModuleRevisionId(), filePattern, retrieveOptions);
    } catch (final IOException e) {
        throw new RuntimeException(e);
    }

}
 
Example 12
Source File: AbstractIvyDependencyDescriptorFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void addDependencyConfiguration(String configuration, ModuleDependency dependency,
                                        DefaultDependencyDescriptor dependencyDescriptor) {
    dependencyDescriptor.addDependencyConfiguration(configuration, dependency.getConfiguration());
}
 
Example 13
Source File: GradlePomModuleDescriptorParser.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void doParsePom(DescriptorParseContext parserSettings, GradlePomModuleDescriptorBuilder mdBuilder, PomReader pomReader) throws IOException, SAXException {
    if (pomReader.hasParent()) {
        //Is there any other parent properties?

        ModuleVersionIdentifier parentId = DefaultModuleVersionIdentifier.newId(
                pomReader.getParentGroupId(),
                pomReader.getParentArtifactId(),
                pomReader.getParentVersion());
        PomReader parentPomReader = parseOtherPom(parserSettings, parentId);
        pomReader.setPomParent(parentPomReader);
    }
    pomReader.resolveGAV();

    String groupId = pomReader.getGroupId();
    String artifactId = pomReader.getArtifactId();
    String version = pomReader.getVersion();
    mdBuilder.setModuleRevId(groupId, artifactId, version);

    mdBuilder.setHomePage(pomReader.getHomePage());
    mdBuilder.setDescription(pomReader.getDescription());
    mdBuilder.setLicenses(pomReader.getLicenses());

    ModuleRevisionId relocation = pomReader.getRelocation();

    if (relocation != null) {
        if (groupId != null && artifactId != null
                && artifactId.equals(relocation.getName())
                && groupId.equals(relocation.getOrganisation())) {
            LOGGER.error("POM relocation to an other version number is not fully supported in Gradle : {} relocated to {}.",
                    mdBuilder.getModuleDescriptor().getModuleRevisionId(), relocation);
            LOGGER.warn("Please update your dependency to directly use the correct version '{}'.", relocation);
            LOGGER.warn("Resolution will only pick dependencies of the relocated element.  Artifacts and other metadata will be ignored.");
            PomReader relocatedModule = parseOtherPom(parserSettings, DefaultModuleVersionIdentifier.newId(relocation));

            Collection<PomDependencyData> pomDependencyDataList = relocatedModule.getDependencies().values();
            for(PomDependencyData pomDependencyData : pomDependencyDataList) {
                mdBuilder.addDependency(pomDependencyData);
            }

        } else {
            LOGGER.info(mdBuilder.getModuleDescriptor().getModuleRevisionId()
                    + " is relocated to " + relocation
                    + ". Please update your dependencies.");
            LOGGER.debug("Relocated module will be considered as a dependency");
            DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(mdBuilder.getModuleDescriptor(), relocation, true, false, true);
            /* Map all public dependencies */
            Configuration[] m2Confs = GradlePomModuleDescriptorBuilder.MAVEN2_CONFIGURATIONS;
            for (Configuration m2Conf : m2Confs) {
                if (Visibility.PUBLIC.equals(m2Conf.getVisibility())) {
                    dd.addDependencyConfiguration(m2Conf.getName(), m2Conf.getName());
                }
            }
            mdBuilder.addDependency(dd);
        }
    } else {
        overrideDependencyMgtsWithImported(parserSettings, pomReader);

        for (PomDependencyData dependency : pomReader.getDependencies().values()) {
            mdBuilder.addDependency(dependency);
        }
    }
}
 
Example 14
Source File: AbstractIvyDependencyDescriptorFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void addDependencyConfiguration(String configuration, ModuleDependency dependency,
                                        DefaultDependencyDescriptor dependencyDescriptor) {
    dependencyDescriptor.addDependencyConfiguration(configuration, dependency.getConfiguration());
}
 
Example 15
Source File: GradlePomModuleDescriptorParser.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void doParsePom(DescriptorParseContext parserSettings, GradlePomModuleDescriptorBuilder mdBuilder, PomReader pomReader) throws IOException, SAXException {
    if (pomReader.hasParent()) {
        //Is there any other parent properties?

        ModuleVersionIdentifier parentId = DefaultModuleVersionIdentifier.newId(
                pomReader.getParentGroupId(),
                pomReader.getParentArtifactId(),
                pomReader.getParentVersion());
        PomReader parentPomReader = parseOtherPom(parserSettings, parentId);
        pomReader.setPomParent(parentPomReader);
    }
    pomReader.resolveGAV();

    String groupId = pomReader.getGroupId();
    String artifactId = pomReader.getArtifactId();
    String version = pomReader.getVersion();
    mdBuilder.setModuleRevId(groupId, artifactId, version);

    mdBuilder.setHomePage(pomReader.getHomePage());
    mdBuilder.setDescription(pomReader.getDescription());
    mdBuilder.setLicenses(pomReader.getLicenses());

    ModuleRevisionId relocation = pomReader.getRelocation();

    if (relocation != null) {
        if (groupId != null && artifactId != null
                && artifactId.equals(relocation.getName())
                && groupId.equals(relocation.getOrganisation())) {
            LOGGER.error("POM relocation to an other version number is not fully supported in Gradle : {} relocated to {}.",
                    mdBuilder.getModuleDescriptor().getModuleRevisionId(), relocation);
            LOGGER.warn("Please update your dependency to directly use the correct version '{}'.", relocation);
            LOGGER.warn("Resolution will only pick dependencies of the relocated element.  Artifacts and other metadata will be ignored.");
            PomReader relocatedModule = parseOtherPom(parserSettings, DefaultModuleVersionIdentifier.newId(relocation));

            Collection<PomDependencyData> pomDependencyDataList = relocatedModule.getDependencies().values();
            for(PomDependencyData pomDependencyData : pomDependencyDataList) {
                mdBuilder.addDependency(pomDependencyData);
            }

        } else {
            LOGGER.info(mdBuilder.getModuleDescriptor().getModuleRevisionId()
                    + " is relocated to " + relocation
                    + ". Please update your dependencies.");
            LOGGER.debug("Relocated module will be considered as a dependency");
            DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(mdBuilder.getModuleDescriptor(), relocation, true, false, true);
            /* Map all public dependencies */
            Configuration[] m2Confs = GradlePomModuleDescriptorBuilder.MAVEN2_CONFIGURATIONS;
            for (Configuration m2Conf : m2Confs) {
                if (Visibility.PUBLIC.equals(m2Conf.getVisibility())) {
                    dd.addDependencyConfiguration(m2Conf.getName(), m2Conf.getName());
                }
            }
            mdBuilder.addDependency(dd);
        }
    } else {
        overrideDependencyMgtsWithImported(parserSettings, pomReader);

        for (PomDependencyData dependency : pomReader.getDependencies().values()) {
            mdBuilder.addDependency(dependency);
        }
    }
}
 
Example 16
Source File: AbstractIvyDependencyDescriptorFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void addDependencyConfiguration(String configuration, ModuleDependency dependency,
                                        DefaultDependencyDescriptor dependencyDescriptor) {
    dependencyDescriptor.addDependencyConfiguration(configuration, dependency.getConfiguration());
}
 
Example 17
Source File: GradlePomModuleDescriptorParser.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void doParsePom(DescriptorParseContext parserSettings, GradlePomModuleDescriptorBuilder mdBuilder, PomReader pomReader) throws IOException, SAXException {
    if (pomReader.hasParent()) {
        //Is there any other parent properties?

        ModuleVersionIdentifier parentId = DefaultModuleVersionIdentifier.newId(
                pomReader.getParentGroupId(),
                pomReader.getParentArtifactId(),
                pomReader.getParentVersion());
        PomReader parentPomReader = parseOtherPom(parserSettings, parentId);
        pomReader.setPomParent(parentPomReader);
    }
    pomReader.resolveGAV();

    String groupId = pomReader.getGroupId();
    String artifactId = pomReader.getArtifactId();
    String version = pomReader.getVersion();
    mdBuilder.setModuleRevId(groupId, artifactId, version);

    mdBuilder.setHomePage(pomReader.getHomePage());
    mdBuilder.setDescription(pomReader.getDescription());
    mdBuilder.setLicenses(pomReader.getLicenses());

    ModuleRevisionId relocation = pomReader.getRelocation();

    if (relocation != null) {
        if (groupId != null && artifactId != null
                && artifactId.equals(relocation.getName())
                && groupId.equals(relocation.getOrganisation())) {
            LOGGER.error("POM relocation to an other version number is not fully supported in Gradle : {} relocated to {}.",
                    mdBuilder.getModuleDescriptor().getModuleRevisionId(), relocation);
            LOGGER.warn("Please update your dependency to directly use the correct version '{}'.", relocation);
            LOGGER.warn("Resolution will only pick dependencies of the relocated element.  Artifacts and other metadata will be ignored.");
            PomReader relocatedModule = parseOtherPom(parserSettings, DefaultModuleVersionIdentifier.newId(relocation));

            Collection<PomDependencyData> pomDependencyDataList = relocatedModule.getDependencies().values();
            for(PomDependencyData pomDependencyData : pomDependencyDataList) {
                mdBuilder.addDependency(pomDependencyData);
            }

        } else {
            LOGGER.info(mdBuilder.getModuleDescriptor().getModuleRevisionId()
                    + " is relocated to " + relocation
                    + ". Please update your dependencies.");
            LOGGER.debug("Relocated module will be considered as a dependency");
            DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(mdBuilder.getModuleDescriptor(), relocation, true, false, true);
            /* Map all public dependencies */
            Configuration[] m2Confs = GradlePomModuleDescriptorBuilder.MAVEN2_CONFIGURATIONS;
            for (Configuration m2Conf : m2Confs) {
                if (Visibility.PUBLIC.equals(m2Conf.getVisibility())) {
                    dd.addDependencyConfiguration(m2Conf.getName(), m2Conf.getName());
                }
            }
            mdBuilder.addDependency(dd);
        }
    } else {
        overrideDependencyMgtsWithImported(parserSettings, pomReader);

        for (PomDependencyData dependency : pomReader.getDependencies().values()) {
            mdBuilder.addDependency(dependency);
        }
    }
}
 
Example 18
Source File: AbstractIvyDependencyDescriptorFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void addDependencyConfiguration(String configuration, ModuleDependency dependency,
                                        DefaultDependencyDescriptor dependencyDescriptor) {
    dependencyDescriptor.addDependencyConfiguration(configuration, dependency.getConfiguration());
}