Example usage for org.apache.maven.artifact.handler DefaultArtifactHandler getExtension

List of usage examples for org.apache.maven.artifact.handler DefaultArtifactHandler getExtension

Introduction

In this page you can find the example usage for org.apache.maven.artifact.handler DefaultArtifactHandler getExtension.

Prototype

public String getExtension() 

Source Link

Usage

From source file:ch.sourcepond.maven.plugin.repobuilder.AdditionalArtifact.java

License:Apache License

/**
 * @return/* ww  w.jav  a  2  s  . c o m*/
 * @throws MojoExecutionException
 */
Artifact toArtifact() throws MojoExecutionException {
    final DefaultArtifactHandler handler = new DefaultArtifactHandler();
    String extension = this.extension;
    if (isBlank(extension)) {
        extension = getFileExtension(file.getAbsolutePath());
    }

    if (isBlank(extension)) {
        throw new MojoExecutionException(
                "No extension specified; either add an extension to the artifact-file, or, specify parameter 'extension'! Invalid config item: "
                        + this);
    }

    handler.setExtension(extension);
    final Artifact artifact = new DefaultArtifact(groupId, artifactId, version, "", handler.getExtension(),
            classifier, handler);
    artifact.setFile(file);
    return artifact;
}