当前位置: 首页>>代码示例>>Java>>正文


Java Artifact类代码示例

本文整理汇总了Java中org.sonatype.aether.artifact.Artifact的典型用法代码示例。如果您正苦于以下问题:Java Artifact类的具体用法?Java Artifact怎么用?Java Artifact使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Artifact类属于org.sonatype.aether.artifact包,在下文中一共展示了Artifact类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: publishArtifacts

import org.sonatype.aether.artifact.Artifact; //导入依赖的package包/类
@Override
protected void publishArtifacts(Collection<Artifact> artifacts, RepositorySystem repositorySystem, RepositorySystemSession session) throws DeploymentException {
    RemoteRepository gradleRepo = remoteRepository;
    if (artifacts.iterator().next().isSnapshot() && remoteSnapshotRepository != null) {
        gradleRepo = remoteSnapshotRepository;
    }
    if (gradleRepo == null) {
        throw new GradleException("Must specify a repository for deployment");
    }

    org.sonatype.aether.repository.RemoteRepository aetherRepo = createRepository(gradleRepo);

    DeployRequest request = new DeployRequest();
    request.setRepository(aetherRepo);
    for (Artifact artifact : artifacts) {
        request.addArtifact(artifact);
    }

    LOGGER.info("Deploying to {}", gradleRepo.getUrl());
    repositorySystem.deploy(session, request);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:22,代码来源:MavenDeployAction.java

示例2: getArtifactsWithDep

import org.sonatype.aether.artifact.Artifact; //导入依赖的package包/类
/**
 *
 * @param dependency
 * @param excludes list of pattern can either be of the form groupId:artifactId
 * @return
 * @throws Exception
 */
public List<ArtifactResult> getArtifactsWithDep(String dependency,
    Collection<String> excludes) throws Exception {
  Artifact artifact = new DefaultArtifact(inferScalaVersion(dependency));
  DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter( JavaScopes.COMPILE );
  PatternExclusionsDependencyFilter exclusionFilter =
      new PatternExclusionsDependencyFilter(inferScalaVersion(excludes));

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));

  synchronized (repos) {
    for (RemoteRepository repo : repos) {
      collectRequest.addRepository(repo);
    }
  }
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
      DependencyFilterUtils.andFilter(exclusionFilter, classpathFlter));
  return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:27,代码来源:DependencyResolver.java

示例3: findVersions

import org.sonatype.aether.artifact.Artifact; //导入依赖的package包/类
@Override
public List<String> findVersions(Artifact artifact) {
  List<String> res = new ArrayList<String>();

  for (MavenId id : myWorkspaceMap.getAvailableIds()) {
    if (equals(id.getArtifactId(), artifact.getArtifactId()) && equals(id.getGroupId(), artifact.getGroupId())) {
      String version = id.getVersion();

      if (version != null) {
        res.add(version);
      }
    }
  }

  return res;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:Maven30WorkspaceReader.java

示例4: fetchArtifactWithDep

import org.sonatype.aether.artifact.Artifact; //导入依赖的package包/类
private List<ArtifactResult> fetchArtifactWithDep(Dependency dep)
    throws DependencyResolutionException, ArtifactResolutionException {
  Artifact artifact = new DefaultArtifact(dep.getGroupArtifactVersion());

  DependencyFilter classpathFilter = DependencyFilterUtils
      .classpathFilter(JavaScopes.COMPILE);
  PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(
      dep.getExclusions());

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new org.sonatype.aether.graph.Dependency(artifact,
      JavaScopes.COMPILE));

  collectRequest.addRepository(mavenCentral);
  collectRequest.addRepository(mavenLocal);
  for (Repository repo : repositories) {
    RemoteRepository rr = new RemoteRepository(repo.getId(), "default", repo.getUrl());
    rr.setPolicy(repo.isSnapshot(), null);
    collectRequest.addRepository(rr);
  }

  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
      DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));

  return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:27,代码来源:DependencyContext.java

示例5: getArtifactsWithDep

import org.sonatype.aether.artifact.Artifact; //导入依赖的package包/类
/**
 * @param dependency
 * @param excludes list of pattern can either be of the form groupId:artifactId
 * @return
 * @throws Exception
 */
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency,
  Collection<String> excludes) throws RepositoryException {
  Artifact artifact = new DefaultArtifact(dependency);
  DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
  PatternExclusionsDependencyFilter exclusionFilter =
          new PatternExclusionsDependencyFilter(excludes);

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));

  synchronized (repos) {
    for (RemoteRepository repo : repos) {
      collectRequest.addRepository(repo);
    }
  }
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
          DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
  try {
    return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
  } catch (NullPointerException | DependencyResolutionException ex) {
    throw new RepositoryException(
            String.format("Cannot fetch dependencies for %s", dependency), ex);
  }
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:32,代码来源:DependencyResolver.java

