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

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

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

Artifact.getId介绍

暂无

代码示例

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

/** {@inheritDoc} */
public String getId()
{
  return artifact.getId();
}

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

/** {@inheritDoc} */
public String getId()
{
  return artifact.getId();
}

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

private static String constructMessage( MavenProject project, Artifact artifact )
{
  return DEFAULT_MESSAGE + " (project: " + project.getId() + "; illegal attachment: " + artifact.getId() + ")";
}

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

private ModelSource createStubModelSource( Artifact artifact )
{
  StringBuilder buffer = new StringBuilder( 1024 );
  buffer.append( "<?xml version='1.0'?>" );
  buffer.append( "<project>" );
  buffer.append( "<modelVersion>4.0.0</modelVersion>" );
  buffer.append( "<groupId>" ).append( artifact.getGroupId() ).append( "</groupId>" );
  buffer.append( "<artifactId>" ).append( artifact.getArtifactId() ).append( "</artifactId>" );
  buffer.append( "<version>" ).append( artifact.getBaseVersion() ).append( "</version>" );
  buffer.append( "<packaging>" ).append( artifact.getType() ).append( "</packaging>" );
  buffer.append( "</project>" );
  return new StringModelSource( buffer, artifact.getId() );
}

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

/**
 * @return {@link List} &lt; {@link String} &gt; with artifact ids
 * @throws OverConstrainedVersionException
 */
public List<String> getDependencyTrail()
  throws OverConstrainedVersionException
{
  List<Artifact> trial = getTrail();
  List<String> ret = new ArrayList<>( trial.size() );
  for ( Artifact artifact : trial )
  {
    ret.add( artifact.getId() );
  }
  return ret;
}

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

public AttachedArtifact( Artifact parent, String type, String classifier, ArtifactHandler artifactHandler )
{        
  super( parent.getGroupId(), parent.getArtifactId(), parent.getVersionRange(), parent.getScope(), type,
      classifier, artifactHandler, parent.isOptional() );
  
  setDependencyTrail( Collections.singletonList( parent.getId() ) );
  
  this.parent = parent;
  
  if ( getId().equals( parent.getId() ) )
  {
    throw new InvalidArtifactRTException( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), parent.getType(), "An attached artifact must have a different ID than its corresponding main artifact." );
  }
}

代码示例来源:origin: simpligility/android-maven-plugin

/**
 * Attempts to resolve an {@link org.apache.maven.artifact.Artifact} to a {@link java.io.File}.
 *
 * @param artifact to resolve
 * @return a {@link java.io.File} to the resolved artifact, never <code>null</code>.
 * @throws org.apache.maven.plugin.MojoExecutionException if the artifact could not be resolved.
 */
public File resolveArtifactToFile( Artifact artifact ) throws MojoExecutionException
{
  final Artifact resolvedArtifact = resolveArtifact( artifact );
  final File jar = resolvedArtifact.getFile();
  if ( jar == null )
  {
    throw new MojoExecutionException( "Could not resolve artifact " + artifact.getId()
        + ". Please install it with \"mvn install:install-file ...\" or deploy it to a repository "
        + "with \"mvn deploy:deploy-file ...\"" );
  }
  return jar;
}

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

public AttachedArtifact( Artifact parent, String type, String classifier, ArtifactHandler artifactHandler )
{
  super( parent.getGroupId(), parent.getArtifactId(), parent.getVersionRange(), parent.getScope(), type,
      classifier, artifactHandler, parent.isOptional() );
  setDependencyTrail( Collections.singletonList( parent.getId() ) );
  this.parent = parent;
  if ( getId().equals( parent.getId() ) )
  {
    throw new InvalidArtifactRTException( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(),
                       parent.getType(), "An attached artifact must have a different ID"
                         + " than its corresponding main artifact." );
  }
}

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

