org.apache.maven.artifact.handler.ArtifactHandler.getExtension()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(37)

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

ArtifactHandler.getExtension介绍

[英]Get the file extension associated to the file represented by the dependency type.
[中]获取与依赖项类型表示的文件关联的文件扩展名。

代码示例

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

public String pathOf( Artifact artifact )
{
  ArtifactHandler artifactHandler = artifact.getArtifactHandler();
  StringBuilder path = new StringBuilder( 128 );
  path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() );
  if ( artifact.hasClassifier() )
  {
    path.append( ARTIFACT_SEPARATOR ).append( artifact.getClassifier() );
  }
  if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 )
  {
    path.append( GROUP_SEPARATOR ).append( artifactHandler.getExtension() );
  }
  return path.toString();
}

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

/** @deprecated we want to use the artifact method only, and ensure artifact.file is set correctly. */
@Deprecated
public void install( String basedir, String finalName, Artifact artifact, ArtifactRepository localRepository )
  throws ArtifactInstallationException
{
  String extension = artifact.getArtifactHandler().getExtension();
  File source = new File( basedir, finalName + "." + extension );
  install( source, artifact, localRepository );
}

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

/**
 * @deprecated we want to use the artifact method only, and ensure artifact.file is set
 *             correctly.
 */
@Deprecated
public void deploy( String basedir, String finalName, Artifact artifact, ArtifactRepository deploymentRepository,
          ArtifactRepository localRepository )
  throws ArtifactDeploymentException
{
  String extension = artifact.getArtifactHandler().getExtension();
  File source = new File( basedir, finalName + "." + extension );
  deploy( source, artifact, deploymentRepository, localRepository );
}

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

public String pathOf( Artifact artifact )
{
  ArtifactHandler artifactHandler = artifact.getArtifactHandler();
  StringBuilder path = new StringBuilder( 128 );
  path.append( formatAsDirectory( artifact.getGroupId() ) ).append( PATH_SEPARATOR );
  path.append( artifact.getArtifactId() ).append( PATH_SEPARATOR );
  path.append( artifact.getBaseVersion() ).append( PATH_SEPARATOR );
  path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() );
  if ( artifact.hasClassifier() )
  {
    path.append( ARTIFACT_SEPARATOR ).append( artifact.getClassifier() );
  }
  if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 )
  {
    path.append( GROUP_SEPARATOR ).append( artifactHandler.getExtension() );
  }
  return path.toString();
}

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

/**
 * Gets the repository conflict id of the specified artifact. Unlike the dependency conflict id, the repository
 * conflict id uses the artifact file extension instead of the artifact type. Hence, the repository conflict id more
 * closely reflects the identity of artifacts as perceived by a repository.
 * 
 * @param artifact The artifact, must not be <code>null</code>.
 * @return The repository conflict id, never <code>null</code>.
 */
private String getRepositoryConflictId( Artifact artifact )
{
  StringBuffer buffer = new StringBuffer( 128 );
  buffer.append( artifact.getGroupId() );
  buffer.append( ':' ).append( artifact.getArtifactId() );
  if ( artifact.getArtifactHandler() != null )
  {
    buffer.append( ':' ).append( artifact.getArtifactHandler().getExtension() );
  }
  else
  {
    buffer.append( ':' ).append( artifact.getType() );
  }
  if ( artifact.hasClassifier() )
  {
    buffer.append( ':' ).append( artifact.getClassifier() );
  }
  return buffer.toString();
}

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

public static Artifact toArtifact( org.apache.maven.artifact.Artifact artifact )
{
  if ( artifact == null )
  {
    return null;
  }
  String version = artifact.getVersion();
  if ( version == null && artifact.getVersionRange() != null )
  {
    version = artifact.getVersionRange().toString();
  }
  Map<String, String> props = null;
  if ( org.apache.maven.artifact.Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
  {
    String localPath = ( artifact.getFile() != null ) ? artifact.getFile().getPath() : "";
    props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, localPath );
  }
  Artifact result =
    new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(),
               artifact.getArtifactHandler().getExtension(), version, props,
               newArtifactType( artifact.getType(), artifact.getArtifactHandler() ) );
  result = result.setFile( artifact.getFile() );
  return result;
}

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

public static ArtifactType newArtifactType( String id, ArtifactHandler handler )
{
  return new DefaultArtifactType( id, handler.getExtension(), handler.getClassifier(), handler.getLanguage(),
                  handler.isAddedToClasspath(), handler.isIncludesDependencies() );
}

代码示例来源:origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

+ artifact.getArtifactHandler().getExtension();

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

public String getExtension() {
  if (this.handler.getExtension().equals("java-gem")) {
    return "gem";
  }
  else {
    return this.handler.getExtension();
  }
}

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

/**
 * Returns true if the artifact handler can handle the dotnet types, otherwise returns false
 *
 * @param artifactHandler the artifact handler to check
 * @return true if the artifact handler can handle the dotnet types, otherwise returns false
 */
