org.sonatype.aether.artifact.Artifact.setVersion()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中org.sonatype.aether.artifact.Artifact.setVersion()方法的一些代码示例,展示了Artifact.setVersion()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Artifact.setVersion()方法的具体详情如下:
包路径:org.sonatype.aether.artifact.Artifact
类名称:Artifact
方法名:setVersion

Artifact.setVersion介绍

[英]Sets the version of this artifact.
[中]设置此工件的版本。

代码示例

代码示例来源:origin: sonatype/sonatype-aether

public Artifact setVersion( String version )
{
  Artifact artifact = delegate.setVersion( version );
  if ( artifact != delegate )
  {
    return newInstance( artifact );
  }
  return this;
}

代码示例来源:origin: org.eclipse.proviso/proviso-spi

public Artifact setVersion( String version )
{
  Artifact artifact = delegate.setVersion( version );
  if ( artifact != delegate )
  {
    return newInstance( artifact );
  }
  return this;
}

代码示例来源:origin: NGDATA/lilyproject

public static void write(Set<Artifact> artifacts, String targetDirectory) throws MojoExecutionException {
  RepositoryLayout m2layout = new MavenDefaultLayout();
  for (Artifact artifact : artifacts) {
    File src = artifact.getFile();
    // set the version (which could be a resolved snapshot) to the base version (which in that case would be
    // literally SNAPSHOT), because that is what lily runtime expects.
    artifact = artifact.setVersion(artifact.getBaseVersion());
    File dest = new File(targetDirectory, m2layout.getPath(artifact).getPath());
    try {
      System.out.println("Copying " + src + " to " + dest);
      FileUtils.copyFile(src, dest);
    } catch (IOException e) {
      throw new MojoExecutionException("Error copying file " + src + " to " + dest);
    }
    // Lily Runtime does not need the pom files, but let's copy them anyway, for informational purposes
    File srcPom = pomFile(src);
    File destPom = pomFile(dest);
    if (srcPom != null && srcPom.exists()) {
      try {
        FileUtils.copyFile(srcPom, destPom);
      } catch (IOException e) {
        throw new MojoExecutionException("Error copying file " + srcPom + " to " + destPom);
      }
    }
  }
}

代码示例来源:origin: org.apache.openejb/openejb-provisionning

/**
 * Tries to resolve versions = LATEST using an open range version query.
 * If it succeeds, version of artifact is set to the highest available version.
 *
 * @param session  to be used.
 * @param artifact to be used
 * @return an artifact with version set properly (highest if available)
 * @throws org.sonatype.aether.resolution.VersionRangeResolutionException
 *          in case of resolver errors.
 */
private Artifact resolveLatestVersionRange(RepositorySystemSession session, Artifact artifact)
    throws VersionRangeResolutionException {
  if (artifact.getVersion().equals("LATEST")) {
    artifact = artifact.setVersion(LATEST_VERSION_RANGE);
    VersionRangeResult versionResult = m_repoSystem.resolveVersionRange(session, new VersionRangeRequest(artifact, m_remoteRepos, null));
    if (versionResult != null) {
      Version v = versionResult.getHighestVersion();
      if (v != null) {
        artifact = artifact.setVersion(v.toString());
      } else {
        throw new VersionRangeResolutionException(versionResult, "Not highest version found for " + artifact);
      }
    }
  }
  return artifact;
}

代码示例来源:origin: org.sonatype.aether/aether-test-util

if ( cls.isAssignableFrom( ArtifactUpload.class ) )
  Artifact artifact = ( (Artifact) item ).setVersion( ( i + 1 ) + "-test" );
  obj = new ArtifactUpload( artifact, file );
    Artifact artifact = ( (Artifact) item ).setVersion( ( i + 1 ) + "-test" );
    obj = new ArtifactDownload( artifact, context, safeFile( file ), checksumPolicy );

代码示例来源:origin: sonatype/sonatype-aether

if ( cls.isAssignableFrom( ArtifactUpload.class ) )
  Artifact artifact = ( (Artifact) item ).setVersion( ( i + 1 ) + "-test" );
  obj = new ArtifactUpload( artifact, file );
    Artifact artifact = ( (Artifact) item ).setVersion( ( i + 1 ) + "-test" );
    obj = new ArtifactDownload( artifact, context, safeFile( file ), checksumPolicy );

代码示例来源:origin: org.apache.openejb/openejb-provisionning

public VersionRangeResult resolveVersions(String groupId, String artifactId, String classifier, String extension, String version) {
  final RepositorySystemSession session = newSession();
  Artifact artifact = new DefaultArtifact(groupId, artifactId, classifier, extension, version);
  if (artifact.getVersion().equals("LATEST")) {
    artifact = artifact.setVersion(LATEST_VERSION_RANGE);
  }
  final VersionRangeRequest request = new VersionRangeRequest(artifact, m_remoteRepos, null);
  try {
    return m_repoSystem.resolveVersionRange(session, request);
  } catch (VersionRangeResolutionException e) {
    final VersionRangeResult result = new VersionRangeResult(request);
    result.setVersions(Arrays.asList((Version) new VersionImpl(version)));
    return result;
  }
}

代码示例来源:origin: com.cloudbees/bees-maven-components

subRequest.setArtifact(artifact.setVersion(result.getVersion()));
if (result.getRepository() instanceof RemoteRepository) {
  subRequest.setRepositories(Collections.singletonList((RemoteRepository) result.getRepository()));

代码示例来源:origin: org.sonatype.aether/aether-impl

artifact = artifact.setVersion( versionResult.getVersion() );

代码示例来源:origin: sonatype/sonatype-aether

artifact = artifact.setVersion( versionResult.getVersion() );

代码示例来源:origin: org.sonatype.aether/aether-impl

dependency = dependency.setArtifact( artifact.setVersion( depMngt.getVersion() ) );
for ( Version version : versions )
  Artifact originalArtifact = dependency.getArtifact().setVersion( version.toString() );
  Dependency d = dependency.setArtifact( originalArtifact );

代码示例来源:origin: sonatype/sonatype-aether

dependency = dependency.setArtifact( artifact.setVersion( depMngt.getVersion() ) );
for ( Version version : versions )
  Artifact originalArtifact = dependency.getArtifact().setVersion( version.toString() );
  Dependency d = dependency.setArtifact( originalArtifact );

代码示例来源:origin: org.sonatype.aether/aether-impl

root = root.setArtifact( root.getArtifact().setVersion( version.toString() ) );

代码示例来源:origin: sonatype/sonatype-aether

root = root.setArtifact( root.getArtifact().setVersion( version.toString() ) );

代码示例来源:origin: org.apache.maven.mae.components/mae-project-tools

final VersionResult versionResult = versionResolver.resolveVersion( session, versionRequest );
artifact = artifact.setVersion( versionResult.getVersion() );

相关文章