示例6: getArtifactsWithDep

import org.sonatype.aether.artifact.Artifact; //导入依赖的package包/类
/**
 * @param dependency
 * @param excludes list of pattern can either be of the form groupId:artifactId
 * @return
 * @throws Exception
 */
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency,
    Collection<String> excludes) throws Exception {
  Artifact artifact = new DefaultArtifact(inferScalaVersion(dependency));
  DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
  PatternExclusionsDependencyFilter exclusionFilter =
      new PatternExclusionsDependencyFilter(inferScalaVersion(excludes));

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));

  synchronized (repos) {
    for (RemoteRepository repo : repos) {
      collectRequest.addRepository(repo);
    }
  }
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
      DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
  return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:27,代码来源:SparkDependencyResolver.java

示例7: discoverPlugins

import org.sonatype.aether.artifact.Artifact; //导入依赖的package包/类
public static Set<String> discoverPlugins(Artifact artifact, ClassLoader classLoader)
        throws IOException
{
    if (!artifact.getExtension().equals("presto-plugin")) {
        throw new RuntimeException("Unexpected extension for main artifact: " + artifact);
    }

    File file = artifact.getFile();
    if (!file.getPath().endsWith("/target/classes")) {
        throw new RuntimeException("Unexpected file for main artifact: " + file);
    }
    if (!file.isDirectory()) {
        throw new RuntimeException("Main artifact file is not a directory: " + file);
    }

    if (new File(file, SERVICES_FILE).exists()) {
        return ImmutableSet.of();
    }

    return listClasses(file.toPath()).stream()
            .filter(name -> classInterfaces(name, classLoader).contains(Plugin.class.getName()))
            .collect(toImmutableSet());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:24,代码来源:PluginDiscovery.java

示例8: collectLibraryDependencies

import org.sonatype.aether.artifact.Artifact; //导入依赖的package包/类
/**
   * Collect the dependencies to other libraries that are not already collected by modules the current
   * module depends on.
   *
   * @param node
   * @param currentModule
   */
  private void collectLibraryDependencies(DependencyNode node, Artifact currentModule) {
String groupId = node.getDependency().getArtifact().getGroupId();
      String artifactId = node.getDependency().getArtifact().getArtifactId();
      if(!isPackDependency(groupId, artifactId)) {
          // first check if the current artifact is already covered by a module the current module depends on
          for(Artifact dependentArtifact : moduleDependencies.get(currentModule)) {
              if(moduleLibraries.containsKey(dependentArtifact) &&
                      moduleLibraries.get(dependentArtifact).contains(node.getDependency().getArtifact())) {
                  return;
              }
          }

          // collect the current dependency for the module
          moduleLibraries.get(currentModule).add(node.getDependency().getArtifact());

          for(DependencyNode child : node.getChildren()) {
              collectLibraryDependencies(child, currentModule);
          }
      }
  }
 
开发者ID:apache,项目名称:marmotta,代码行数:28,代码来源:RefPackMojo.java

示例9: getArtifactModel

import org.sonatype.aether.artifact.Artifact; //导入依赖的package包/类
private Model getArtifactModel(Artifact artifact) {
    org.apache.maven.artifact.Artifact mavenArtifact = artifactFactory.createArtifact(artifact.getGroupId(),artifact.getArtifactId(),artifact.getVersion(),"runtime",artifact.getExtension());

    DefaultProjectBuildingRequest req = new DefaultProjectBuildingRequest();
    req.setRepositorySession(session);
    req.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_STRICT);

    try {
        ProjectBuildingResult res = projectBuilder.build(mavenArtifact, req);

        return res.getProject().getModel();
    } catch (ProjectBuildingException e) {
        getLog().warn("error building artifact model for artifact "+artifact,e);
        return null;
    }

}
 
开发者ID:apache,项目名称:marmotta,代码行数:18,代码来源:RefPackMojo.java

示例10: resolveArtifacts

