本文整理汇总了Java中org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java DefaultModuleDescriptor类的具体用法?Java DefaultModuleDescriptor怎么用?Java DefaultModuleDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultModuleDescriptor类属于org.apache.ivy.core.module.descriptor包,在下文中一共展示了DefaultModuleDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mergeInfo
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor; //导入依赖的package包/类
private void mergeInfo(ModuleDescriptor parent) {
ModuleRevisionId parentMrid = parent.getModuleRevisionId();
DefaultModuleDescriptor descriptor = getMd();
ModuleRevisionId currentMrid = descriptor.getModuleRevisionId();
ModuleRevisionId mergedMrid = createModuleRevisionId(
mergeValue(parentMrid.getOrganisation(), currentMrid.getOrganisation()),
currentMrid.getName(),
mergeValue(parentMrid.getBranch(), currentMrid.getBranch()),
mergeValue(parentMrid.getRevision(), currentMrid.getRevision()),
mergeValues(parentMrid.getQualifiedExtraAttributes(), currentMrid.getQualifiedExtraAttributes())
);
descriptor.setModuleRevisionId(mergedMrid);
descriptor.setResolvedModuleRevisionId(mergedMrid);
descriptor.setStatus(mergeValue(parent.getStatus(), descriptor.getStatus()));
if (descriptor.getNamespace() == null && parent instanceof DefaultModuleDescriptor) {
Namespace parentNamespace = ((DefaultModuleDescriptor) parent).getNamespace();
descriptor.setNamespace(parentNamespace);
}
}
示例2: populateModuleDescriptorWithPublication
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor; //导入依赖的package包/类
static void populateModuleDescriptorWithPublication(DefaultModuleDescriptor descriptor,
JkMavenPublication publication, Instant publishDate) {
final ModuleRevisionId moduleRevisionId = descriptor.getModuleRevisionId();
final String artifactName = moduleRevisionId.getName();
final Artifact mavenMainArtifact = toPublishedMavenArtifact(publication.mainArtifactFiles()
.get(0), artifactName, null, moduleRevisionId, publishDate);
final String mainConf = "default";
populateDescriptorWithMavenArtifact(descriptor, mainConf, mavenMainArtifact);
for (final JkClassifiedFileArtifact artifactEntry : publication.classifiedArtifacts()) {
final Path file = artifactEntry.file();
final String classifier = artifactEntry.classifier();
final Artifact mavenArtifact = toPublishedMavenArtifact(file, artifactName, classifier,
descriptor.getModuleRevisionId(), publishDate);
populateDescriptorWithMavenArtifact(descriptor, classifier, mavenArtifact);
}
}
示例3: publishMavenArtifacts
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor; //导入依赖的package包/类
private int publishMavenArtifacts(JkMavenPublication publication,
DefaultModuleDescriptor moduleDescriptor) {
int count = 0;
for (final RepositoryResolver resolver : IvyTranslations.publishResolverOf(this.ivy
.getSettings())) {
final JkPublishRepo publishRepo = this.publishRepos.getRepoHavingUrl(IvyTranslations
.publishResolverUrl(resolver));
final JkVersionedModule jkModule = IvyTranslations
.toJkVersionedModule(moduleDescriptor.getModuleRevisionId());
if (isMaven(resolver) && publishRepo.filter().accept(jkModule)) {
JkLog.startln("Publishing for repository " + resolver);
final CheckFileFlag checkFileFlag = CheckFileFlag.of(publishRepo);
final IvyPublisherForMaven ivyPublisherForMaven = new IvyPublisherForMaven(
checkFileFlag, resolver, descriptorOutputDir, publishRepo.uniqueSnapshot());
ivyPublisherForMaven.publish(moduleDescriptor, publication);
count++;
}
}
return count;
}
示例4: toPublicationLessModule
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor; //导入依赖的package包/类
@Test
public void toPublicationLessModule() throws Exception {
final JkScopeMapping mapping = DEFAULT_SCOPE_MAPPING;
final JkVersionProvider versionProvider = JkVersionProvider.empty();
// handle multiple artifacts properly
final DefaultModuleDescriptor desc = IvyTranslations.toPublicationLessModule(OWNER, deps(), mapping, versionProvider);
final DependencyDescriptor[] dependencyDescriptors = desc.getDependencies();
assertEquals(1, dependencyDescriptors.length);
final DependencyDescriptor depDesc = dependencyDescriptors[0];
final DependencyArtifactDescriptor[] artifactDescs = depDesc.getAllDependencyArtifacts();
assertEquals(2, artifactDescs.length);
final DependencyArtifactDescriptor mainArt = findArtifactIn(artifactDescs, null);
assertNotNull(mainArt);
final DependencyArtifactDescriptor linuxArt = findArtifactIn(artifactDescs, "linux");
assertNotNull(linuxArt);
System.out.println(Arrays.asList(linuxArt.getConfigurations()));
}
示例5: doParseDescriptor
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor; //导入依赖的package包/类
protected MutableModuleVersionMetaData doParseDescriptor(DescriptorParseContext parserSettings, LocallyAvailableExternalResource resource, boolean validate) throws IOException, ParseException, SAXException {
PomReader pomReader = new PomReader(resource);
GradlePomModuleDescriptorBuilder mdBuilder = new GradlePomModuleDescriptorBuilder(resource, parserSettings, pomReader);
doParsePom(parserSettings, mdBuilder, pomReader);
String artifactId = pomReader.getArtifactId();
if (pomReader.getRelocation() == null) {
mdBuilder.addMainArtifact(artifactId, pomReader.getPackaging());
}
DefaultModuleDescriptor moduleDescriptor = mdBuilder.getModuleDescriptor();
ModuleDescriptorAdapter adapter = new ModuleDescriptorAdapter(moduleDescriptor);
if ("pom".equals(pomReader.getPackaging())) {
adapter.setMetaDataOnly(true);
}
return adapter;
}
示例6: findModule
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor; //导入依赖的package包/类
public ResolvedModuleRevision findModule(ModuleRevisionId id, ResolveOptions options) {
DependencyResolver r = settings.getResolver(id);
if (r == null) {
throw new IllegalStateException("no resolver found for " + id.getModuleId());
}
DefaultModuleDescriptor md = DefaultModuleDescriptor.newCallerInstance(id,
new String[] {"*"}, false, false);
if (options.getResolveId() == null) {
options.setResolveId(ResolveOptions.getDefaultResolveId(md));
}
try {
return r.getDependency(new DefaultDependencyDescriptor(id, true), new ResolveData(this,
options, new ConfigurationResolveReport(this, md, "default", null, options)));
} catch (ParseException e) {
throw new RuntimeException("problem while parsing repository module descriptor for "
+ id + ": " + e, e);
}
}
示例7: mergeInfo
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor; //导入依赖的package包/类
/**
* Explain how to inherit metadata related to info element
*
* @param parent
* a given parent module descriptor
*/
protected void mergeInfo(ModuleDescriptor parent) {
ModuleRevisionId parentMrid = parent.getModuleRevisionId();
DefaultModuleDescriptor descriptor = getMd();
ModuleRevisionId currentMrid = descriptor.getModuleRevisionId();
ModuleRevisionId mergedMrid = ModuleRevisionId.newInstance(
mergeValue(parentMrid.getOrganisation(), currentMrid.getOrganisation()),
currentMrid.getName(),
mergeValue(parentMrid.getBranch(), currentMrid.getBranch()),
mergeRevisionValue(parentMrid.getRevision(), currentMrid.getRevision()),
mergeValues(parentMrid.getQualifiedExtraAttributes(),
currentMrid.getQualifiedExtraAttributes()));
descriptor.setModuleRevisionId(mergedMrid);
descriptor.setResolvedModuleRevisionId(mergedMrid);
descriptor.setStatus(mergeValue(parent.getStatus(), descriptor.getStatus()));
if (descriptor.getNamespace() == null && parent instanceof DefaultModuleDescriptor) {
Namespace parentNamespace = ((DefaultModuleDescriptor) parent).getNamespace();
descriptor.setNamespace(parentNamespace);
}
descriptor.getExtraInfos().addAll(parent.getExtraInfos());
}
示例8: testCircularDependency
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor; //导入依赖的package包/类
/**
* Sorter does not throw circular dependency, circular dependencies are handled at resolve time
* only. However the sort respect the transitive order when it is unambiguous. (If A depends
* transitively of B, but B doesn't depends transitively on A, then B always comes before A.)
*/
@Test
public void testCircularDependency() {
addDependency(md1, "md4", "rev4");
addDependency(md2, "md1", "rev1");
addDependency(md3, "md2", "rev2");
addDependency(md4, "md3", "rev3");
DefaultModuleDescriptor[][] possibleOrder = new DefaultModuleDescriptor[][] {
{md2, md3, md4, md1}, {md3, md4, md1, md2}, {md4, md1, md2, md3},
{md1, md2, md3, md4}};
for (List<ModuleDescriptor> toSort : getAllLists(md1, md3, md2, md4)) {
assertSorted(possibleOrder, sortModuleDescriptors(toSort, nonMatchReporter));
}
}
示例9: testLatestIntegration
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor; //导入依赖的package包/类
/**
* The dependency can ask for the latest integration. It should match whatever the version
* declared in the modules to order.
*/
@Test
public void testLatestIntegration() {
addDependency(md2, "md1", "latest.integration");
addDependency(md3, "md2", "latest.integration");
addDependency(md4, "md3", "latest.integration");
settings.setVersionMatcher(new LatestVersionMatcher());
DefaultModuleDescriptor[][] expectedOrder = new DefaultModuleDescriptor[][] {
{md1, md2, md3, md4}};
for (List<ModuleDescriptor> toSort : getAllLists(md1, md3, md2, md4)) {
assertSorted(expectedOrder, sortModuleDescriptors(toSort, nonMatchReporter));
}
}
示例10: testDifferentVersionNotConsidered
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor; //导入依赖的package包/类
/**
* When the version asked by a dependency is not compatible with the version declared in the
* module to order, the two modules should be considered as independent.
* NB: I'm sure of what 'compatible' means !
*/
@Test
public void testDifferentVersionNotConsidered() {
// To test it, I use a 'broken' loop (in one step, I change the revision) in such a way that
// I get only one solution. If the loop was
// complete more solutions where possible.
addDependency(md1, "md4", "rev4-other");
addDependency(md2, "md1", "rev1");
addDependency(md3, "md2", "rev2");
addDependency(md4, "md3", "rev3");
DefaultModuleDescriptor[][] possibleOrder = new DefaultModuleDescriptor[][] {
{md1, md2, md3, md4}};
for (List<ModuleDescriptor> toSort : getAllLists(md1, md3, md2, md4)) {
assertSorted(possibleOrder, sortModuleDescriptors(toSort, nonMatchReporter));
}
}
示例11: testSimple
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor; //导入依赖的package包/类
@Test
public void testSimple() throws Exception {
DefaultModuleDescriptor md = (DefaultModuleDescriptor) XmlModuleDescriptorParser
.getInstance().parseDescriptor(new IvySettings(),
XmlModuleDescriptorWriterTest.class.getResource("test-simple.xml"), true);
md.setResolvedPublicationDate(new GregorianCalendar(2005, 4, 1, 11, 0, 0).getTime());
md.setResolvedModuleRevisionId(new ModuleRevisionId(md.getModuleRevisionId().getModuleId(),
"NONE"));
XmlModuleDescriptorWriter.write(md, LICENSE, dest);
assertTrue(dest.exists());
String wrote = FileUtil.readEntirely(new BufferedReader(new FileReader(dest)))
.replaceAll("\r\n", "\n").replace('\r', '\n');
String expected = readEntirely("test-write-simple.xml").replaceAll("\r\n", "\n").replace(
'\r', '\n');
assertEquals(expected, wrote);
}
示例12: testInfo
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor; //导入依赖的package包/类
@Test
public void testInfo() throws Exception {
DefaultModuleDescriptor md = (DefaultModuleDescriptor) XmlModuleDescriptorParser
.getInstance().parseDescriptor(new IvySettings(),
XmlModuleDescriptorWriterTest.class.getResource("test-info.xml"), true);
md.setResolvedPublicationDate(new GregorianCalendar(2005, 4, 1, 11, 0, 0).getTime());
md.setResolvedModuleRevisionId(new ModuleRevisionId(md.getModuleRevisionId().getModuleId(),
"NONE"));
XmlModuleDescriptorWriter.write(md, LICENSE, dest);
assertTrue(dest.exists());
String wrote = FileUtil.readEntirely(new BufferedReader(new FileReader(dest)))
.replaceAll("\r\n", "\n").replace('\r', '\n');
String expected = readEntirely("test-write-info.xml").replaceAll("\r\n", "\n").replace(
'\r', '\n');
assertEquals(expected, wrote);
}
示例13: testTransitiveAttributeForNonTransitiveConfs
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor; //导入依赖的package包/类
/**
* 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\""));
}
示例14: testTransitiveAttributeNotWrittenForTransitiveConfs
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor; //导入依赖的package包/类
/**
* 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="));
}
示例15: computeModuleDescriptor
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor; //导入依赖的package包/类
public static DefaultModuleDescriptor computeModuleDescriptor(DefaultModuleDescriptor md, IvySettings settings,
List<IvyDependency> dependencies, List<IvyConflict> conflicts, List<IvyExclude> excludes) {
for (IvyDependency dependency : dependencies) {
DependencyDescriptor dd = dependency.asDependencyDescriptor(md, "default", settings);
md.addDependency(dd);
}
for (IvyExclude exclude : excludes) {
org.apache.ivy.core.module.descriptor.DefaultExcludeRule rule = exclude.asRule(settings);
rule.addConfiguration("default");
md.addExcludeRule(rule);
}
for (IvyConflict conflict : conflicts) {
conflict.addConflict(md, settings);
}
return md;
}