package org.apache.maven.plugin.coreit; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.*; import org.apache.maven.artifact.*; import org.apache.maven.artifact.factory.*; import org.apache.maven.artifact.resolver.*; import org.apache.maven.artifact.repository.*; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; /** * Resolves an artifact and has an (unused) dependency on log4j. * * @goal it * * @author Benjamin Bentmann * @version $Id: CleanMojo.java 698220 2008-09-23 16:18:19Z bentmann $ */ public class ItMojo extends AbstractMojo { /** * @component */ private ArtifactFactory artifactFactory; /** * @component */ private ArtifactResolver artifactResolver; /** * @parameter default-value="${localRepository}" * @required * @readonly */ private ArtifactRepository localRepository; /** * @parameter default-value="${project.remoteArtifactRepositories}" * @required * @readonly */ private List remoteRepositories; /** * @parameter default-value="test" */ private String groupId; /** * @parameter default-value="test" */ private String artifactId; /** * @parameter default-value="1.0" */ private String version; /** * Runs this mojo. * * @throws MojoExecutionException If the output file could not be created. * @throws MojoFailureException If the output file has not been set. */ public void execute() throws MojoExecutionException { getLog().info( "[MAVEN-CORE-IT-LOG4J]" ); Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, version ); try { artifactResolver.resolve( artifact, remoteRepositories, localRepository ); } catch ( ArtifactNotFoundException e ) { getLog().info( "SUCCESS" ); } catch ( ArtifactResolutionException e ) { throw new MojoExecutionException( "Should have responded with ArtifactNotFoundException.", e ); } } }