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

x33g5p2x  于2022-01-15 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(74)

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

Artifact.setVersion介绍

暂无

代码示例

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

/** {@inheritDoc} */
public void setVersion( String version )
{
  artifact.setVersion( version );
}

代码示例来源:origin: apache/maven

farthest.getArtifact().setVersion( nearest.getArtifact().getVersion() );
fireEvent( ResolutionListener.OMIT_FOR_NEARER, listeners, nearest, farthest.getArtifact() );

代码示例来源:origin: apache/maven

/** {@inheritDoc} */
public void setVersion( String version )
{
  artifact.setVersion( version );
}

代码示例来源:origin: torquebox/jruby-maven-plugins

private Artifact setLatestVersionIfMissing(final Artifact artifact,
    final ArtifactRepository localRepository,
    final List<ArtifactRepository> remoteRepositories)
    throws GemException {
  if (artifact.getVersion() == null) {
    final List<String> versions = availableVersions(artifact,
                            localRepository,
                            remoteRepositories);
    artifact.setVersionRange(null);
    artifact.setVersion(versions.get(versions.size() - 1));
  }
  return artifact;
}

代码示例来源:origin: apache/maven

private void manageArtifact( ResolutionNode node, ManagedVersionMap managedVersions,
               List<ResolutionListener> listeners )
{
  Artifact artifact = managedVersions.get( node.getKey() );
  // Before we update the version of the artifact, we need to know
  // whether we are working on a transitive dependency or not. This
  // allows depMgmt to always override transitive dependencies, while
  // explicit child override depMgmt (viz. depMgmt should only
  // provide defaults to children, but should override transitives).
  // We can do this by calling isChildOfRootNode on the current node.
  if ( ( artifact.getVersion() != null )
       && ( !node.isChildOfRootNode() || node.getArtifact().getVersion() == null ) )
  {
    fireEvent( ResolutionListener.MANAGE_ARTIFACT_VERSION, listeners, node, artifact );
    node.getArtifact().setVersion( artifact.getVersion() );
  }
  if ( ( artifact.getScope() != null ) && ( !node.isChildOfRootNode() || node.getArtifact().getScope() == null ) )
  {
    fireEvent( ResolutionListener.MANAGE_ARTIFACT_SCOPE, listeners, node, artifact );
    node.getArtifact().setScope( artifact.getScope() );
  }
  if ( Artifact.SCOPE_SYSTEM.equals( node.getArtifact().getScope() ) && ( node.getArtifact().getFile() == null )
       && ( artifact.getFile() != null ) )
  {
    fireEvent( ResolutionListener.MANAGE_ARTIFACT_SYSTEM_PATH, listeners, node, artifact );
    node.getArtifact().setFile( artifact.getFile() );
  }
}

代码示例来源:origin: egineering-llc/gitflow-helper-maven-plugin

/**
 * Updates artifact versions for a given branch name.
 * @param a artifact to update (may be null)
 * @param branchName the branch name
 */
private void updateArtifactVersion(Artifact a, String branchName) {
  if (a != null) {
    a.setVersion(getAsBranchSnapshotVersion(a.getVersion(), branchName));
    try {
      a.setVersionRange(VersionRange.createFromVersion(a.getVersion()));
    } catch (UnsupportedOperationException uoe) { // Some artifact types don't like this.
      getLog().debug("Unable to update VersionRange for artifact.");
    }
  }
}

代码示例来源:origin: org.apache.maven.plugins/maven-gpg-plugin

public void setVersion( String version )
{
  delegate.setVersion( version );
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-maven-embedder

public void setVersion(String version) {
  original.setVersion(version);
}

代码示例来源:origin: de.saumya.mojo/gem-maven-plugin

public void setVersion(final String version) {
  this.artifact.setVersion(version);
}

代码示例来源:origin: org.codehaus.mevenide/nb-mvn-embedder

public void setVersion(String version) {
  original.setVersion(version);
}

代码示例来源:origin: torquebox/jruby-maven-plugins

public void setVersion(final String version) {
  this.artifact.setVersion(version);
}

代码示例来源:origin: org.apache.maven.plugins/maven-assembly-plugin

private void setAlignment( Artifact artifact, Map<String, GroupVersionAlignment> groupVersionAlignments )
  {
    GroupVersionAlignment alignment = groupVersionAlignments.get( artifact.getGroupId() );

    if ( alignment != null )
    {
      if ( !alignment.getExcludes().contains( artifact.getArtifactId() ) )
      {
        artifact.setVersion( alignment.getVersion() );
      }
    }
  }
}

