本文整理汇总了Java中org.apache.ivy.core.module.descriptor.ModuleDescriptor.getAllArtifacts方法的典型用法代码示例。如果您正苦于以下问题:Java ModuleDescriptor.getAllArtifacts方法的具体用法?Java ModuleDescriptor.getAllArtifacts怎么用?Java ModuleDescriptor.getAllArtifacts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ivy.core.module.descriptor.ModuleDescriptor
的用法示例。
在下文中一共展示了ModuleDescriptor.getAllArtifacts方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUpdateWithExcludeConfigurations4
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
@Test
public void testUpdateWithExcludeConfigurations4() throws Exception {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
URL settingsUrl = new File("test/java/org/apache/ivy/plugins/parser/xml/"
+ "test-update-excludedconfs4.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
Artifact[] artifacts = updatedMd.getAllArtifacts();
assertNotNull("Published artifacts shouldn't be null", artifacts);
assertEquals("Number of published artifacts incorrect", 4, artifacts.length);
// test that the correct configuration has been removed
for (Artifact current : artifacts) {
List<String> currentConfs = Arrays.asList(current.getConfigurations());
assertTrue("myconf2 hasn't been removed for artifact " + current.getName(),
!currentConfs.contains("myconf2"));
}
}
示例2: resolveModuleVersion
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
private String resolveModuleVersion( ModuleDescriptor module )
{
for ( Artifact artifact : module.getAllArtifacts() )
{
ResolutionRequest request = new ResolutionRequest( ivy2aether( artifact ) );
ResolutionResult result = getResolver().resolve( request );
if ( result.getArtifactPath() != null )
return resolvedVersion( result );
}
return null;
}
示例3: findArtifact
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
/**
* Returns the first artifact with the correct name and without a classifier.
*/
private static Artifact findArtifact(ModuleDescriptor md, String artifactName) {
for (Artifact artifact : md.getAllArtifacts()) {
if (artifact.getName().equals(artifactName)
&& artifact.getAttribute("classifier") == null) {
return artifact;
}
}
return null;
}
示例4: printPublications
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
private static void printPublications(ModuleDescriptor md, PrintWriter out) {
out.println("\t<publications>");
for (Artifact artifact : md.getAllArtifacts()) {
out.print(String.format("\t\t<artifact name=\"%s\" type=\"%s\" ext=\"%s\" conf=\"%s\"",
XMLHelper.escape(artifact.getName()),
XMLHelper.escape(artifact.getType()),
XMLHelper.escape(artifact.getExt()),
XMLHelper.escape(getConfs(md, artifact))));
printExtraAttributes(artifact, out, " ");
out.println("/>");
}
out.println("\t</publications>");
}
示例5: fillRepository
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
/**
* Fills a repository with a set of module, using empty files for published artifacts.
*
* @param resolver
* the resolver to use to publish the modules
* @param mds
* the descriptors of the modules to put in the repository
* @throws IOException
* if an IO problem occurs while filling the repository
*/
public static void fillRepository(DependencyResolver resolver, Collection<ModuleDescriptor> mds)
throws IOException {
File tmp = File.createTempFile("ivy", "tmp");
try {
for (ModuleDescriptor md : mds) {
boolean overwrite = false;
resolver.beginPublishTransaction(md.getModuleRevisionId(), overwrite);
boolean published = false;
try {
XmlModuleDescriptorWriter.write(md, tmp);
resolver.publish(md.getMetadataArtifact(), tmp, overwrite);
tmp.delete();
tmp.createNewFile();
for (Artifact artifact : md.getAllArtifacts()) {
resolver.publish(artifact, tmp, overwrite);
}
resolver.commitPublishTransaction();
published = true;
} finally {
if (!published) {
resolver.abortPublishTransaction();
}
}
}
} finally {
tmp.delete();
}
}
示例6: testExtendsConfigurations
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
@Test
public void testExtendsConfigurations() throws Exception {
// descriptor specifies that only parent configurations should be included
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-extends-configurations.xml"), true);
assertNotNull(md);
assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("mymodule", md.getModuleRevisionId().getName());
assertEquals(Ivy.getWorkingRevision(), md.getModuleRevisionId().getRevision());
assertEquals("integration", md.getStatus());
// verify that the parent description was ignored.
assertEquals("", md.getDescription());
// verify that the parent and child configurations were merged together.
final Configuration[] expectedConfs = {new Configuration("default"),
new Configuration("conf1"), new Configuration("conf2")};
assertNotNull(md.getConfigurations());
assertEquals(Arrays.asList(expectedConfs), Arrays.asList(md.getConfigurations()));
// verify parent dependencies were ignored.
DependencyDescriptor[] deps = md.getDependencies();
assertNotNull(deps);
assertEquals(1, deps.length);
assertEquals(Arrays.asList("conf1", "conf2"),
Arrays.asList(deps[0].getModuleConfigurations()));
ModuleRevisionId dep = deps[0].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule2", dep.getModuleId().getName());
assertEquals("2.0", dep.getRevision());
// verify only child publications are present
Artifact[] artifacts = md.getAllArtifacts();
assertNotNull(artifacts);
assertEquals(1, artifacts.length);
assertEquals("mymodule", artifacts[0].getName());
assertEquals("jar", artifacts[0].getType());
}
示例7: testExtendsDescription
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
@Test
public void testExtendsDescription() throws Exception {
// descriptor specifies that only parent description should be included
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-extends-description.xml"), true);
assertNotNull(md);
assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("mymodule", md.getModuleRevisionId().getName());
assertEquals(Ivy.getWorkingRevision(), md.getModuleRevisionId().getRevision());
assertEquals("integration", md.getStatus());
// verify that the parent description was merged.
assertEquals("Parent module description.", md.getDescription());
// verify that the parent configurations were ignored.
final Configuration[] expectedConfs = {new Configuration("default")};
assertNotNull(md.getConfigurations());
assertEquals(Arrays.asList(expectedConfs), Arrays.asList(md.getConfigurations()));
// verify parent dependencies were ignored.
DependencyDescriptor[] deps = md.getDependencies();
assertNotNull(deps);
assertEquals(1, deps.length);
assertEquals(Collections.singletonList("default"),
Arrays.asList(deps[0].getModuleConfigurations()));
ModuleRevisionId dep = deps[0].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule2", dep.getModuleId().getName());
assertEquals("2.0", dep.getRevision());
// verify only child publications are present
Artifact[] artifacts = md.getAllArtifacts();
assertNotNull(artifacts);
assertEquals(1, artifacts.length);
assertEquals("mymodule", artifacts[0].getName());
assertEquals("jar", artifacts[0].getType());
}
示例8: testExtendsDescriptionWithOverride
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
@Test
public void testExtendsDescriptionWithOverride() throws Exception {
// descriptor specifies that only parent description should be included
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-extends-description-override.xml"), true);
assertNotNull(md);
assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("mymodule", md.getModuleRevisionId().getName());
assertEquals(Ivy.getWorkingRevision(), md.getModuleRevisionId().getRevision());
assertEquals("integration", md.getStatus());
// child description should always be preferred, even if extendType="description"
assertEquals("Child description overrides parent.", md.getDescription());
// verify that the parent configurations were ignored.
final Configuration[] expectedConfs = {new Configuration("default")};
assertNotNull(md.getConfigurations());
assertEquals(Arrays.asList(expectedConfs), Arrays.asList(md.getConfigurations()));
// verify parent dependencies were ignored.
DependencyDescriptor[] deps = md.getDependencies();
assertNotNull(deps);
assertEquals(1, deps.length);
assertEquals(Collections.singletonList("default"),
Arrays.asList(deps[0].getModuleConfigurations()));
ModuleRevisionId dep = deps[0].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule2", dep.getModuleId().getName());
assertEquals("2.0", dep.getRevision());
// verify only child publications are present
Artifact[] artifacts = md.getAllArtifacts();
assertNotNull(artifacts);
assertEquals(1, artifacts.length);
assertEquals("mymodule", artifacts[0].getName());
assertEquals("jar", artifacts[0].getType());
}
示例9: testExtendsAll
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
@Test
public void testExtendsAll() throws Exception {
Message.setDefaultLogger(new DefaultMessageLogger(99));
// default extends type is 'all' when no extendsType attribute is specified.
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-extends-all.xml"), true);
assertNotNull(md);
assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("mymodule", md.getModuleRevisionId().getName());
assertEquals("myrev", md.getModuleRevisionId().getRevision());
assertEquals("integration", md.getStatus());
// verify that the parent description was merged.
assertEquals("Parent module description.", md.getDescription());
// verify that the parent and child configurations were merged together.
final Configuration[] expectedConfs = {new Configuration("default"),
new Configuration("conf1"), new Configuration("conf2")};
assertNotNull(md.getConfigurations());
assertEquals(Arrays.asList(expectedConfs), Arrays.asList(md.getConfigurations()));
// verify parent and child dependencies were merged together.
DependencyDescriptor[] deps = md.getDependencies();
assertNotNull(deps);
assertEquals(2, deps.length);
assertEquals(Collections.singletonList("default"),
Arrays.asList(deps[0].getModuleConfigurations()));
ModuleRevisionId dep = deps[0].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule1", dep.getModuleId().getName());
assertEquals("1.0", dep.getRevision());
assertEquals(Arrays.asList("conf1", "conf2"),
Arrays.asList(deps[1].getModuleConfigurations()));
dep = deps[1].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule2", dep.getModuleId().getName());
assertEquals("2.0", dep.getRevision());
// verify only child publications are present
Artifact[] artifacts = md.getAllArtifacts();
assertNotNull(artifacts);
assertEquals(1, artifacts.length);
assertEquals("mymodule", artifacts[0].getName());
assertEquals("jar", artifacts[0].getType());
}
示例10: testExtendsDependencies
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
@Test
public void testExtendsDependencies() throws Exception {
// descriptor specifies that only parent dependencies should be included
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-extends-dependencies.xml"), true);
assertNotNull(md);
assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("mymodule", md.getModuleRevisionId().getName());
assertEquals(Ivy.getWorkingRevision(), md.getModuleRevisionId().getRevision());
assertEquals("integration", md.getStatus());
// verify that the parent description was ignored.
assertEquals("", md.getDescription());
// verify that the parent configurations were ignored.
final Configuration[] expectedConfs = {new Configuration("default")};
assertNotNull(md.getConfigurations());
assertEquals(Arrays.asList(expectedConfs), Arrays.asList(md.getConfigurations()));
// verify parent dependencies were merged.
DependencyDescriptor[] deps = md.getDependencies();
assertNotNull(deps);
assertEquals(2, deps.length);
assertEquals(Collections.singletonList("default"),
Arrays.asList(deps[0].getModuleConfigurations()));
ModuleRevisionId dep = deps[0].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule1", dep.getModuleId().getName());
assertEquals("1.0", dep.getRevision());
assertEquals(Collections.singletonList("default"),
Arrays.asList(deps[1].getModuleConfigurations()));
dep = deps[1].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule2", dep.getModuleId().getName());
assertEquals("2.0", dep.getRevision());
// verify only child publications are present
Artifact[] artifacts = md.getAllArtifacts();
assertNotNull(artifacts);
assertEquals(1, artifacts.length);
assertEquals("mymodule", artifacts[0].getName());
assertEquals("jar", artifacts[0].getType());
}
示例11: testExtendsMixed
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
@Test
public void testExtendsMixed() throws Exception {
// descriptor specifies that parent configurations and dependencies should be included
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-extends-mixed.xml"), true);
assertNotNull(md);
assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("mymodule", md.getModuleRevisionId().getName());
assertEquals(Ivy.getWorkingRevision(), md.getModuleRevisionId().getRevision());
assertEquals("integration", md.getStatus());
// verify that the parent description was ignored.
assertEquals("", md.getDescription());
// verify that the parent and child configurations were merged together.
final Configuration[] expectedConfs = {new Configuration("default"),
new Configuration("conf1"), new Configuration("conf2")};
assertNotNull(md.getConfigurations());
assertEquals(Arrays.asList(expectedConfs), Arrays.asList(md.getConfigurations()));
// verify parent and child dependencies were merged together.
DependencyDescriptor[] deps = md.getDependencies();
assertNotNull(deps);
assertEquals(2, deps.length);
assertEquals(Collections.singletonList("default"),
Arrays.asList(deps[0].getModuleConfigurations()));
ModuleRevisionId dep = deps[0].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule1", dep.getModuleId().getName());
assertEquals("1.0", dep.getRevision());
assertEquals(Arrays.asList("conf1", "conf2"),
Arrays.asList(deps[1].getModuleConfigurations()));
dep = deps[1].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule2", dep.getModuleId().getName());
assertEquals("2.0", dep.getRevision());
// verify only child publications are present
Artifact[] artifacts = md.getAllArtifacts();
assertNotNull(artifacts);
assertEquals(1, artifacts.length);
assertEquals("mymodule", artifacts[0].getName());
assertEquals("jar", artifacts[0].getType());
}
示例12: testExtendsCached
import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
@Test
public void testExtendsCached() throws Exception {
// configure a resolver to serve the parent descriptor, so that parse succeeds.
File resolveRoot = new File("build/tmp/xmlModuleDescriptorTest");
assertTrue(resolveRoot.exists() || resolveRoot.mkdirs());
FileUtil.copy(getClass().getResource("test-extends-parent.xml"), new File(resolveRoot,
"myorg/myparent/ivy.xml"), null, null);
FileSystemResolver resolver = new FileSystemResolver();
resolver.setSettings(settings);
resolver.setName("testExtendsCached");
resolver.addIvyPattern(resolveRoot.getAbsolutePath()
+ "/[organisation]/[module]/[artifact].[ext]");
settings.addResolver(resolver);
settings.setDefaultResolver("testExtendsCached");
// descriptor extends a module without a location="..." attribute, so resolver lookup
// must be performed.
ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor(settings,
getClass().getResource("test-extends-cached.xml"), true);
assertNotNull(md);
assertEquals("myorg", md.getModuleRevisionId().getOrganisation());
assertEquals("mymodule", md.getModuleRevisionId().getName());
assertEquals("myrev", md.getModuleRevisionId().getRevision());
assertEquals("integration", md.getStatus());
// verify that the parent description was merged.
assertEquals("Parent module description.", md.getDescription());
// verify that the parent and child configurations were merged together.
final Configuration[] expectedConfs = {new Configuration("default"),
new Configuration("conf1"), new Configuration("conf2")};
assertNotNull(md.getConfigurations());
assertEquals(Arrays.asList(expectedConfs), Arrays.asList(md.getConfigurations()));
// verify parent and child dependencies were merged together.
DependencyDescriptor[] deps = md.getDependencies();
assertNotNull(deps);
assertEquals(2, deps.length);
assertEquals(Collections.singletonList("default"),
Arrays.asList(deps[0].getModuleConfigurations()));
ModuleRevisionId dep = deps[0].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule1", dep.getModuleId().getName());
assertEquals("1.0", dep.getRevision());
assertEquals(Arrays.asList("conf1", "conf2"),
Arrays.asList(deps[1].getModuleConfigurations()));
dep = deps[1].getDependencyRevisionId();
assertEquals("myorg", dep.getModuleId().getOrganisation());
assertEquals("mymodule2", dep.getModuleId().getName());
assertEquals("2.0", dep.getRevision());
// verify only child publications are present
Artifact[] artifacts = md.getAllArtifacts();
assertNotNull(artifacts);
assertEquals(1, artifacts.length);
assertEquals("mymodule", artifacts[0].getName());
assertEquals("jar", artifacts[0].getType());
}