Example usage for org.apache.maven.project MavenProject replaceWithActiveArtifact

List of usage examples for org.apache.maven.project MavenProject replaceWithActiveArtifact

Introduction

In this page you can find the example usage for org.apache.maven.project MavenProject replaceWithActiveArtifact.

Prototype

@Deprecated
    public Artifact replaceWithActiveArtifact(Artifact pluginArtifact) 

Source Link

Usage

From source file:org.sonatype.flexmojos.utilities.MavenUtils.java

License:Apache License

/**
 * Use the resolver to resolve the given artifact in the local or remote repositories.
 * /*from  w w w .  ja  v a 2  s .c om*/
 * @param project Active project
 * @param artifact Artifact to be resolved
 * @param resolver ArtifactResolver to use for resolving the artifact
 * @param localRepository ArtifactRepository
 * @param remoteRepositories List of remote artifact repositories
 * @throws MojoExecutionException thrown if an exception occured during artifact resolving
 * @return resolved artifact
 */
@SuppressWarnings("unchecked")
public static Artifact resolveArtifact(MavenProject project, Artifact artifact, ArtifactResolver resolver,
        ArtifactRepository localRepository, List remoteRepositories) throws MojoExecutionException {
    try {
        artifact = project.replaceWithActiveArtifact(artifact);
        if (!artifact.isResolved()) {
            resolver.resolve(artifact, remoteRepositories, localRepository);
        }
        return artifact;
    } catch (AbstractArtifactResolutionException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}