Java Code Examples for org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor#addConfiguration()
The following examples show how to use
org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor#addConfiguration() .
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: XmlModuleDescriptorWriterTest.java From ant-ivy with Apache License 2.0 | 6 votes |
/** * Test that the transitive attribute is written for non-transitive configurations. * * <code><conf ... transitive="false" ... /></code> * * @throws Exception if something goes wrong * @see <a href="https://issues.apache.org/jira/browse/IVY-1207">IVY-1207</a> */ @Test public void testTransitiveAttributeForNonTransitiveConfs() throws Exception { // Given a ModuleDescriptor with a non-transitive configuration DefaultModuleDescriptor md = new DefaultModuleDescriptor(new ModuleRevisionId(new ModuleId( "myorg", "myname"), "1.0"), "integration", new Date()); Configuration conf = new Configuration("conf", PUBLIC, "desc", null, false, null); md.addConfiguration(conf); // When the ModuleDescriptor is written XmlModuleDescriptorWriter.write(md, LICENSE, dest); // Then the transitive attribute must be set to false String output = FileUtil.readEntirely(dest); String writtenConf = output.substring(output.indexOf("<configurations>") + 16, output.indexOf("</configurations>")).trim(); assertTrue("Transitive attribute not set to false: " + writtenConf, writtenConf.contains("transitive=\"false\"")); }
Example 2
Source File: XmlModuleDescriptorWriterTest.java From ant-ivy with Apache License 2.0 | 6 votes |
/** * Test that the transitive attribute is not written when the configuration IS transitive. * * This is the default and writing it will only add noise and cause a deviation from the known * behavior (before fixing IVY-1207). * * @throws Exception if something goes wrong * @see <a href="https://issues.apache.org/jira/browse/IVY-1207">IVY-1207</a> */ @Test public void testTransitiveAttributeNotWrittenForTransitiveConfs() throws Exception { // Given a ModuleDescriptor with a transitive configuration DefaultModuleDescriptor md = new DefaultModuleDescriptor(new ModuleRevisionId(new ModuleId( "myorg", "myname"), "1.0"), "integration", new Date()); Configuration conf = new Configuration("conf", PUBLIC, "desc", null, true, null); md.addConfiguration(conf); // When the ModuleDescriptor is written XmlModuleDescriptorWriter.write(md, LICENSE, dest); // Then the transitive attribute must NOT be written String output = FileUtil.readEntirely(dest); String writtenConf = output.substring(output.indexOf("<configurations>") + 16, output.indexOf("</configurations>")).trim(); assertFalse("Transitive attribute set: " + writtenConf, writtenConf.contains("transitive=")); }
Example 3
Source File: DefaultClientModuleMetaDataFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public MutableModuleVersionMetaData createModuleDescriptor(ModuleRevisionId moduleRevisionId, Set<ModuleDependency> dependencies) { DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(moduleRevisionId, "release", null); moduleDescriptor.addConfiguration(new Configuration(Dependency.DEFAULT_CONFIGURATION)); addDependencyDescriptors(moduleDescriptor, dependencies, dependencyDescriptorFactory); moduleDescriptor.addArtifact(Dependency.DEFAULT_CONFIGURATION, new DefaultArtifact(moduleRevisionId, null, moduleRevisionId.getName(), "jar", "jar")); return new ModuleDescriptorAdapter(moduleDescriptor); }
Example 4
Source File: DefaultClientModuleMetaDataFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public MutableModuleVersionMetaData createModuleDescriptor(ModuleRevisionId moduleRevisionId, Set<ModuleDependency> dependencies) { DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(moduleRevisionId, "release", null); moduleDescriptor.addConfiguration(new Configuration(Dependency.DEFAULT_CONFIGURATION)); addDependencyDescriptors(moduleDescriptor, dependencies, dependencyDescriptorFactory); moduleDescriptor.addArtifact(Dependency.DEFAULT_CONFIGURATION, new DefaultArtifact(moduleRevisionId, null, moduleRevisionId.getName(), "jar", "jar")); return new ModuleDescriptorAdapter(moduleDescriptor); }
Example 5
Source File: AbstractOSGiResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
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: BundleInfoAdapter.java From ant-ivy with Apache License 2.0 | 5 votes |
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 7
Source File: DefaultConfigurationsToModuleDescriptorConverter.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public void addConfigurations(DefaultModuleDescriptor moduleDescriptor, Iterable<? extends Configuration> configurations) { for (Configuration configuration : configurations) { moduleDescriptor.addConfiguration(getIvyConfiguration(configuration)); } }
Example 8
Source File: DefaultConfigurationsToModuleDescriptorConverter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void addConfigurations(DefaultModuleDescriptor moduleDescriptor, Iterable<? extends Configuration> configurations) { for (Configuration configuration : configurations) { moduleDescriptor.addConfiguration(getIvyConfiguration(configuration)); } }
Example 9
Source File: IvyDependencyUpdateChecker.java From ant-ivy with Apache License 2.0 | 4 votes |
public void doExecute() throws BuildException { prepareAndCheck(); ModuleDescriptor originalModuleDescriptor = getResolvedReport().getModuleDescriptor(); // clone module descriptor DefaultModuleDescriptor latestModuleDescriptor = new DefaultModuleDescriptor( originalModuleDescriptor.getModuleRevisionId(), originalModuleDescriptor.getStatus(), originalModuleDescriptor.getPublicationDate()); // copy configurations for (Configuration configuration : originalModuleDescriptor.getConfigurations()) { latestModuleDescriptor.addConfiguration(configuration); } // clone dependency and add new one with the requested revisionToCheck for (DependencyDescriptor dependencyDescriptor : originalModuleDescriptor.getDependencies()) { ModuleRevisionId upToDateMrid = ModuleRevisionId.newInstance( dependencyDescriptor.getDependencyRevisionId(), revisionToCheck); latestModuleDescriptor.addDependency(dependencyDescriptor.clone(upToDateMrid)); } // resolve ResolveOptions resolveOptions = new ResolveOptions(); resolveOptions.setDownload(isDownload()); resolveOptions.setLog(getLog()); resolveOptions.setConfs(splitToArray(getConf())); resolveOptions.setCheckIfChanged(checkIfChanged); ResolveReport latestReport; try { latestReport = getIvyInstance().getResolveEngine().resolve(latestModuleDescriptor, resolveOptions); displayDependencyUpdates(getResolvedReport(), latestReport); if (showTransitive) { displayNewDependencyOnLatest(getResolvedReport(), latestReport); displayMissingDependencyOnLatest(getResolvedReport(), latestReport); } } catch (ParseException | IOException e) { throw new BuildException("impossible to resolve dependencies:\n\t" + e, e); } }
Example 10
Source File: BundleInfoAdapter.java From ant-ivy with Apache License 2.0 | 4 votes |
/** * @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; }