private void logMissingSiblingProjectArtifact( Artifact artifact )
{
  if ( logger == null || !logger.isDebugEnabled() )
  {
    return;
  }
  
  if ( logger.isDebugEnabled() )
  {
    StringBuffer message = new StringBuffer();
    message.append( "WARNING: A dependency of the current project (or of one the plugins used in its build) was found in the reactor, " );
    message.append( "\nbut had not been built at the time it was requested. It will be resolved from the repository instead." );
    message.append( "\n\nCurrent Project: " ).append( getName() );
    message.append( "\nRequested Dependency: " ).append( artifact.getId() );
    message.append( "\n\nNOTE: You may need to run this build to the 'compile' lifecycle phase, or farther, in order to build the dependency artifact." );
    message.append( "\n" );
    
    logger.debug( message.toString() );
  }
  else
  {
    logger.warn( "Requested project artifact: " + artifact.getId() + " is not available at this time. Resolving externally." );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

try {
  urls.add( a.getFile().toURI().toURL() );
  getLog().debug( "Adding classpath entry for dependency " + a.getId() );
  String msg = "Unable to resolve URL for dependency " + a.getId() + " at " + a.getFile().getAbsolutePath();
  if ( failOnError ) {
    throw new MojoExecutionException( msg, e );

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

private static String constructMessage( List<Artifact> artifacts )
{
  StringBuilder buffer = new StringBuilder( 256 );
  buffer.append( "Missing:\n" );
  buffer.append( "----------\n" );
  int counter = 0;
  for ( Artifact artifact : artifacts )
  {
    String message = ( ++counter ) + ") " + artifact.getId();
    buffer.append( constructMissingArtifactMessage( message, "  ", artifact.getGroupId(),
        artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(),
        artifact.getDownloadUrl(), artifact.getDependencyTrail() ) );
  }
  buffer.append( "----------\n" );
  int size = artifacts.size();
  buffer.append( size ).append( " required artifact" );
  if ( size > 1 )
  {
    buffer.append( "s are" );
  }
  else
  {
    buffer.append( " is" );
  }
  buffer.append( " missing.\n\nfor artifact: " );
  return buffer.toString();
}

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

private static String constructMessage( List<Artifact> artifacts )
{
  StringBuilder buffer = new StringBuilder( 256 );
  buffer.append( "Missing:\n" );
  buffer.append( "----------\n" );
  int counter = 0;
  for ( Artifact artifact : artifacts )
  {
    String message = ( ++counter ) + ") " + artifact.getId();
    buffer.append( constructMissingArtifactMessage( message, "  ", artifact.getGroupId(),
        artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(),
        artifact.getDownloadUrl(), artifact.getDependencyTrail() ) );
  }
  buffer.append( "----------\n" );
  int size = artifacts.size();
  buffer.append( size ).append( " required artifact" );
  if ( size > 1 )
  {
    buffer.append( "s are" );
  }
  else
  {
    buffer.append( " is" );
  }
  buffer.append( " missing.\n\nfor artifact: " );
  return buffer.toString();
}

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

public static void toArtifacts( Collection<org.apache.maven.artifact.Artifact> artifacts,
                Collection<? extends DependencyNode> nodes, List<String> trail,
                DependencyFilter filter )
{
  for ( DependencyNode node : nodes )
  {
    org.apache.maven.artifact.Artifact artifact = toArtifact( node.getDependency() );
    List<String> nodeTrail = new ArrayList<>( trail.size() + 1 );
    nodeTrail.addAll( trail );
    nodeTrail.add( artifact.getId() );
    if ( filter == null || filter.accept( node, Collections.<DependencyNode>emptyList() ) )
    {
      artifact.setDependencyTrail( nodeTrail );
      artifacts.add( artifact );
    }
    toArtifacts( artifacts, node.getChildren(), nodeTrail, filter );
  }
}

代码示例来源:origin: simpligility/android-maven-plugin

if ( type.equals( APKLIB ) && isAarBuild )
  getLog().warn( "Detected APKLIB transitive dependency: " + artifact.getId() );
  foundApklib = true;
      getLog().warn( "Detected " + artifact.getId() + " that depends on APKLIB: "
          + dependency.getId() );
      foundApklib = true;

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

+ artifact.getId() );
logger.debug( "Trying repository " + repository.getId() + " for resolution of " + artifact.getId()
         + " from " + remotePath );
logger.debug( "  Artifact " + artifact.getId() + " resolved to " + artifact.getFile() );

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

logger.debug( "Unable to find artifact " + artifact.getId() + " in repository " + repository.getId()
         + " (" + repository.getUrl() + ")", e );
  "Unable to get artifact " + artifact.getId() + " from repository " + repository.getId() + " ("
    + repository.getUrl() + "): " + e.getMessage();

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

Collections.singletonList( project.getArtifact().getId() ), null );

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

Collections.singletonList( project.getArtifact().getId() ), collectionFilter );

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

public static org.apache.maven.artifact.Artifact toArtifact( Artifact artifact )
{
  if ( artifact == null )
  {
    return null;
  }
  ArtifactHandler handler = newHandler( artifact );
  /*
   * NOTE: From Artifact.hasClassifier(), an empty string and a null both denote "no classifier". However, some
   * plugins only check for null, so be sure to nullify an empty classifier.
   */
  org.apache.maven.artifact.Artifact result =
    new org.apache.maven.artifact.DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(),
                            artifact.getVersion(), null,
                            artifact.getProperty( ArtifactProperties.TYPE,
                                       artifact.getExtension() ),
                            nullify( artifact.getClassifier() ), handler );
  result.setFile( artifact.getFile() );
  result.setResolved( artifact.getFile() != null );
  List<String> trail = new ArrayList<>( 1 );
  trail.add( result.getId() );
  result.setDependencyTrail( trail );
  return result;
}

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

throw new ProjectBuildingException( artifact.getId(),
                  "Error resolving project artifact: " + e.getMessage(), e );

相关文章

微信公众号

最新文章

更多