Search in sources :

Example 6 with ArtifactId

use of org.apache.ivy.core.module.id.ArtifactId in project gradle by gradle.

the class IvyModuleDescriptorConverter method forIvyExclude.

private Exclude forIvyExclude(org.apache.ivy.core.module.descriptor.ExcludeRule excludeRule) {
    ArtifactId id = excludeRule.getId();
    IvyArtifactName artifactExclusion = artifactForIvyExclude(id);
    return new DefaultExclude(moduleIdentifierFactory.module(id.getModuleId().getOrganisation(), id.getModuleId().getName()), artifactExclusion, excludeRule.getConfigurations(), excludeRule.getMatcher().getName());
}
Also used : ArtifactId(org.apache.ivy.core.module.id.ArtifactId) DefaultExclude(org.gradle.internal.component.external.descriptor.DefaultExclude) DefaultIvyArtifactName(org.gradle.internal.component.model.DefaultIvyArtifactName) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName)

Example 7 with ArtifactId

use of org.apache.ivy.core.module.id.ArtifactId in project walkmod-core by walkmod.

the class IvyConfigurationProvider method addArtifact.

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);
}
Also used : DefaultExcludeRule(org.apache.ivy.core.module.descriptor.DefaultExcludeRule) ModuleId(org.apache.ivy.core.module.id.ModuleId) ArtifactId(org.apache.ivy.core.module.id.ArtifactId) DefaultDependencyDescriptor(org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor) ExcludeRule(org.apache.ivy.core.module.descriptor.ExcludeRule) DefaultExcludeRule(org.apache.ivy.core.module.descriptor.DefaultExcludeRule)

Example 8 with ArtifactId

use of org.apache.ivy.core.module.id.ArtifactId in project ant-ivy by apache.

the class BundleInfoAdapter method toModuleDescriptor.

/**
 * @param parser ModuleDescriptorParser
 * @param baseUri
 *            uri to help build the absolute url if the bundle info has a relative uri.
 * @param bundle BundleInfo
 * @param manifest Manifest
 * @param profileProvider ExecutionEnvironmentProfileProvider
 * @return DefaultModuleDescriptor ditto
 * @throws ProfileNotFoundException if descriptor is not found
 */
