本文整理汇总了Java中org.apache.ivy.core.module.descriptor.ModuleDescriptor.getConfigurations方法的典型用法代码示例。如果您正苦于以下问题:Java ModuleDescriptor.getConfigurations方法的具体用法?Java ModuleDescriptor.getConfigurations怎么用?Java ModuleDescriptor.getConfigurations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ivy.core.module.descriptor.ModuleDescriptor
的用法示例。
在下文中一共展示了ModuleDescriptor.getConfigurations方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUpdateWithExcludeConfigurations1
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
@Test
public void testUpdateWithExcludeConfigurations1() throws Exception {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/"
+ "test-update-excludedconfs1.xml").toURI().toURL();
XmlModuleDescriptorUpdater.update(settingsUrl, buffer,
getUpdateOptions("release", "mynewrev").setConfsToExclude(new String[] {"myconf2"}));
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(),
new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0,
false), true);
// test the number of configurations
Configuration[] configs = updatedMd.getConfigurations();
assertNotNull("Configurations shouldn't be null", configs);
assertEquals("Number of configurations incorrect", 3, configs.length);
// test that the correct configuration has been removed
assertNull("myconf2 hasn't been removed", updatedMd.getConfiguration("myconf2"));
// test that the other configurations aren't removed
assertNotNull("myconf1 has been removed", updatedMd.getConfiguration("myconf1"));
assertNotNull("myconf3 has been removed", updatedMd.getConfiguration("myconf3"));
assertNotNull("myconf4 has been removed", updatedMd.getConfiguration("myconf4"));
}
示例2: testMergedUpdateWithInclude
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
/**
* Test case for IVY-1315.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1315">IVY-1315</a>
*/
@Test
public void testMergedUpdateWithInclude() throws Exception {
URL url = XmlModuleUpdaterTest.class.getResource("test-update-excludedconfs6.xml");
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor md = parser.parseDescriptor(new IvySettings(), url, true);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
XmlModuleDescriptorUpdater.update(url, buffer,
getUpdateOptions("release", "mynewrev")
.setMerge(true)
.setMergedDescriptor(md));
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(),
new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0,
false), true);
Configuration[] configurations = updatedMd.getConfigurations();
assertNotNull("Configurations shouldn't be null", configurations);
assertEquals("Number of configurations is incorrect", 6, configurations.length);
String updatedXml = buffer.toString();
System.out.println(updatedXml);
assertTrue(updatedXml.contains("dependencies defaultconf=\"conf1->default\""));
}
示例3: extractConfigurations
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
public static List<Configuration> extractConfigurations(ModuleDescriptor ivyDescriptor) {
List<Configuration> result = Lists.newArrayListWithCapacity(ivyDescriptor.getConfigurations().length);
for (org.apache.ivy.core.module.descriptor.Configuration ivyConfiguration : ivyDescriptor.getConfigurations()) {
addConfiguration(result, ivyConfiguration);
}
return result;
}
示例4: checkDescriptor
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
protected void checkDescriptor(ComponentMetaData metaData) {
ModuleDescriptor moduleDescriptor = metaData.getDescriptor();
for (Configuration configuration : moduleDescriptor.getConfigurations()) {
for (String parent : configuration.getExtends()) {
if (moduleDescriptor.getConfiguration(parent) == null) {
throw new ModuleVersionResolveException(metaData.getId(), String.format("Configuration '%s' extends unknown configuration '%s' in module descriptor for %%s.", configuration.getName(), parent));
}
}
}
}
示例5: printConfigurations
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
private static void printConfigurations(ModuleDescriptor md, PrintWriter out) {
Configuration[] confs = md.getConfigurations();
if (confs.length > 0) {
out.println("\t<configurations>");
for (Configuration conf : confs) {
out.print("\t\t");
printConfiguration(conf, out);
}
out.println("\t</configurations>");
}
}
示例6: mergeConfigurations
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
/**
* Describes how to merge configurations elements
*
* @param parent
* the module descriptor
*/
protected void mergeConfigurations(ModuleDescriptor parent) {
ModuleRevisionId sourceMrid = parent.getModuleRevisionId();
for (Configuration configuration : parent.getConfigurations()) {
Message.debug("Merging configuration with: " + configuration.getName());
// copy configuration from parent descriptor
getMd().addConfiguration(new Configuration(configuration, sourceMrid));
}
if (parent instanceof DefaultModuleDescriptor) {
setDefaultConfMapping(((DefaultModuleDescriptor) parent).getDefaultConfMapping());
setDefaultConf(((DefaultModuleDescriptor) parent).getDefaultConf());
getMd().setMappingOverride(((DefaultModuleDescriptor) parent).isMappingOverride());
}
}
示例7: flushMergedElementsBefore
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
/**
* <p>
* If publishing in merge mode, guarantee that any merged elements appearing before
* <code>moduleElement</code> have been written. This method should be called <i>before</i>
* we write the start tag of <code>moduleElement</code>. This covers cases where merged
* elements like "configurations" and "dependencies" appear in the parent descriptor, but
* are completely missing in the child descriptor.
* </p>
*
* <p>
* For example, if "moduleElement" is "dependencies", guarantees that "configurations" has
* been written. If <code>moduleElement</code> is <code>null</code>, then all missing merged
* elements will be flushed.
* </p>
*
* @param moduleElement
* a descriptor element name, for example "configurations" or "info"
*/
private void flushMergedElementsBefore(String moduleElement) {
if (options.isMerge() && context.size() == 1 && "ivy-module".equals(context.peek())
&& !(mergedConfigurations && mergedDependencies)) {
// calculate the position of the element in ivy-module
int position = (moduleElement == null) ? MODULE_ELEMENTS.size()
: MODULE_ELEMENTS.indexOf(moduleElement);
ModuleDescriptor merged = options.getMergedDescriptor();
// see if we should write <configurations>
if (!mergedConfigurations && position > CONFIGURATIONS_POSITION
&& merged.getConfigurations().length > 0) {
mergedConfigurations = true;
writeInheritedItems(merged, merged.getConfigurations(),
ConfigurationPrinter.INSTANCE, "configurations", true);
}
// see if we should write <dependencies>
if (!mergedDependencies && position > DEPENDENCIES_POSITION
&& merged.getDependencies().length > 0) {
mergedDependencies = true;
writeInheritedItems(merged, merged.getDependencies(),
DependencyPrinter.INSTANCE, "dependencies", true);
}
}
}
示例8: testExtendsAbsoluteLocation
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
/**
* Tests that when the <code>location</code> attribute of the <code>extends</code> element of
* a module descriptor file, includes an {@link File#isAbsolute() absolute path} with
* characters that {@link java.net.URI} considers as encoded characters (for example,
* <code>%2F</code>) then the module descriptor and the location of the parent descriptor
* are resolved and parsed correctly.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1562">IVY-1562</a>
*/
@Test
public void testExtendsAbsoluteLocation() throws Exception {
final URL ivyXML = this.getClass().getResource("foo%2Fbar/hello/test-ivy-extends-absolute.xml");
assertNotNull("Ivy xml file is missing", ivyXML);
final URL parentIvyXML = this.getClass().getResource("foo%2Fbar/parent-ivy.xml");
assertNotNull("Parent Ivy xml file is missing", parentIvyXML);
// the ivy xml references a parent ivy xml via extends "location" and expects the parent
// ivy to be present at a location under java.io.tmpdir, so we copy over the parent ivy
// file over there
final Path targetDir = Paths.get(System.getProperty("java.io.tmpdir"), "foo%2Fbar");
Files.createDirectories(targetDir);
final Path parentIvyXMLPath = Paths.get(targetDir.toString(), "parent-ivy.xml");
try (final InputStream is = parentIvyXML.openStream()) {
Files.copy(is, parentIvyXMLPath, StandardCopyOption.REPLACE_EXISTING);
}
assertTrue("Parent ivy xml file wasn't copied", Files.isRegularFile(parentIvyXMLPath));
try {
// now start parsing the Ivy xml
final ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings, ivyXML, true);
assertNotNull("Parsed module descriptor is null", md);
assertEquals("Unexpected org for the parsed module descriptor", "myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("Unexpected module name for the parsed module descriptor", "mymodule", md.getModuleRevisionId().getName());
assertEquals("Unexpected revision for the parsed module descriptor", "1.0.0", md.getModuleRevisionId().getRevision());
final Configuration[] confs = md.getConfigurations();
assertNotNull("No configurations found in module descriptor", confs);
assertEquals("Unexpected number of configurations found in module descriptor", 3, confs.length);
final Set<String> expectedConfs = new HashSet<>(Arrays.asList("parent-conf1", "parent-conf2", "conf2"));
for (final Configuration conf : confs) {
assertNotNull("One of the configurations was null in module descriptor", conf);
assertTrue("Unexpected configuration " + conf.getName() + " found in parsed module descriptor", expectedConfs.remove(conf.getName()));
}
assertTrue("Missing configurations " + expectedConfs + " from the parsed module descriptor", expectedConfs.isEmpty());
} finally {
// clean up the copied over file
Files.delete(parentIvyXMLPath);
}
}
示例9: testUpdateWithExcludeConfigurations3
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
@Test
public void testUpdateWithExcludeConfigurations3() throws Exception {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/"
+ "test-update-excludedconfs3.xml").toURI().toURL();
XmlModuleDescriptorUpdater.update(
settingsUrl,
buffer,
getUpdateOptions("release", "mynewrev").setConfsToExclude(
new String[] {"myconf2", "conf2"}));
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(),
new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0,
false), true);
// test the number of configurations
Configuration[] configs = updatedMd.getConfigurations();
assertNotNull("Configurations shouldn't be null", configs);
assertEquals("Number of configurations incorrect", 4, configs.length);
// test that the correct configuration has been removed
assertNull("myconf2 hasn't been removed", updatedMd.getConfiguration("myconf2"));
assertNull("conf2 hasn't been removed", updatedMd.getConfiguration("conf2"));
// test that the other configurations aren't removed
assertNotNull("conf1 has been removed", updatedMd.getConfiguration("conf1"));
assertNotNull("myconf1 has been removed", updatedMd.getConfiguration("myconf1"));
assertNotNull("myconf3 has been removed", updatedMd.getConfiguration("myconf3"));
assertNotNull("myconf4 has been removed", updatedMd.getConfiguration("myconf4"));
}
示例10: testMergedUpdateWithExtendsAndDefaultConfMappings
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
/**
* Test case for IVY-1420.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1420">IVY-1420</a>
*/
@Test
public void testMergedUpdateWithExtendsAndDefaultConfMappings() throws Exception {
URL url = XmlModuleUpdaterTest.class.getResource("test-extends-configurations-defaultconfmapping.xml");
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor md = parser.parseDescriptor(new IvySettings(), url, true);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
XmlModuleDescriptorUpdater.update(url, buffer,
getUpdateOptions("release", "mynewrev")
.setMerge(true)
.setMergedDescriptor(md));
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(),
new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0,
false), true);
Configuration[] configurations = updatedMd.getConfigurations();
assertNotNull("Configurations shouldn't be null", configurations);
assertEquals("Number of configurations is incorrect", 3, configurations.length);
String updatedXml = buffer.toString();
System.out.println(updatedXml);
assertTrue(updatedXml.contains("configurations defaultconfmapping=\"conf1,default->@()\""));
assertTrue(updatedXml.contains("dependencies defaultconfmapping=\"conf1,default->@()\""));
}
示例11: testMergedUpdateWithExtendsAndConfigurationsInheritance
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
/**
* Test case for IVY-1437.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1437">IVY-1437</a>
*/
@Test
public void testMergedUpdateWithExtendsAndConfigurationsInheritance() throws Exception {
URL url = XmlModuleUpdaterTest.class.getResource("test-extends-configurations-inherit.xml");
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor md = parser.parseDescriptor(new IvySettings(), url, true);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
XmlModuleDescriptorUpdater.update(url, buffer,
getUpdateOptions("release", "mynewrev")
.setMerge(true)
.setMergedDescriptor(md));
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(),
new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0,
false), true);
Configuration[] configurations = updatedMd.getConfigurations();
assertNotNull("Configurations shouldn't be null", configurations);
assertEquals("Number of configurations is incorrect", 2, configurations.length);
String updatedXml = buffer.toString();
System.out.println(updatedXml);
assertTrue(updatedXml.contains("configurations defaultconf=\"compile\" defaultconfmapping=\"*->default\""));
assertTrue(updatedXml.contains("dependencies defaultconf=\"compile\" defaultconfmapping=\"*->default\""));
}
示例12: testMergedUpdateWithIncludeAndExcludedConf
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
/**
* Test case for IVY-1419.
*
* @throws Exception if something goes wrong
* @see <a href="https://issues.apache.org/jira/browse/IVY-1419">IVY-1419</a>
*/
@Test
public void testMergedUpdateWithIncludeAndExcludedConf() throws Exception {
URL url = XmlModuleUpdaterTest.class.getResource("test-update-excludedconfs6.xml");
XmlModuleDescriptorParser parser = XmlModuleDescriptorParser.getInstance();
ModuleDescriptor md = parser.parseDescriptor(new IvySettings(), url, true);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
XmlModuleDescriptorUpdater.update(url, buffer,
getUpdateOptions("release", "mynewrev")
.setMerge(true)
.setMergedDescriptor(md)
.setConfsToExclude(new String[]{"conf1"}));
ModuleDescriptor updatedMd = parser.parseDescriptor(new IvySettings(),
new ByteArrayInputStream(buffer.toByteArray()), new BasicResource("test", false, 0, 0,
false), true);
Configuration[] configurations = updatedMd.getConfigurations();
assertNotNull("Configurations shouldn't be null", configurations);
assertEquals("Number of configurations is incorrect", 5, configurations.length);
String updatedXml = buffer.toString();
System.out.println(updatedXml);
assertTrue(updatedXml.contains("dependencies/"));
}
示例13: cloneMd
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
private DefaultModuleDescriptor cloneMd(ModuleDescriptor md, Artifact af) {
DefaultModuleDescriptor newMd = new DefaultModuleDescriptor(md.getModuleRevisionId(),
"release", null, true);
newMd.addConfiguration(new Configuration(ModuleDescriptor.DEFAULT_CONFIGURATION));
newMd.setLastModified(System.currentTimeMillis());
newMd.setDescription(md.getDescription());
newMd.setHomePage(md.getHomePage());
newMd.setLastModified(md.getLastModified());
newMd.setPublicationDate(md.getPublicationDate());
newMd.setResolvedPublicationDate(md.getResolvedPublicationDate());
newMd.setStatus(md.getStatus());
Configuration[] allConfs = md.getConfigurations();
if (allConfs.length == 0) {
newMd.addArtifact(ModuleDescriptor.DEFAULT_CONFIGURATION, af);
} else {
for (Configuration conf : allConfs) {
newMd.addConfiguration(conf);
newMd.addArtifact(conf.getName(), af);
}
}
for (DependencyDescriptor dependency : md.getDependencies()) {
newMd.addDependency(dependency);
}
for (ExcludeRule excludeRule : md.getAllExcludeRules()) {
newMd.addExcludeRule(excludeRule);
}
newMd.getExtraInfos().addAll(md.getExtraInfos());
for (License license : md.getLicenses()) {
newMd.addLicense(license);
}
return newMd;
}
示例14: setModuleDescriptor
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
public void setModuleDescriptor(ModuleDescriptor md) {
if (md == null) {
orderedConfigurations = new Configuration[0];
} else {
orderedConfigurations = md.getConfigurations();
}
confTableViewer.setInput(orderedConfigurations);
}
示例15: replaceConfigurationWildcards
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
private void replaceConfigurationWildcards(ModuleDescriptor md) {
Configuration[] configs = md.getConfigurations();
for (int i = 0; i < configs.length; i++) {
configs[i].replaceWildcards(md);
}
}