本文整理汇总了Java中org.apache.ivy.core.module.descriptor.MDArtifact类的典型用法代码示例。如果您正苦于以下问题:Java MDArtifact类的具体用法?Java MDArtifact怎么用?Java MDArtifact使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MDArtifact类属于org.apache.ivy.core.module.descriptor包,在下文中一共展示了MDArtifact类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addArtifact
import org.apache.ivy.core.module.descriptor.MDArtifact; //导入依赖的package包/类
public void addArtifact(IvyArtifactName newArtifact, Set<String> configurations) {
if (configurations.isEmpty()) {
throw new IllegalArgumentException("Artifact should be attached to at least one configuration.");
}
MDArtifact unattached = new MDArtifact(module, newArtifact.getName(), newArtifact.getType(), newArtifact.getExtension(), null, newArtifact.getAttributes());
//Adding the artifact will replace any existing artifact
//This potentially leads to loss of information - the configurations of the replaced artifact are lost (see GRADLE-123)
//Hence we attempt to find an existing artifact and merge the information
Artifact[] allArtifacts = module.getAllArtifacts();
for (Artifact existing : allArtifacts) {
// Can't just compare the raw IvyArtifactName, since creating MDArtifact creates a bunch of attributes
if (artifactsEqual(unattached, existing)) {
if (!(existing instanceof MDArtifact)) {
throw new IllegalArgumentException("Cannot update an existing artifact (" + existing + ") in provided module descriptor (" + module + ")"
+ " because the artifact is not an instance of MDArtifact." + module);
}
attachArtifact((MDArtifact) existing, configurations, module);
return; //there is only one matching artifact
}
}
attachArtifact(unattached, configurations, module);
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:24,代码来源:BuildableIvyModuleResolveMetaData.java
示例2: addArtifactsFromMergedUsage
import org.apache.ivy.core.module.descriptor.MDArtifact; //导入依赖的package包/类
private void addArtifactsFromMergedUsage(String rootModuleConf, Set<Artifact> artifacts) {
for (IvyNodeUsage usage : mergedUsages.values()) {
Set<DependencyArtifactDescriptor> mergedDependencyArtifacts = usage
.getDependencyArtifactsSet(rootModuleConf);
if (mergedDependencyArtifacts != null) {
for (DependencyArtifactDescriptor dad : mergedDependencyArtifacts) {
Map<String, String> extraAttributes = new HashMap<>(
dad.getQualifiedExtraAttributes());
MDArtifact artifact = new MDArtifact(md, dad.getName(), dad.getType(),
dad.getExt(), dad.getUrl(), extraAttributes);
if (!artifacts.contains(artifact)) {
// this is later used to know that this is a merged artifact
extraAttributes.put("ivy:merged", dad.getDependencyDescriptor()
.getParentRevisionId() + " -> " + usage.getNode().getId());
artifacts.add(artifact);
}
}
}
}
}
开发者ID:apache,项目名称:ant-ivy,代码行数:22,代码来源:IvyNode.java
示例3: publish
import org.apache.ivy.core.module.descriptor.MDArtifact; //导入依赖的package包/类
public void publish(final Iterable<? extends PublicationAwareRepository> repositories, final ModuleInternal module, final Configuration configuration, final File descriptor) throws PublishException {
ivyContextManager.withIvy(new Action<Ivy>() {
public void execute(Ivy ivy) {
Set<Configuration> allConfigurations = configuration.getAll();
Set<Configuration> configurationsToPublish = configuration.getHierarchy();
MutableLocalComponentMetaData componentMetaData = publishLocalComponentFactory.convert(allConfigurations, module);
if (descriptor != null) {
ModuleDescriptor moduleDescriptor = componentMetaData.getModuleDescriptor();
ivyModuleDescriptorWriter.write(moduleDescriptor, descriptor);
}
// Need to convert a second time, to determine which artifacts to publish (and yes, this isn't a great way to do things...)
componentMetaData = publishLocalComponentFactory.convert(configurationsToPublish, module);
BuildableIvyModulePublishMetaData publishMetaData = componentMetaData.toPublishMetaData();
if (descriptor != null) {
Artifact artifact = MDArtifact.newIvyArtifact(componentMetaData.getModuleDescriptor());
publishMetaData.addArtifact(artifact, descriptor);
}
List<ModuleVersionPublisher> publishResolvers = new ArrayList<ModuleVersionPublisher>();
for (PublicationAwareRepository repository : repositories) {
ModuleVersionPublisher publisher = repository.createPublisher();
publishResolvers.add(publisher);
}
dependencyPublisher.publish(publishResolvers, publishMetaData);
}
});
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:31,代码来源:IvyBackedArtifactPublisher.java
示例4: attachArtifact
import org.apache.ivy.core.module.descriptor.MDArtifact; //导入依赖的package包/类
private static void attachArtifact(MDArtifact artifact, Set<String> configurations, DefaultModuleDescriptor target) {
//The existing artifact configurations will be first
Set<String> existingConfigurations = newLinkedHashSet(asList(artifact.getConfigurations()));
for (String c : configurations) {
if (!existingConfigurations.contains(c)) {
artifact.addConfiguration(c);
target.addArtifact(c, artifact);
}
}
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:11,代码来源:BuildableIvyModuleResolveMetaData.java
示例5: publish
import org.apache.ivy.core.module.descriptor.MDArtifact; //导入依赖的package包/类
public void publish(final Iterable<? extends PublicationAwareRepository> repositories, final ModuleInternal module, final Configuration configuration, final File descriptor) throws PublishException {
ivyContextManager.withIvy(new Action<Ivy>() {
public void execute(Ivy ivy) {
Set<Configuration> allConfigurations = configuration.getAll();
Set<Configuration> configurationsToPublish = configuration.getHierarchy();
MutableLocalComponentMetaData componentMetaData = publishLocalComponentFactory.convert(allConfigurations, module);
if (descriptor != null) {
ModuleDescriptor moduleDescriptor = componentMetaData.getModuleDescriptor();
ivyModuleDescriptorWriter.write(moduleDescriptor, descriptor);
}
// Need to convert a second time, to determine which artifacts to publish (and yes, this isn't a great way to do things...)
componentMetaData = publishLocalComponentFactory.convert(configurationsToPublish, module);
BuildableModuleVersionPublishMetaData publishMetaData = componentMetaData.toPublishMetaData();
if (descriptor != null) {
Artifact artifact = MDArtifact.newIvyArtifact(componentMetaData.getModuleDescriptor());
publishMetaData.addArtifact(artifact, descriptor);
}
List<ModuleVersionPublisher> publishResolvers = new ArrayList<ModuleVersionPublisher>();
for (PublicationAwareRepository repository : repositories) {
ModuleVersionPublisher publisher = repository.createPublisher();
publisher.setSettings(ivy.getSettings());
publishResolvers.add(publisher);
}
dependencyPublisher.publish(publishResolvers, publishMetaData);
}
});
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:32,代码来源:IvyBackedArtifactPublisher.java
示例6: addArtifactsFromOwnUsage
import org.apache.ivy.core.module.descriptor.MDArtifact; //导入依赖的package包/类
private void addArtifactsFromOwnUsage(Set<Artifact> artifacts,
Set<DependencyArtifactDescriptor> dependencyArtifacts) {
for (DependencyArtifactDescriptor dad : dependencyArtifacts) {
artifacts.add(new MDArtifact(md, dad.getName(), dad.getType(), dad.getExt(), dad
.getUrl(), dad.getQualifiedExtraAttributes()));
}
}
开发者ID:apache,项目名称:ant-ivy,代码行数:8,代码来源:IvyNode.java
示例7: artifactStarted
import org.apache.ivy.core.module.descriptor.MDArtifact; //导入依赖的package包/类
protected void artifactStarted(String qName, Attributes attributes)
throws MalformedURLException {
if (state == State.PUB) {
// this is a published artifact
String artName = settings.substitute(attributes.getValue("name"));
if (artName == null) {
artName = getMd().getModuleRevisionId().getName();
}
String type = settings.substitute(attributes.getValue("type"));
if (type == null) {
type = "jar";
}
String ext = settings.substitute(attributes.getValue("ext"));
if (ext == null) {
ext = type;
}
String url = settings.substitute(attributes.getValue("url"));
artifact = new MDArtifact(getMd(), artName, type, ext, url == null ? null
: new URL(url), ExtendableItemHelper.getExtraAttributes(settings,
attributes, Arrays.asList("ext", "type", "name", "conf")));
String confs = settings.substitute(attributes.getValue("conf"));
// only add confs if they are specified. if they aren't, endElement will
// handle this
// only if there are no conf defined in sub elements
if (confs != null && confs.length() > 0) {
String[] configs = "*".equals(confs) ? getMd().getConfigurationsNames()
: splitToArray(confs);
for (String config : configs) {
artifact.addConfiguration(config);
getMd().addArtifact(config, artifact);
}
}
} else if (state == State.DEP) {
// this is an artifact asked for a particular dependency
addDependencyArtifacts(qName, attributes);
} else if (validate) {
addError("artifact tag found in invalid tag: " + state);
}
}
开发者ID:apache,项目名称:ant-ivy,代码行数:40,代码来源:XmlModuleDescriptorParser.java
示例8: addArtifact
import org.apache.ivy.core.module.descriptor.MDArtifact; //导入依赖的package包/类
void addArtifact(DefaultModuleDescriptor moduleDescriptor, String name, String type, String extension, Map<String, String> extraAttributes, String configuration) {
LOG.trace("addArtifact {} ", name);
moduleDescriptor.addArtifact(configuration, new MDArtifact(moduleDescriptor, name, type, extension, null, extraAttributes));
}
开发者ID:dhakehurst,项目名称:net.akehurst.build.gradle,代码行数:5,代码来源:AbstractP2RepositoryAccess.java
示例9: getSourceArtifact
import org.apache.ivy.core.module.descriptor.MDArtifact; //导入依赖的package包/类
public Artifact getSourceArtifact() {
return new MDArtifact(ivyModuleDescriptor, mrid.getName(), "source", "jar", null,
Collections.singletonMap("m:classifier", "sources"));
}
开发者ID:apache,项目名称:ant-ivy,代码行数:5,代码来源:PomModuleDescriptorBuilder.java
示例10: getSrcArtifact
import org.apache.ivy.core.module.descriptor.MDArtifact; //导入依赖的package包/类
public Artifact getSrcArtifact() {
return new MDArtifact(ivyModuleDescriptor, mrid.getName(), "source", "jar", null,
Collections.singletonMap("m:classifier", "src"));
}
开发者ID:apache,项目名称:ant-ivy,代码行数:5,代码来源:PomModuleDescriptorBuilder.java
示例11: getJavadocArtifact
import org.apache.ivy.core.module.descriptor.MDArtifact; //导入依赖的package包/类
public Artifact getJavadocArtifact() {
return new MDArtifact(ivyModuleDescriptor, mrid.getName(), "javadoc", "jar", null,
Collections.singletonMap("m:classifier", "javadoc"));
}
开发者ID:apache,项目名称:ant-ivy,代码行数:5,代码来源:PomModuleDescriptorBuilder.java
示例12: getArtifact
import org.apache.ivy.core.module.descriptor.MDArtifact; //导入依赖的package包/类
protected MDArtifact getArtifact() {
return artifact;
}
开发者ID:apache,项目名称:ant-ivy,代码行数:4,代码来源:XmlModuleDescriptorParser.java
示例13: setArtifact
import org.apache.ivy.core.module.descriptor.MDArtifact; //导入依赖的package包/类
protected void setArtifact(MDArtifact artifact) {
this.artifact = artifact;
}
开发者ID:apache,项目名称:ant-ivy,代码行数:4,代码来源:XmlModuleDescriptorParser.java
示例14: setUp
import org.apache.ivy.core.module.descriptor.MDArtifact; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
// reset test case state.
resetCounters();
// this ivy settings should configure an InstrumentedResolver, PrePublishTrigger, and
// PostPublishTrigger
// (see inner classes below).
ivy = Ivy.newInstance();
ivy.configure(PublishEventsTest.class.getResource("ivysettings-publisheventstest.xml"));
ivy.pushContext();
publishEngine = ivy.getPublishEngine();
// setup dummy ivy and data files to test publishing. since we're testing the engine and not
// the resolver,
// we don't really care whether the file actually gets published. we just want to make sure
// that the engine calls the correct methods in the correct order, and fires required
// events.
ivyFile = new File("test/java/org/apache/ivy/core/publish/ivy-1.0-dev.xml");
assertTrue("path to ivy file not found in test environment", ivyFile.exists());
// the contents of the data file don't matter.
dataFile = File.createTempFile("ivydata", ".jar");
dataFile.deleteOnExit();
publishModule = XmlModuleDescriptorParser.getInstance().parseDescriptor(ivy.getSettings(),
ivyFile.toURI().toURL(), false);
// always use the same source data file, no pattern substitution is required.
publishSources = Collections.singleton(dataFile.getAbsolutePath());
// always use the same ivy file, no pattern substitution is required.
publishOptions = new PublishOptions();
publishOptions.setSrcIvyPattern(ivyFile.getAbsolutePath());
// set up our expectations for the test. these variables will
// be checked by the resolver and triggers during publication.
dataArtifact = publishModule.getAllArtifacts()[0];
assertEquals("sanity check", "foo", dataArtifact.getName());
ivyArtifact = MDArtifact.newIvyArtifact(publishModule);
expectedPublications = new HashMap<>();
expectedPublications.put(dataArtifact.getId(), new PublishTestCase(dataArtifact, dataFile,
true));
expectedPublications.put(ivyArtifact.getId(), new PublishTestCase(ivyArtifact, ivyFile,
true));
assertEquals("hashCode sanity check: two artifacts expected during publish", 2,
expectedPublications.size());
// push the TestCase instance onto the context stack, so that our
// triggers and resolver instances can interact with it it.
IvyContext.getContext().push(PublishEventsTest.class.getName(), this);
}
开发者ID:apache,项目名称:ant-ivy,代码行数:51,代码来源:PublishEventsTest.java
示例15: doExecute
import org.apache.ivy.core.module.descriptor.MDArtifact; //导入依赖的package包/类
@Override
public void doExecute() throws BuildException {
prepareAndCheck();
DefaultModuleDescriptor md = (DefaultModuleDescriptor) getResolvedReport().getModuleDescriptor();
// this is a published artifact
String artName = getSettings().substitute(getName());
artName = artName == null ? md.getModuleRevisionId().getName() : artName;
String artType = getSettings().substitute(getType());
artType = artType == null ? "jar" : artType;
String artExt = getSettings().substitute(getExt());
artExt = artExt != null ? artExt : artType;
Map<String, String> extraAttributes = new HashMap<String, String>();
if (getClassifier() != null) {
md.addExtraAttributeNamespace("m", "http://ant.apache.org/ivy/maven");
extraAttributes.put("m:classifier", getClassifier());
}
MDArtifact artifact = new MDArtifact(md, artName, artType, artExt, null, extraAttributes);
String[] configurations = getConfs().split(",");
for (String configuration : configurations) {
if ("*".equals(configuration)) {
String[] declaredConfs = md.getConfigurationsNames();
for (String declaredConf : declaredConfs) {
artifact.addConfiguration(declaredConf);
md.addArtifact(declaredConf, artifact);
}
} else {
// create configuration if it doesn't exist
if (md.getConfiguration(configuration) == null) {
Configuration generatedConfiguration = new Configuration(configuration);
md.addConfiguration(generatedConfiguration);
}
artifact.addConfiguration(configuration);
md.addArtifact(configuration, artifact);
}
}
ResolutionCacheManager cacheManager = getSettings().getResolutionCacheManager();
File ivyFileInCache = cacheManager.getResolvedIvyFileInCache(md.getResolvedModuleRevisionId());
try {
XmlModuleDescriptorWriter.write(md, ivyFileInCache);
} catch (IOException e) {
throw new BuildException("Can't register specified artifact", e);
}
}
开发者ID:apache,项目名称:ant-easyant-core,代码行数:47,代码来源:RegisterArtifact.java
注:本文中的org.apache.ivy.core.module.descriptor.MDArtifact类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论