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

The following examples show how to use org.apache.ivy.core.module.descriptor.ModuleDescriptor#getExtraInfoContentByTagName() . 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: 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 2
Source File: PomModuleDescriptorBuilder.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public static List<PomDependencyMgt> getPlugins(ModuleDescriptor md) {
    List<PomDependencyMgt> result = new ArrayList<>();
    String plugins = md.getExtraInfoContentByTagName("m:maven.plugins");
    if (plugins == null) {
        return new ArrayList<>();
    }
    for (String plugin : plugins.split("\\|")) {
        String[] parts = plugin.split(EXTRA_INFO_DELIMITER);
        result.add(new PomPluginElement(parts[0], parts[1], parts[2]));
    }

    return result;
}
 
Example 3
Source File: PomModuleDescriptorBuilder.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public static List<PomDependencyMgt> getDependencyManagements(ModuleDescriptor md) {
    List<PomDependencyMgt> result = new ArrayList<>();

    if (md instanceof PomModuleDescriptor) {
        result.addAll(((PomModuleDescriptor) md).getDependencyManagementMap().values());
    } else {
        for (ExtraInfoHolder extraInfoHolder : md.getExtraInfos()) {
            String key = extraInfoHolder.getName();
            if (key.startsWith(DEPENDENCY_MANAGEMENT)) {
                String[] parts = key.split(EXTRA_INFO_DELIMITER);
                if (parts.length != DEPENDENCY_MANAGEMENT_KEY_PARTS_COUNT) {
                    Message.warn("what seem to be a dependency management extra info "
                            + "doesn't match expected pattern: " + key);
                } else {
                    String versionKey = DEPENDENCY_MANAGEMENT + EXTRA_INFO_DELIMITER + parts[1]
                            + EXTRA_INFO_DELIMITER + parts[2] + EXTRA_INFO_DELIMITER
                            + "version";
                    String scopeKey = DEPENDENCY_MANAGEMENT + EXTRA_INFO_DELIMITER + parts[1]
                            + EXTRA_INFO_DELIMITER + parts[2] + EXTRA_INFO_DELIMITER + "scope";

                    String version = md.getExtraInfoContentByTagName(versionKey);
                    String scope = md.getExtraInfoContentByTagName(scopeKey);

                    List<ModuleId> exclusions = getDependencyMgtExclusions(md, parts[1],
                        parts[2]);
                    result.add(new DefaultPomDependencyMgt(parts[1], parts[2], version, scope,
                            exclusions));
                }
            }
        }
    }
    return result;
}