import org.sonatype.aether.artifact.Artifact; //导入依赖的package包/类
private List<Artifact> resolveArtifacts(DependencyRequest dependencyRequest)
{
    DependencyResult dependencyResult;
    try {
        dependencyResult = repositorySystem.resolveDependencies(repositorySystemSession, dependencyRequest);
    }
    catch (DependencyResolutionException e) {
        dependencyResult = e.getResult();
    }
    List<ArtifactResult> artifactResults = dependencyResult.getArtifactResults();
    List<Artifact> artifacts = new ArrayList<>(artifactResults.size());
    for (ArtifactResult artifactResult : artifactResults) {
        if (artifactResult.isMissing()) {
            artifacts.add(artifactResult.getRequest().getArtifact());
        }
        else {
            artifacts.add(artifactResult.getArtifact());
        }
    }

    return Collections.unmodifiableList(artifacts);
}
 
开发者ID:airlift,项目名称:resolver,代码行数:23,代码来源:ArtifactResolver.java

示例11: toString

import org.sonatype.aether.artifact.Artifact; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public String toString() {
    final StringBuilder text = new StringBuilder();
    text.append(
        Logger.format(
            "%s:%s:%s:%d",
            this.art.getGroupId(),
            this.art.getArtifactId(),
            this.art.getVersion(),
            this.exclusions.size()
        )
    );
    try {
        for (final Artifact child : this.children()) {
            text.append("\n  ").append(child);
            if (this.excluded(child)) {
                text.append(" (excluded)");
            }
        }
    } catch (final DependencyResolutionException ex) {
        text.append(' ').append(ex);
    }
    return text.toString();
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:28,代码来源:RootArtifact.java

示例12: resolveModel

import org.sonatype.aether.artifact.Artifact; //导入依赖的package包/类
public ModelSource resolveModel( String groupId, String artifactId, String version )
    throws UnresolvableModelException
{
    Artifact pomArtifact = new DefaultArtifact( groupId, artifactId, "", "pom", version );

    try
    {
        ArtifactRequest request = new ArtifactRequest( pomArtifact, repositories, context );
        request.setTrace( trace );
        pomArtifact = resolver.resolveArtifact( session, request ).getArtifact();
    }
    catch ( ArtifactResolutionException e )
    {
        throw new UnresolvableModelException( e.getMessage(), groupId, artifactId, version, e );
    }

    File pomFile = pomArtifact.getFile();

    return new FileModelSource( pomFile );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:21,代码来源:DefaultModelResolver.java

示例13: prepare

import org.sonatype.aether.artifact.Artifact; //导入依赖的package包/类
public Collection<? extends Metadata> prepare( Collection<? extends Artifact> artifacts )
{
    for ( Artifact artifact : artifacts )
    {
        if ( artifact.isSnapshot() )
        {
            Object key = RemoteSnapshotMetadata.getKey( artifact );
            RemoteSnapshotMetadata snapshotMetadata = snapshots.get( key );
            if ( snapshotMetadata == null )
            {
                snapshotMetadata = new RemoteSnapshotMetadata( artifact, legacyFormat );
                snapshots.put( key, snapshotMetadata );
            }
            snapshotMetadata.bind( artifact );
        }
    }

    return snapshots.values();
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:20,代码来源:RemoteSnapshotMetadataGenerator.java

示例14: isSafelyCacheable

import org.sonatype.aether.artifact.Artifact; //导入依赖的package包/类
private boolean isSafelyCacheable( RepositorySystemSession session, Artifact artifact )
{
    /*
     * The workspace/reactor is in flux so we better not assume definitive information for any of its
     * artifacts/projects.
     */

    WorkspaceReader workspace = session.getWorkspaceReader();
    if ( workspace == null )
    {
        return true;
    }

    Artifact pomArtifact = ArtifactDescriptorUtils.toPomArtifact( artifact );

    return workspace.findArtifact( pomArtifact ) == null;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:18,代码来源:DefaultVersionResolver.java

示例15: finish

import org.sonatype.aether.artifact.Artifact; //导入依赖的package包/类
public Collection<? extends Metadata> finish( Collection<? extends Artifact> artifacts )
{
    for ( Artifact artifact : artifacts )
    {
        Object key = VersionsMetadata.getKey( artifact );
        if ( processedVersions.get( key ) == null )
        {
            VersionsMetadata versionsMetadata = versions.get( key );
            if ( versionsMetadata == null )
            {
                versionsMetadata = new VersionsMetadata( artifact );
                versions.put( key, versionsMetadata );
            }
        }
    }

    return versions.values();
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:19,代码来源:VersionsMetadataGenerator.java


注:本文中的org.sonatype.aether.artifact.Artifact类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。