本文整理汇总了Java中org.apache.ivy.core.module.descriptor.DefaultArtifact类的典型用法代码示例。如果您正苦于以下问题:Java DefaultArtifact类的具体用法?Java DefaultArtifact怎么用?Java DefaultArtifact使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultArtifact类属于org.apache.ivy.core.module.descriptor包,在下文中一共展示了DefaultArtifact类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: publish
import org.apache.ivy.core.module.descriptor.DefaultArtifact; //导入依赖的package包/类
public void publish(IvyNormalizedPublication publication, PublicationAwareRepository repository) {
ModuleVersionPublisher publisher = repository.createPublisher();
IvyPublicationIdentity projectIdentity = publication.getProjectIdentity();
ModuleRevisionId moduleRevisionId = IvyUtil.createModuleRevisionId(projectIdentity.getOrganisation(), projectIdentity.getModule(), projectIdentity.getRevision());
ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(moduleRevisionId);
DefaultIvyModulePublishMetaData publishMetaData = new DefaultIvyModulePublishMetaData(moduleVersionIdentifier);
try {
for (IvyArtifact publishArtifact : publication.getArtifacts()) {
Artifact ivyArtifact = createIvyArtifact(publishArtifact, moduleRevisionId);
publishMetaData.addArtifact(ivyArtifact, publishArtifact.getFile());
}
Artifact artifact = DefaultArtifact.newIvyArtifact(moduleRevisionId, null);
publishMetaData.addArtifact(artifact, publication.getDescriptorFile());
publisher.publish(publishMetaData);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例2: createIvyArtifact
import org.apache.ivy.core.module.descriptor.DefaultArtifact; //导入依赖的package包/类
public Artifact createIvyArtifact(PublishArtifact publishArtifact, ModuleRevisionId moduleRevisionId) {
Map<String, String> extraAttributes = new HashMap<String, String>();
if (GUtil.isTrue(publishArtifact.getClassifier())) {
extraAttributes.put(Dependency.CLASSIFIER, publishArtifact.getClassifier());
}
String name = publishArtifact.getName();
if (!GUtil.isTrue(name)) {
name = moduleRevisionId.getName();
}
return new DefaultArtifact(
moduleRevisionId,
publishArtifact.getDate(),
name,
publishArtifact.getType(),
publishArtifact.getExtension(),
extraAttributes);
}
示例3: publish
import org.apache.ivy.core.module.descriptor.DefaultArtifact; //导入依赖的package包/类
public void publish(IvyNormalizedPublication publication, PublicationAwareRepository repository) {
ModuleVersionPublisher publisher = repository.createPublisher();
IvyPublicationIdentity projectIdentity = publication.getProjectIdentity();
ModuleRevisionId moduleRevisionId = IvyUtil.createModuleRevisionId(projectIdentity.getOrganisation(), projectIdentity.getModule(), projectIdentity.getRevision());
ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(moduleRevisionId);
DefaultModuleVersionPublishMetaData publishMetaData = new DefaultModuleVersionPublishMetaData(moduleVersionIdentifier);
try {
for (IvyArtifact publishArtifact : publication.getArtifacts()) {
Artifact ivyArtifact = createIvyArtifact(publishArtifact, moduleRevisionId);
publishMetaData.addArtifact(ivyArtifact, publishArtifact.getFile());
}
Artifact artifact = DefaultArtifact.newIvyArtifact(moduleRevisionId, null);
publishMetaData.addArtifact(artifact, publication.getDescriptorFile());
publisher.publish(publishMetaData);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例4: analyse
import org.apache.ivy.core.module.descriptor.DefaultArtifact; //导入依赖的package包/类
public void analyse(String pattern, DependencyAnalyser depAnalyser) {
JarModuleFinder finder = new JarModuleFinder(pattern);
ModuleDescriptor[] mds = depAnalyser.analyze(finder.findJarModules());
Message.info("found " + mds.length + " modules");
for (ModuleDescriptor md : mds) {
File ivyFile = new File(IvyPatternHelper.substitute(
pattern,
DefaultArtifact.newIvyArtifact(md.getModuleRevisionId(),
md.getPublicationDate())));
try {
Message.info("generating " + ivyFile);
XmlModuleDescriptorWriter.write(md, ivyFile);
} catch (IOException e) {
Message.debug(e);
}
}
}
示例5: findIvyFileRef
import org.apache.ivy.core.module.descriptor.DefaultArtifact; //导入依赖的package包/类
@Override
public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) {
if (!isM2compatible() || !isUsepoms()) {
return null;
}
ModuleRevisionId mrid = dd.getDependencyRevisionId();
mrid = convertM2IdForResourceSearch(mrid);
final String revision = dd.getDependencyRevisionId().getRevision();
final MavenTimedSnapshotVersionMatcher.MavenSnapshotRevision snapshotRevision = MavenTimedSnapshotVersionMatcher.computeIfSnapshot(revision);
if (snapshotRevision != null) {
final ResolvedResource rres = findSnapshotDescriptor(dd, data, mrid, snapshotRevision);
if (rres != null) {
return rres;
}
}
return findResourceUsingPatterns(mrid, getIvyPatterns(),
DefaultArtifact.newPomArtifact(mrid, data.getDate()), getRMDParser(dd, data),
data.getDate());
}
示例6: putSignature
import org.apache.ivy.core.module.descriptor.DefaultArtifact; //导入依赖的package包/类
protected void putSignature(Artifact artifact, File src, String dest, boolean overwrite)
throws IOException {
SignatureGenerator gen = getSettings().getSignatureGenerator(signerName);
if (gen == null) {
throw new IllegalArgumentException("Couldn't sign the artifacts! "
+ "Unknown signer name: '" + signerName + "'");
}
File tempFile = File.createTempFile("ivytemp", gen.getExtension());
try {
gen.sign(src, tempFile);
repository.put(
DefaultArtifact.cloneWithAnotherTypeAndExt(artifact, gen.getExtension(),
artifact.getExt() + "." + gen.getExtension()), tempFile,
dest + "." + gen.getExtension(), overwrite);
} finally {
tempFile.delete();
}
}
示例7: testAbortTransaction
import org.apache.ivy.core.module.descriptor.DefaultArtifact; //导入依赖的package包/类
@Test
public void testAbortTransaction() throws Exception {
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("test");
resolver.setSettings(settings);
resolver.addIvyPattern(settings.getBaseDir()
+ "/test/repositories/1/[organisation]/[module]/[revision]/[artifact].[ext]");
resolver.addArtifactPattern(settings.getBaseDir()
+ "/test/repositories/1/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]");
ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision");
Artifact ivyArtifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml");
Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype",
"myext");
File src = new File("test/repositories/ivysettings.xml");
resolver.beginPublishTransaction(mrid, false);
resolver.publish(ivyArtifact, src, false);
resolver.publish(artifact, src, false);
resolver.abortPublishTransaction();
assertFalse(new File("test/repositories/1/myorg/mymodule/myrevision/ivy.xml").exists());
assertFalse(new File(
"test/repositories/1/myorg/mymodule/myrevision/myartifact-myrevision.myext")
.exists());
}
示例8: testUnsupportedTransaction
import org.apache.ivy.core.module.descriptor.DefaultArtifact; //导入依赖的package包/类
/**
* Publishing with transaction=true and an unsupported pattern must fail.
*
* @throws Exception if something goes wrong
*/
@Test
public void testUnsupportedTransaction() throws Exception {
expExc.expect(IllegalStateException.class);
expExc.expectMessage("transactional");
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("test");
resolver.setSettings(settings);
resolver.setTransactional("true");
resolver.addArtifactPattern(
// this pattern is not supported for transaction publish
settings.getBaseDir()
+ "/test/repositories/1/[organisation]/[module]/[artifact]-[revision].[ext]");
ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision");
Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype",
"myext");
File src = new File("test/repositories/ivysettings.xml");
resolver.beginPublishTransaction(mrid, false);
resolver.publish(artifact, src, false);
}
示例9: testUnsupportedTransaction3
import org.apache.ivy.core.module.descriptor.DefaultArtifact; //导入依赖的package包/类
/**
* Publishing with transaction=true and overwrite mode must fail.
*
* @throws Exception if something goes wrong
*/
@Test
public void testUnsupportedTransaction3() throws Exception {
expExc.expect(IllegalStateException.class);
expExc.expectMessage("transactional");
FileSystemResolver resolver = new FileSystemResolver();
resolver.setName("test");
resolver.setSettings(settings);
resolver.setTransactional("true");
resolver.addArtifactPattern(settings.getBaseDir()
+ "/test/repositories/1/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]");
ModuleRevisionId mrid = ModuleRevisionId.newInstance("myorg", "mymodule", "myrevision");
Artifact artifact = new DefaultArtifact(mrid, new Date(), "myartifact", "mytype",
"myext");
File src = new File("test/repositories/ivysettings.xml");
// overwrite transaction not supported
resolver.beginPublishTransaction(mrid, true);
resolver.publish(artifact, src, true);
}
示例10: publish
import org.apache.ivy.core.module.descriptor.DefaultArtifact; //导入依赖的package包/类
public void publish(IvyModulePublishMetadata moduleVersion) {
for (IvyModuleArtifactPublishMetadata artifactMetadata : moduleVersion.getArtifacts()) {
IvyArtifactName artifact = artifactMetadata.getArtifactName();
ModuleRevisionId moduleRevisionId = IvyUtil.createModuleRevisionId(artifactMetadata.getId().getComponentIdentifier());
Map<String, String> attributes = Collections.singletonMap("classifier", artifact.getClassifier());
Artifact ivyArtifact = new DefaultArtifact(moduleRevisionId, null, artifact.getName(), artifact.getType(), artifact.getExtension(), attributes);
collectArtifact(ivyArtifact, artifactMetadata.getFile());
}
publish();
}
示例11: ivy2aether
import org.apache.ivy.core.module.descriptor.DefaultArtifact; //导入依赖的package包/类
private static org.fedoraproject.xmvn.artifact.Artifact ivy2aether( ModuleRevisionId revision, String extension )
{
String groupId = revision.getOrganisation();
String artifactId = revision.getName();
String classifier = revision.getExtraAttribute( "classifier" );
String version = revision.getRevision();
return new org.fedoraproject.xmvn.artifact.DefaultArtifact( groupId, artifactId, extension, classifier,
version );
}
示例12: findIvyFileRef
import org.apache.ivy.core.module.descriptor.DefaultArtifact; //导入依赖的package包/类
@Override
public ResolvedResource findIvyFileRef( DependencyDescriptor depDescriptor, ResolveData data )
{
Artifact artifact = DefaultArtifact.newIvyArtifact( depDescriptor.getDependencyRevisionId(), null );
ResolutionRequest request = new ResolutionRequest();
request.setArtifact( ivy2aether( artifact.getModuleRevisionId(), "pom" ) );
ResolutionResult result = getResolver().resolve( request );
Path pomPath = result.getArtifactPath();
if ( pomPath == null )
return null;
Resource fileResource = new FileResource( new FileRepository(), pomPath.toFile() );
return new ResolvedResource( fileResource, resolvedVersion( result ) );
}
示例13: toPublishedArtifact
import org.apache.ivy.core.module.descriptor.DefaultArtifact; //导入依赖的package包/类
static Artifact toPublishedArtifact(JkIvyPublication.Artifact artifact,
ModuleRevisionId moduleId, Instant date) {
final String artifactName = JkUtilsString.isBlank(artifact.name) ? moduleId.getName()
: artifact.name;
final String extension = JkUtilsObject.firstNonNull(artifact.extension, "");
final String type = JkUtilsObject.firstNonNull(artifact.type, extension);
return new DefaultArtifact(moduleId, new Date(date.toEpochMilli()), artifactName, type, extension);
}
示例14: toPublishedMavenArtifact
import org.apache.ivy.core.module.descriptor.DefaultArtifact; //导入依赖的package包/类
private static Artifact toPublishedMavenArtifact(Path artifact, String artifactName,
String classifier, ModuleRevisionId moduleId, Instant date) {
final String extension = JkUtilsString.substringAfterLast(artifact.getFileName().toString(), ".");
final Map<String, String> extraMap;
if (classifier == null) {
extraMap = new HashMap<>();
} else {
extraMap = JkUtilsIterable.mapOf(EXTRA_PREFIX + ":classifier", classifier);
}
return new DefaultArtifact(moduleId, new Date(date.toEpochMilli()), artifactName, extension, extension, extraMap);
}
示例15: createIvyArtifact
import org.apache.ivy.core.module.descriptor.DefaultArtifact; //导入依赖的package包/类
private Artifact createIvyArtifact(IvyArtifact ivyArtifact, ModuleRevisionId moduleRevisionId) {
Map<String, String> extraAttributes = new HashMap<String, String>();
if (GUtil.isTrue(ivyArtifact.getClassifier())) {
extraAttributes.put(Dependency.CLASSIFIER, ivyArtifact.getClassifier());
}
return new DefaultArtifact(
moduleRevisionId,
null,
GUtil.elvis(ivyArtifact.getName(), moduleRevisionId.getName()),
ivyArtifact.getType(),
ivyArtifact.getExtension(),
extraAttributes);
}