private boolean isDotNetHandler( ArtifactHandler artifactHandler )
{
  String extension = artifactHandler.getExtension();
  return extension.equals( "dll" ) || extension.equals( "nar" ) || extension.equals( "exe" ) ||
    extension.equals( "exe.config" );
}

代码示例来源:origin: org.springframework.boot/spring-boot-maven-plugin

private File getTargetFile() {
  String classifier = (this.classifier != null) ? this.classifier.trim() : "";
  if (!classifier.isEmpty() && !classifier.startsWith("-")) {
    classifier = "-" + classifier;
  }
  if (!this.outputDirectory.exists()) {
    this.outputDirectory.mkdirs();
  }
  return new File(this.outputDirectory, this.finalName + classifier + "."
      + this.project.getArtifact().getArtifactHandler().getExtension());
}

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

private File shadedTestArtifactFileWithClassifier()
{
  Artifact artifact = project.getArtifact();
  final String shadedName = shadedArtifactId + "-" + artifact.getVersion() + "-" + shadedClassifierName
    + "-tests." + artifact.getArtifactHandler().getExtension();
  return new File( outputDirectory, shadedName );
}

代码示例来源:origin: apache/axis2-java

/**
 * Converts the filename of an artifact to artifactId-version.type format.
 *
 * @param artifact
 * @return converted filename of the artifact
 */
private String getDefaultFinalName(Artifact artifact) {
  return artifact.getArtifactId() + "-" + artifact.getVersion() + "." +
      artifact.getArtifactHandler().getExtension();
}

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

/**
 * Returns a string that represents a pattern for an exclude filter for the given artifact.
 *
 * @param artifact Artifact.
 * @return String representation of a pattern for an exclude filter for the given artifact.
 */
private String toPatternExcludes( Artifact artifact )
{
  return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":"
    + artifact.getArtifactHandler().getExtension() + ":" + artifact.getVersion();
}

代码示例来源:origin: alipay/sofa-ark

private String getFileName(Artifact artifact) {
  StringBuilder sb = new StringBuilder();
  sb.append(artifact.getArtifactId()).append("-").append(artifact.getBaseVersion());
  String classifier = artifact.getClassifier();
  if (classifier != null) {
    sb.append("-").append(classifier);
  }
  sb.append(".").append(artifact.getArtifactHandler().getExtension());
  return sb.toString();
}

代码示例来源:origin: org.springframework.boot/spring-boot-maven-plugin

private String getFileName(Artifact artifact) {
  StringBuilder sb = new StringBuilder();
  sb.append(artifact.getArtifactId()).append("-").append(artifact.getBaseVersion());
  String classifier = artifact.getClassifier();
  if (classifier != null) {
    sb.append("-").append(classifier);
  }
  sb.append(".").append(artifact.getArtifactHandler().getExtension());
  return sb.toString();
}

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

public static String getProjectArtifactCoordinates(MavenProject project, String versionOverride) {
  org.apache.maven.artifact.Artifact artifact = project.getArtifact();
  String extension = artifact.getArtifactHandler().getExtension();
  String version = versionOverride == null ? project.getVersion() : versionOverride;
  if (artifact.hasClassifier()) {
    return project.getGroupId() + ":" + project.getArtifactId() + ":" + extension + ":" +
        artifact.getClassifier() + ":" + version;
  } else {
    return project.getGroupId() + ":" + project.getArtifactId() + ":" + extension + ":" +
        version;
  }
}

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

private static Artifact findProjectArtifact(MavenProject project) {
  String extension = project.getArtifact().getArtifactHandler().getExtension();
  String fileName = project.getModel().getBuild().getFinalName() + "." + extension;
  File f = new File(new File(project.getBasedir(), "target"), fileName);
  if (f.exists()) {
    Artifact ret = RepositoryUtils.toArtifact(project.getArtifact());
    return ret.setFile(f);
  } else {
    return null;
  }
}

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

@Override
public CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest, DependableCoordinate root )
  throws DependencyCollectorException
{
  ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( root.getType() );
  
  String extension = artifactHandler != null ? artifactHandler.getExtension() : null;
  
  Artifact aetherArtifact = new DefaultArtifact( root.getGroupId(), root.getArtifactId(), root.getClassifier(),
                          extension, root.getVersion() );
  
  CollectRequest request = new CollectRequest();
  request.setRoot( new Dependency( aetherArtifact, null ) );
  return collectDependencies( buildingRequest, request );
}

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

private ArtifactCoordinate toArtifactCoordinate( DependableCoordinate dependableCoordinate )
{
  ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( dependableCoordinate.getType() );
  DefaultArtifactCoordinate artifactCoordinate = new DefaultArtifactCoordinate();
  artifactCoordinate.setGroupId( dependableCoordinate.getGroupId() );
  artifactCoordinate.setArtifactId( dependableCoordinate.getArtifactId() );
  artifactCoordinate.setVersion( dependableCoordinate.getVersion() );
  artifactCoordinate.setClassifier( dependableCoordinate.getClassifier() );
  artifactCoordinate.setExtension( artifactHandler.getExtension() );
  return artifactCoordinate;
}

相关文章