代码示例来源:origin: org.apache.maven.plugins/maven-dependency-plugin

private void installBaseSnapshot( Artifact artifact, ProjectBuildingRequest buildingRequest )
  throws ArtifactInstallerException
{
  if ( artifact.isSnapshot() && !artifact.getBaseVersion().equals( artifact.getVersion() ) )
  {
    String version = artifact.getVersion();
    try
    {
      artifact.setVersion( artifact.getBaseVersion() );
      installer.install( buildingRequest, Collections.singletonList( artifact ) );
    }
    finally
    {
      artifact.setVersion( version );
    }
  }
}

代码示例来源:origin: org.apache.geronimo.genesis.plugins/plugin-support

public void manageArtifact(final Artifact artifact, final Artifact replacement) {
    Node node = (Node) artifacts.get(artifact.getDependencyConflictId());

    if (node != null) {
      if (replacement.getVersion() != null) {
        node.artifact.setVersion(replacement.getVersion());
      }
      if (replacement.getScope() != null) {
        node.artifact.setScope(replacement.getScope());
      }
    }
  }
}

代码示例来源:origin: org.codehaus.mojo/plugin-support

public void manageArtifact(final Artifact artifact, final Artifact replacement) {
    Node node = (Node) artifacts.get(artifact.getDependencyConflictId());

    if (node != null) {
      if (replacement.getVersion() != null) {
        node.artifact.setVersion(replacement.getVersion());
      }
      if (replacement.getScope() != null) {
        node.artifact.setScope(replacement.getScope());
      }
    }
  }
}

代码示例来源:origin: bsorrentino/maven-confluence-plugin

@Override
public void manageArtifact( Artifact artifact, Artifact replacement )
{
  Node node = (Node) artifacts.get( artifact.getDependencyConflictId() );
  if ( node != null )
  {
    if ( replacement.getVersion() != null )
    {
      node.artifact.setVersion( replacement.getVersion() );
    }
    if ( replacement.getScope() != null )
    {
      node.artifact.setScope( replacement.getScope() );
    }
  }
}

代码示例来源:origin: sundrio/sundrio

private void applyOverrides(BomConfig config, Map<Artifact, Dependency> dependencies) {
  if (config.getOverrides() != null) {
    for (VersionOverride override : config.getOverrides()) {
      List<ArtifactFilter> filters = new LinkedList<ArtifactFilter>();
      filters.add(new IncludesFilter(override.getDependencies().getIncludes()));
      filters.add(new ExcludesFilter(override.getDependencies().getExcludes()));
      CompositeFilter filter = new CompositeFilter(filters);
      for (Map.Entry<Artifact, Dependency> entry : dependencies.entrySet()) {
        if (filter.apply(entry.getKey()) != null) {
          getLog().debug("Changing version of dependency " + dependencyKey(entry.getValue()) + " to " + override.getVersion());
          entry.getKey().setVersion(override.getVersion());
          entry.getValue().setVersion(override.getVersion());
        }
      }
    }
  }
}

代码示例来源:origin: be.fluid-it.tools.mvn.cd/mvn-ext-freeze