public static DefaultModuleDescriptor toModuleDescriptor(ModuleDescriptorParser parser, URI baseUri, BundleInfo bundle, Manifest manifest, ExecutionEnvironmentProfileProvider profileProvider) throws ProfileNotFoundException {
    DefaultModuleDescriptor md = new DefaultModuleDescriptor(parser, null);
    md.addExtraAttributeNamespace("o", Ivy.getIvyHomeURL() + "osgi");
    ModuleRevisionId mrid = asMrid(BundleInfo.BUNDLE_TYPE, bundle.getSymbolicName(), bundle.getVersion());
    md.setResolvedPublicationDate(new Date());
    md.setModuleRevisionId(mrid);
    md.addConfiguration(CONF_DEFAULT);
    md.addConfiguration(CONF_OPTIONAL);
    md.addConfiguration(CONF_TRANSITIVE_OPTIONAL);
    Set<String> exportedPkgNames = new HashSet<>(bundle.getExports().size());
    for (ExportPackage exportPackage : bundle.getExports()) {
        md.getExtraInfos().add(new ExtraInfoHolder(EXTRA_INFO_EXPORT_PREFIX + exportPackage.getName(), exportPackage.getVersion().toString()));
        exportedPkgNames.add(exportPackage.getName());
        String[] confDependencies = new String[exportPackage.getUses().size() + 1];
        int i = 0;
        for (String use : exportPackage.getUses()) {
            confDependencies[i++] = CONF_USE_PREFIX + use;
        }
        confDependencies[i] = CONF_NAME_DEFAULT;
        md.addConfiguration(new Configuration(CONF_USE_PREFIX + exportPackage.getName(), PUBLIC, "Exported package " + exportPackage.getName(), confDependencies, true, null));
    }
    requirementAsDependency(md, bundle, exportedPkgNames);
    if (baseUri != null) {
        for (BundleArtifact bundleArtifact : bundle.getArtifacts()) {
            String type = "jar";
            String ext = "jar";
            String packaging = null;
            if (bundle.hasInnerClasspath() && !bundleArtifact.isSource()) {
                packaging = "bundle";
            }
            if ("packed".equals(bundleArtifact.getFormat())) {
                ext = "jar.pack.gz";
                if (packaging != null) {
                    packaging += ",pack200";
                } else {
                    packaging = "pack200";
                }
            }
            if (bundleArtifact.isSource()) {
                type = "source";
            }
            URI uri = bundleArtifact.getUri();
            if (uri != null) {
                DefaultArtifact artifact = buildArtifact(mrid, baseUri, uri, type, ext, packaging);
                md.addArtifact(CONF_NAME_DEFAULT, artifact);
            }
        }
    }
    if (profileProvider != null) {
        for (String env : bundle.getExecutionEnvironments()) {
            ExecutionEnvironmentProfile profile = profileProvider.getProfile(env);
            if (profile == null) {
                throw new ProfileNotFoundException("Execution environment profile " + env + " not found");
            }
            for (String pkg : profile.getPkgNames()) {
                ArtifactId id = new ArtifactId(ModuleId.newInstance(BundleInfo.PACKAGE_TYPE, pkg), PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION);
                DefaultExcludeRule rule = new DefaultExcludeRule(id, ExactOrRegexpPatternMatcher.INSTANCE, null);
                for (String conf : md.getConfigurationsNames()) {
                    rule.addConfiguration(conf);
                }
                md.addExcludeRule(rule);
            }
        }
    }
    if (manifest != null) {
        for (Map.Entry<Object, Object> entries : manifest.getMainAttributes().entrySet()) {
            md.addExtraInfo(new ExtraInfoHolder(entries.getKey().toString(), entries.getValue().toString()));
        }
    }
    return md;
}
Also used : Configuration(org.apache.ivy.core.module.descriptor.Configuration) ArtifactId(org.apache.ivy.core.module.id.ArtifactId) ExtraInfoHolder(org.apache.ivy.core.module.descriptor.ExtraInfoHolder) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) URI(java.net.URI) Date(java.util.Date) DefaultExcludeRule(org.apache.ivy.core.module.descriptor.DefaultExcludeRule) DefaultModuleDescriptor(org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor) HashMap(java.util.HashMap) Map(java.util.Map) DefaultArtifact(org.apache.ivy.core.module.descriptor.DefaultArtifact) HashSet(java.util.HashSet)

Example 9 with ArtifactId

use of org.apache.ivy.core.module.id.ArtifactId in project ant-ivy by apache.

the class IvyExclude method asRule.

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

Aggregations

ArtifactId (org.apache.ivy.core.module.id.ArtifactId)9 DefaultExcludeRule (org.apache.ivy.core.module.descriptor.DefaultExcludeRule)5 ModuleId (org.apache.ivy.core.module.id.ModuleId)5 HashMap (java.util.HashMap)3 DefaultArtifact (org.apache.ivy.core.module.descriptor.DefaultArtifact)3 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)3 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)3 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 Artifact (org.apache.ivy.core.module.descriptor.Artifact)2 DefaultIncludeRule (org.apache.ivy.core.module.descriptor.DefaultIncludeRule)2 URI (java.net.URI)1 Date (java.util.Date)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Configuration (org.apache.ivy.core.module.descriptor.Configuration)1 DefaultDependencyArtifactDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyArtifactDescriptor)1 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)1 DependencyArtifactDescriptor (org.apache.ivy.core.module.descriptor.DependencyArtifactDescriptor)1 DependencyDescriptor (org.apache.ivy.core.module.descriptor.DependencyDescriptor)1