本文整理汇总了Java中org.sonatype.aether.artifact.Artifact.getArtifactId方法的典型用法代码示例。如果您正苦于以下问题:Java Artifact.getArtifactId方法的具体用法?Java Artifact.getArtifactId怎么用?Java Artifact.getArtifactId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sonatype.aether.artifact.Artifact
的用法示例。
在下文中一共展示了Artifact.getArtifactId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBundleName
import org.sonatype.aether.artifact.Artifact; //导入方法依赖的package包/类
@Override
public String getBundleName(Artifact artifact)
{
//return artifact.getGroupId() + " " + artifact.getArtifactId(); // don't have access to the name
try
{
Model pom = Maven.getModel(artifact);
String name = pom.getName();
System.out.println(pom);
if(Strings.isNullOrEmpty(name))
return artifact.getArtifactId();
return name;
}
catch(ModelBuildingException | ComponentLookupException e)
{
System.err.println("Exception: " + e);
return artifact.getArtifactId(); // don't have access to the name
}
}
示例2: loadFromMvn
import org.sonatype.aether.artifact.Artifact; //导入方法依赖的package包/类
private List<File> loadFromMvn(String artifact, Collection<String> excludes)
throws RepositoryException {
Collection<String> allExclusions = new LinkedList<>();
allExclusions.addAll(excludes);
allExclusions.addAll(Arrays.asList(exclusions));
List<ArtifactResult> listOfArtifact;
listOfArtifact = getArtifactsWithDep(artifact, allExclusions);
Iterator<ArtifactResult> it = listOfArtifact.iterator();
while (it.hasNext()) {
Artifact a = it.next().getArtifact();
String gav = a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion();
for (String exclude : allExclusions) {
if (gav.startsWith(exclude)) {
it.remove();
break;
}
}
}
List<File> files = new LinkedList<>();
for (ArtifactResult artifactResult : listOfArtifact) {
files.add(artifactResult.getArtifact().getFile());
logger.debug("load {}", artifactResult.getArtifact().getFile().getAbsolutePath());
}
return files;
}
示例3: getMetadata
import org.sonatype.aether.artifact.Artifact; //导入方法依赖的package包/类
public static Metadata getMetadata(RepositorySystem system, RepositorySystemSession session, Artifact artifact)
{
Metadata metadata = new DefaultMetadata(
artifact.getGroupId(),
artifact.getArtifactId(),
artifact.getVersion(),
artifact.getArtifactId() + "-" + artifact.getBaseVersion() + ".pom",
Metadata.Nature.RELEASE_OR_SNAPSHOT);
MetadataRequest request = new MetadataRequest(metadata, central(), null);
MetadataResult result = system.resolveMetadata(session, Collections.singleton(request)).get(0);
return result.getMetadata();
}
示例4: Key
import org.sonatype.aether.artifact.Artifact; //导入方法依赖的package包/类
public Key( RepositorySystemSession session, VersionRequest request )
{
Artifact artifact = request.getArtifact();
groupId = artifact.getGroupId();
artifactId = artifact.getArtifactId();
classifier = artifact.getClassifier();
extension = artifact.getExtension();
version = artifact.getVersion();
localRepo = session.getLocalRepository().getBasedir();
workspace = CacheUtils.getWorkspace( session );
repositories = new ArrayList<RemoteRepository>( request.getRepositories().size() );
boolean repoMan = false;
for ( RemoteRepository repository : request.getRepositories() )
{
if ( repository.isRepositoryManager() )
{
repoMan = true;
repositories.addAll( repository.getMirroredRepositories() );
}
else
{
repositories.add( repository );
}
}
context = repoMan ? request.getRequestContext() : "";
int hash = 17;
hash = hash * 31 + groupId.hashCode();
hash = hash * 31 + artifactId.hashCode();
hash = hash * 31 + classifier.hashCode();
hash = hash * 31 + extension.hashCode();
hash = hash * 31 + version.hashCode();
hash = hash * 31 + localRepo.hashCode();
hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories );
hashCode = hash;
}
示例5: writeMetadata
import org.sonatype.aether.artifact.Artifact; //导入方法依赖的package包/类
private static void writeMetadata(Artifact a, File repository) {
Versioning v = new Versioning();
// while multiple POMs get downloaded for the same groupId+artifactId,
// there'll be only one jar for each groupId+artifactId, so we just need
// to record that
v.setRelease(a.getVersion());
v.setLatest(a.getVersion());
v.addVersion(a.getVersion());
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata(
new DefaultArtifact(a.getGroupId(), a.getArtifactId(),
VersionRange.createFromVersion(a.getVersion()),
null, a.getExtension(), null,new DefaultArtifactHandler()),v );
File metadataFile = new File(repository,
a.getGroupId().replace('.', '/')+"/" +
a.getArtifactId() +"/maven-metadata.xml");
MetadataXpp3Writer metadataWriter = new MetadataXpp3Writer();
Writer writer = null;
try {
writer = new FileWriter(metadataFile);
metadataWriter.write(writer, metadata.getMetadata());
} catch (IOException e) {
throw new Error("Error writing artifact metdata.", e);
} finally {
IOUtil.close(writer);
}
}
示例6: findArtifact
import org.sonatype.aether.artifact.Artifact; //导入方法依赖的package包/类
@Override
public File findArtifact(Artifact artifact) {
return super.findArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion(), artifact.getExtension(), artifact.getClassifier());
}
示例7: findVersions
import org.sonatype.aether.artifact.Artifact; //导入方法依赖的package包/类
@Override
public List<String> findVersions(Artifact artifact) {
return super.findVersions(artifact.getGroupId(), artifact.getArtifactId());
}
示例8: loadFromMvn
import org.sonatype.aether.artifact.Artifact; //导入方法依赖的package包/类
private List<String> loadFromMvn(String artifact, Collection<String> excludes,
boolean addSparkContext) throws Exception {
List<String> loadedLibs = new LinkedList<String>();
Collection<String> allExclusions = new LinkedList<String>();
allExclusions.addAll(excludes);
allExclusions.addAll(Arrays.asList(exclusions));
List<ArtifactResult> listOfArtifact;
listOfArtifact = getArtifactsWithDep(artifact, allExclusions);
Iterator<ArtifactResult> it = listOfArtifact.iterator();
while (it.hasNext()) {
Artifact a = it.next().getArtifact();
String gav = a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion();
for (String exclude : allExclusions) {
if (gav.startsWith(exclude)) {
it.remove();
break;
}
}
}
List<URL> newClassPathList = new LinkedList<URL>();
List<File> files = new LinkedList<File>();
for (ArtifactResult artifactResult : listOfArtifact) {
logger.info("Load " + artifactResult.getArtifact().getGroupId() + ":"
+ artifactResult.getArtifact().getArtifactId() + ":"
+ artifactResult.getArtifact().getVersion());
newClassPathList.add(artifactResult.getArtifact().getFile().toURI().toURL());
files.add(artifactResult.getArtifact().getFile());
loadedLibs.add(artifactResult.getArtifact().getGroupId() + ":"
+ artifactResult.getArtifact().getArtifactId() + ":"
+ artifactResult.getArtifact().getVersion());
}
intp.global().new Run();
if (sc.version().startsWith("1.1")) {
updateRuntimeClassPath_1_x(newClassPathList.toArray(new URL[0]));
} else {
updateRuntimeClassPath_2_x(newClassPathList.toArray(new URL[0]));
}
updateCompilerClassPath(newClassPathList.toArray(new URL[0]));
if (addSparkContext) {
for (File f : files) {
sc.addJar(f.getAbsolutePath());
}
}
return loadedLibs;
}
示例9: loadFromMvn
import org.sonatype.aether.artifact.Artifact; //导入方法依赖的package包/类
private List<String> loadFromMvn(String artifact, Collection<String> excludes,
boolean addSparkContext) throws Exception {
List<String> loadedLibs = new LinkedList<>();
Collection<String> allExclusions = new LinkedList<>();
allExclusions.addAll(excludes);
allExclusions.addAll(Arrays.asList(exclusions));
List<ArtifactResult> listOfArtifact;
listOfArtifact = getArtifactsWithDep(artifact, allExclusions);
Iterator<ArtifactResult> it = listOfArtifact.iterator();
while (it.hasNext()) {
Artifact a = it.next().getArtifact();
String gav = a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion();
for (String exclude : allExclusions) {
if (gav.startsWith(exclude)) {
it.remove();
break;
}
}
}
List<URL> newClassPathList = new LinkedList<>();
List<File> files = new LinkedList<>();
for (ArtifactResult artifactResult : listOfArtifact) {
logger.info("Load " + artifactResult.getArtifact().getGroupId() + ":"
+ artifactResult.getArtifact().getArtifactId() + ":"
+ artifactResult.getArtifact().getVersion());
newClassPathList.add(artifactResult.getArtifact().getFile().toURI().toURL());
files.add(artifactResult.getArtifact().getFile());
loadedLibs.add(artifactResult.getArtifact().getGroupId() + ":"
+ artifactResult.getArtifact().getArtifactId() + ":"
+ artifactResult.getArtifact().getVersion());
}
global.new Run();
if (sc.version().startsWith("1.1")) {
updateRuntimeClassPath_1_x(newClassPathList.toArray(new URL[0]));
} else {
updateRuntimeClassPath_2_x(newClassPathList.toArray(new URL[0]));
}
updateCompilerClassPath(newClassPathList.toArray(new URL[0]));
if (addSparkContext) {
for (File f : files) {
sc.addJar(f.getAbsolutePath());
}
}
return loadedLibs;
}
示例10: artifactAsString
import org.sonatype.aether.artifact.Artifact; //导入方法依赖的package包/类
private String artifactAsString(Artifact artifact) {
return artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getVersion();
}
示例11: getSymbolicName
import org.sonatype.aether.artifact.Artifact; //导入方法依赖的package包/类
@Override
public String getSymbolicName(Artifact artifact)
{
if(artifact.getGroupId().indexOf('.') == -1)
{
// Find the first package with classes in it
try(JarFile jar = new JarFile(artifact.getFile())) // commons-logging:commons-logging -> org.apache.commons.logging
{
List<String> contents = new ArrayList<>();
Enumeration<JarEntry> entries = jar.entries();
while(entries.hasMoreElements())
{
JarEntry entry = entries.nextElement();
contents.add(entry.getName());
}
// sort by number of slashes
Collections.sort(contents, PATH_COMPONENTS);
for(String path : contents)
{
if(path.endsWith(".class"))
{
path = path.substring(0, path.lastIndexOf('/')).replace('/', '.');
if(path.startsWith("/"))
{
path = path.substring(1);
}
return path;
}
}
}
catch (IOException e)
{
return null;
}
}
else if(Iterables.getLast(Splitter.on('.').split(artifact.getGroupId())).equals(artifact.getArtifactId()))
{
return artifact.getGroupId(); // org.apache.maven:maven -> org.apache.maven
}
else
{
String gidEnd = Iterables.getLast(Splitter.on('.').split(artifact.getGroupId()));
if(Iterables.getFirst(Splitter.on('.').split(artifact.getArtifactId()), null).equals(gidEnd))
{
// org.apache.maven:maven-core -> org.apache.maven.core
return artifact.getGroupId() + "." + PUNCTUATION.trimFrom(artifact.getArtifactId().substring(gidEnd.length()));
}
else
{
return artifact.getGroupId() + "." + artifact.getArtifactId(); // groupId + "." + artifactId
}
}
return null;
}
示例12: getKey
import org.sonatype.aether.artifact.Artifact; //导入方法依赖的package包/类
public static Object getKey( Artifact artifact )
{
return artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion();
}
示例13: getKey
import org.sonatype.aether.artifact.Artifact; //导入方法依赖的package包/类
public static Object getKey( Artifact artifact )
{
return artifact.getGroupId() + ':' + artifact.getArtifactId();
}