@Override
public void mojoStarted( ExecutionEvent event )
{
  if (event.getMojoExecution().getExecutionId() != null && event.getMojoExecution().getExecutionId().endsWith("-snapshot")) {
    frozenPomFile = event.getProject().getFile();
    event.getProject().setFile(new File( frozenPomFile.getParent(), MavenConventions.POM_FILE));
    frozenArtifact = event.getProject().getArtifact();
    Artifact snapshotArtifact = ArtifactUtils.copyArtifact(frozenArtifact);
    snapshotArtifact.setVersion(transformToSnapshotVersion(frozenArtifact.getVersion()));
    event.getProject().setArtifact(snapshotArtifact);
    if (!isPomArtifact(event.getProject())) {
      frozenFinalName = event.getProject().getBuild().getFinalName();
      event.getProject().getBuild().setFinalName(transformToSnapshot(frozenFinalName, frozenArtifact, snapshotArtifact));
      event.getProject().getArtifact().setFile(new File(transformToSnapshot(frozenArtifact.getFile().getAbsolutePath(), frozenArtifact, snapshotArtifact)));
      logger.info("[SnapshotExecutionListener]: Switched frozenArtifact file to " + transformToSnapshot(frozenArtifact.getFile().getAbsolutePath(), frozenArtifact, snapshotArtifact));
    }
    frozenAttachedArtifacts = new LinkedList<Artifact>();
    for (Artifact attachedArtifact : event.getProject().getAttachedArtifacts()) {
      String attachedFileAbsolutePath = attachedArtifact.getFile().getAbsolutePath();
      logger.info("[SnapshotExecutionListener]: Attached frozenArtifact file : " + attachedFileAbsolutePath);
      frozenAttachedArtifacts.add(attachedArtifact);
    }
    event.getProject().getAttachedArtifacts().clear();
    for (Artifact frozenAttachedArtifact : frozenAttachedArtifacts) {
      Artifact unfrozenAttachedArtifact = ArtifactUtils.copyArtifact(frozenAttachedArtifact);
      unfrozenAttachedArtifact.setVersion(transformToSnapshot(unfrozenAttachedArtifact.getVersion(), frozenArtifact, snapshotArtifact));
      event.getProject().addAttachedArtifact(unfrozenAttachedArtifact);
    }
  }
}

代码示例来源:origin: de.saumya.mojo/gem-maven-plugin

private MavenProject projectFromArtifact(final Artifact artifact)
    throws ProjectBuildingException, GemException {
  final ProjectBuildingRequest request = new DefaultProjectBuildingRequest().setLocalRepository(this.localRepository)
      .setRemoteRepositories(this.project.getRemoteArtifactRepositories());
  
  manager.setRepositorySession(request, this.repositorySession );
  
  final MavenProject project = this.builder.build(artifact, request)
      .getProject();
  if (project.getDistributionManagement() != null
      && project.getDistributionManagement().getRelocation() != null) {
    final Relocation reloc = project.getDistributionManagement()
        .getRelocation();
    final String key = artifact.getGroupId() + ":"
        + artifact.getArtifactId() + ":" + artifact.getType() + ":"
        + artifact.getVersion();
    artifact.setArtifactId(reloc.getArtifactId());
    artifact.setGroupId(reloc.getGroupId());
    if (reloc.getVersion() != null) {
      artifact.setVersion(reloc.getVersion());
    }
    this.relocationMap.put(key, artifact.getGroupId() + ":"
        + artifact.getArtifactId() + ":" + artifact.getType() + ":"
        + artifact.getVersion());
    return projectFromArtifact(artifact);
  }
  else {
    return project;
  }
}

代码示例来源:origin: torquebox/jruby-maven-plugins

private MavenProject projectFromArtifact(final Artifact artifact)
    throws ProjectBuildingException, GemException {
  final ProjectBuildingRequest request = new DefaultProjectBuildingRequest().setLocalRepository(this.localRepository)
      .setRemoteRepositories(this.project.getRemoteArtifactRepositories());
  
  manager.setRepositorySession(request, this.repositorySession );
  
  final MavenProject project = this.builder.build(artifact, request)
      .getProject();
  if (project.getDistributionManagement() != null
      && project.getDistributionManagement().getRelocation() != null) {
    final Relocation reloc = project.getDistributionManagement()
        .getRelocation();
    final String key = artifact.getGroupId() + ":"
        + artifact.getArtifactId() + ":" + artifact.getType() + ":"
        + artifact.getVersion();
    artifact.setArtifactId(reloc.getArtifactId());
    artifact.setGroupId(reloc.getGroupId());
    if (reloc.getVersion() != null) {
      artifact.setVersion(reloc.getVersion());
    }
    this.relocationMap.put(key, artifact.getGroupId() + ":"
        + artifact.getArtifactId() + ":" + artifact.getType() + ":"
        + artifact.getVersion());
    return projectFromArtifact(artifact);
  }
  else {
    return project;
  }
}

相关文章

微信公众号

最新文章

更多