本文整理汇总了Java中org.eclipse.aether.util.artifact.SubArtifact类的典型用法代码示例。如果您正苦于以下问题:Java SubArtifact类的具体用法?Java SubArtifact怎么用?Java SubArtifact使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SubArtifact类属于org.eclipse.aether.util.artifact包,在下文中一共展示了SubArtifact类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: publish
import org.eclipse.aether.util.artifact.SubArtifact; //导入依赖的package包/类
/**
* @param descriptor an {@link Artifact}, holding the maven coordinates for the published files
* less the extension that is to be derived from the files. The {@code descriptor} itself will
* not be published as is, and the {@link File} attached to it (if any) will be ignored.
* @param toPublish {@link File}(s) to be published using the given coordinates. The filename
* extension of each given file will be used as a maven "extension" coordinate
*/
public DeployResult publish(Artifact descriptor, List<File> toPublish)
throws DeploymentException {
String providedExtension = descriptor.getExtension();
if (!providedExtension.isEmpty()) {
LOG.warn(
"Provided extension %s of artifact %s to be published will be ignored. The extensions "
+ "of the provided file(s) will be used",
providedExtension, descriptor);
}
List<Artifact> artifacts = new ArrayList<>(toPublish.size());
for (File file : toPublish) {
artifacts.add(
new SubArtifact(
descriptor,
descriptor.getClassifier(),
Files.getFileExtension(file.getAbsolutePath()),
file));
}
return publish(artifacts);
}
示例2: deploy
import org.eclipse.aether.util.artifact.SubArtifact; //导入依赖的package包/类
@Override
public void deploy(Rugs operationsAndHandlers, ArtifactSource source,
ArtifactDescriptor artifact, File root, String clientId) throws IOException {
String zipFileName = artifact.artifact() + "-" + artifact.version() + "."
+ artifact.extension().toString().toLowerCase();
File archive = new File(root, ".atomist/target/" + zipFileName);
Manifest manifest = ManifestFactory.read(source);
manifest.setGroup(artifact.group());
manifest.setArtifact(artifact.artifact());
manifest.setVersion(artifact.version());
source = generateMetadata(operationsAndHandlers, artifact, source, manifest, clientId);
writeArtifactSourceToZip(archive, source);
File pomFile = writePom(manifest, artifact, root);
File metadataFile = writeMetadataFile(source, artifact, root);
RepositorySystem system = new MavenConfiguration().repositorySystem();
RepositorySystemSession session = createRepositorySession();
Artifact zip = new DefaultArtifact(manifest.group(), manifest.artifact(), "",
artifact.extension().toString().toLowerCase(), manifest.version());
zip = zip.setFile(archive);
Artifact pom = new SubArtifact(zip, "", "pom");
pom = pom.setFile(pomFile);
Artifact metadata = new SubArtifact(zip, "metadata", "json");
metadata = metadata.setFile(metadataFile);
doWithRepositorySession(system, session, source, manifest, zip, pom, metadata);
}
示例3: installBundleWithJar
import org.eclipse.aether.util.artifact.SubArtifact; //导入依赖的package包/类
public void installBundleWithJar(Artifact pomArtifact, Artifact bundleArtifact,
List<? extends Class<?>> containedClasses) throws IOException, RepositoryException {
Path jarFile = tempDir.resolve(pomArtifact.getArtifactId() + '-' + pomArtifact.getVersion() + ".jar");
createDummyJar(jarFile, containedClasses);
Artifact jarArtifact = new SubArtifact(pomArtifact, "", "jar", jarFile.toFile());
InstallRequest installRequest = new InstallRequest()
.addArtifact(pomArtifact)
.addArtifact(bundleArtifact)
.addArtifact(jarArtifact);
repositorySystem.install(repositorySystemSession, installRequest);
}
示例4: testMvn1
import org.eclipse.aether.util.artifact.SubArtifact; //导入依赖的package包/类
@Test
public void testMvn1 () throws Exception
{
final ChannelTester ct = ChannelTester.create ( getWebContext (), "m1" );
ct.addAspect ( "mvn" );
ct.addAspect ( "maven.repo" );
ct.assignDeployGroup ( "m1" );
final String key = ct.getDeployKeys ().iterator ().next (); // get first
assertNotNull ( key );
final RepositorySystem system = MavenUtil.newRepositorySystem ();
final RepositorySystemSession session = MavenUtil.newRepositorySystemSession ( system );
Artifact jarArtifact = new DefaultArtifact ( "org.eclipse.packagedrone.testing", "test.felix1", "", "jar", "0.0.1-SNAPSHOT" );
jarArtifact = jarArtifact.setFile ( new File ( TEST_1_JAR ) );
Artifact pomArtifact = new SubArtifact ( jarArtifact, "", "pom" );
pomArtifact = pomArtifact.setFile ( new File ( TEST_1_POM ) );
Artifact srcArtifact = new SubArtifact ( jarArtifact, "sources", "jar" );
srcArtifact = srcArtifact.setFile ( new File ( TEST_1_SOURCES_JAR ) );
final AuthenticationBuilder ab = new AuthenticationBuilder ();
ab.addUsername ( "deploy" );
ab.addPassword ( key );
final Authentication auth = ab.build ();
final RemoteRepository distRepo = new RemoteRepository.Builder ( "test", "default", resolve ( String.format ( "/maven/%s", ct.getId () ) ) ).setAuthentication ( auth ).build ();
final DeployRequest deployRequest = new DeployRequest ();
deployRequest.addArtifact ( jarArtifact ).addArtifact ( pomArtifact ).addArtifact ( srcArtifact );
deployRequest.setRepository ( distRepo );
system.deploy ( session, deployRequest );
testUrl ( String.format ( "/maven/%s", ct.getId () ) ); // index page
// FIXME: check more data
}
示例5: testMvn1
import org.eclipse.aether.util.artifact.SubArtifact; //导入依赖的package包/类
@Test
public void testMvn1 () throws Exception
{
final ChannelTester ct = ChannelTester.create ( getWebContext (), "m1" );
ct.addAspect ( "mvn" );
ct.addAspect ( "maven.repo" );
ct.assignDeployGroup ( "m1" );
final String key = ct.getDeployKeys ().iterator ().next (); // get first
assertNotNull ( key );
final RepositorySystem system = MavenUtil.newRepositorySystem ();
final RepositorySystemSession session = MavenUtil.newRepositorySystemSession ( system );
Artifact jarArtifact = new DefaultArtifact ( "de.dentrassi", "test.bundle1", "", "jar", "1.0.0-SNAPSHOT" );
jarArtifact = jarArtifact.setFile ( new File ( "data/mvn/test.bundle1-1.0.0-SNAPSHOT.jar" ) );
Artifact pomArtifact = new SubArtifact ( jarArtifact, "", "pom" );
pomArtifact = pomArtifact.setFile ( new File ( "data/mvn/test.bundle1-1.0.0-SNAPSHOT.pom" ) );
Artifact srcArtifact = new SubArtifact ( jarArtifact, "sources", "jar" );
srcArtifact = srcArtifact.setFile ( new File ( "data/mvn/test.bundle1-1.0.0-SNAPSHOT-sources.jar" ) );
final AuthenticationBuilder ab = new AuthenticationBuilder ();
ab.addUsername ( "deploy" );
ab.addPassword ( key );
final Authentication auth = ab.build ();
final RemoteRepository distRepo = new RemoteRepository.Builder ( "test", "default", resolve ( String.format ( "/maven/%s", ct.getId () ) ) ).setAuthentication ( auth ).build ();
final DeployRequest deployRequest = new DeployRequest ();
deployRequest.addArtifact ( jarArtifact ).addArtifact ( pomArtifact ).addArtifact ( srcArtifact );
deployRequest.setRepository ( distRepo );
system.deploy ( session, deployRequest );
testUrl ( String.format ( "/maven/%s", ct.getId () ) ); // index page
// FIXME: check more data
}
示例6: installArtifact
import org.eclipse.aether.util.artifact.SubArtifact; //导入依赖的package包/类
public void installArtifact(String groupId, String artifactId, String ext, String classifier, String version, File artifactFile, File pomFile) throws Exception {
Artifact jarArtifact = new DefaultArtifact(groupId, artifactId, classifier, ext, version);
jarArtifact = jarArtifact.setFile(artifactFile);
Artifact pomArtifact = new SubArtifact(jarArtifact, "", "pom");
pomArtifact = pomArtifact.setFile(pomFile);
InstallRequest installRequest = new InstallRequest();
installRequest.addArtifact(jarArtifact ).addArtifact( pomArtifact );
InstallResult result = system.install(session, installRequest);
if (!result.getArtifacts().contains(jarArtifact)) {
throw new AssertionError("Could not install jar " + jarArtifact);
}
if (!result.getArtifacts().contains(pomArtifact)) {
throw new AssertionError("Could not install pom " + jarArtifact);
}
}
示例7: downloadSources
import org.eclipse.aether.util.artifact.SubArtifact; //导入依赖的package包/类
private void downloadSources(Artifact artifact, Path project, Prebuilt library)
throws IOException {
Artifact srcs = new SubArtifact(artifact, "sources", "jar");
try {
Path relativePath = resolveArtifact(srcs, project);
library.setSourceJar(relativePath);
} catch (ArtifactResolutionException e) {
System.err.println("Skipping sources for: " + srcs);
}
}
示例8: installBundle
import org.eclipse.aether.util.artifact.SubArtifact; //导入依赖的package包/类
/**
* Installs an Aether artifact representing a CloudKeeper bundle with the given declarations.
*
* <p>The group id of artifacts installed with this method is always {@link #GROUP_ID}. Likewise, the version is
* always {@link #VERSION}.
*
* @param artifactId artifact id for new Aether artifact
* @param declarationClasses DSL classes of plugin declarations that the new bundle will consist of
* @param dependencies Artifact ids of CloudKeeper bundle dependencies (previously installed with this
* method). Group id and version are always assumed to be {@link #GROUP_ID} and {@link #VERSION}, respectively.
* @throws IOException if an I/O exception occurs
* @throws LinkerException if the new CloudKeeper bundle cannot be linked with the specified dependencies
* @throws RepositoryException if an Aether operation (such as retrieving dependencies or installing the new
* artifact) fails
*/
public void installBundle(String artifactId, List<? extends Class<?>> declarationClasses,
String... dependencies) throws IOException, LinkerException, RepositoryException {
Objects.requireNonNull(declarationClasses);
Objects.requireNonNull(artifactId);
Objects.requireNonNull(dependencies);
List<String> dependenciesList = Arrays.asList(dependencies);
Map<Name, MutablePackage> packageMap = new LinkedHashMap<>();
ModuleFactory moduleFactory = ModuleFactory.getDefault();
for (Class<?> declarationClass: declarationClasses) {
getOrCreatePackage(declarationClass.getPackage(), packageMap)
.getDeclarations()
.add(moduleFactory.loadDeclaration(declarationClass));
}
MutableBundle unverifiedBundle = new MutableBundle()
.setBundleIdentifier(
Bundles.bundleIdentifierFromMaven(GROUP_ID, artifactId, VERSION))
.setCreationTime(new Date())
.setCloudKeeperVersion(BuildInformation.PROJECT_VERSION)
.setPackages(new ArrayList<>(packageMap.values()));
try {
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
// Verify that bundle can be linked
List<MutableBundle> dependencyBundles = loadDependencyDeclarations(dependenciesList);
List<MutableBundle> bundles = new ArrayList<>(1 + dependencyBundles.size());
bundles.add(unverifiedBundle);
bundles.addAll(dependencyBundles);
LinkerOptions linkerOptions = new LinkerOptions.Builder()
.setMarshalValues(true)
.build();
RuntimeRepository repository = Linker.createRepository(bundles, linkerOptions);
MutableBundle verifiedBundle = MutableBundle.copyOf(repository.getBundles().get(0));
Path bundleFile = tempDir.resolve(artifactId + '-' + VERSION + ".ckbundle");
marshaller.marshal(verifiedBundle, bundleFile.toFile());
Path pomFile = tempDir.resolve(artifactId + '-' + VERSION + ".pom");
generatePOM(pomFile, GROUP_ID, artifactId, dependenciesList);
Artifact pomArtifact = new DefaultArtifact(
GROUP_ID, artifactId, "", "pom", VERSION.toString(), null, pomFile.toFile()
);
Artifact bundleArtifact = new SubArtifact(pomArtifact, "", "ckbundle", bundleFile.toFile());
installBundleWithJar(pomArtifact, bundleArtifact, declarationClasses);
} catch (JAXBException | XMLStreamException exception) {
throw new IllegalStateException("Unexpected exception!", exception);
}
}
示例9: deployArtifact
import org.eclipse.aether.util.artifact.SubArtifact; //导入依赖的package包/类
private void deployArtifact(final GAV gav,
final String pomXML,
final File jarFile,
final boolean includeAdditionalRepositories) {
//Write pom.xml to temporary file for deployment
final File pomXMLFile = new File(System.getProperty("java.io.tmpdir"),
toFileName(gav,
"pom.xml"));
try {
writeStringIntoFile(pomXML,
pomXMLFile);
//JAR Artifact
Artifact jarArtifact = new DefaultArtifact(gav.getGroupId(),
gav.getArtifactId(),
"jar",
gav.getVersion());
jarArtifact = jarArtifact.setFile(jarFile);
//pom.xml Artifact
Artifact pomXMLArtifact = new SubArtifact(jarArtifact,
"",
"pom");
pomXMLArtifact = pomXMLArtifact.setFile(pomXMLFile);
final Artifact finalJarArtifact = jarArtifact;
final Artifact finalPomXMLArtifact = pomXMLArtifact;
this.repositories.forEach((repository) -> repository.deploy(pomXML,
finalJarArtifact,
finalPomXMLArtifact));
//Only deploy to additional repositories if required. This flag is principally for Unit Tests
if (!includeAdditionalRepositories) {
return;
}
} finally {
try {
pomXMLFile.delete();
} catch (Exception e) {
log.warn("Unable to remove temporary file '" + pomXMLFile.getAbsolutePath() + "'");
}
}
}
示例10: attach
import org.eclipse.aether.util.artifact.SubArtifact; //导入依赖的package包/类
/**
* Convenience method for attaching {@link SubArtifact SubArtifacts} to this Artifact.
* @param file
* @param classifier
*/
public void attach(File file, String classifier) {
subs.add(new SubArtifact(this, classifier, FilenameUtils.getExtension(file.getName()), file));
}