You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by pa...@free.fr on 2009/02/02 12:13:40 UTC

Plugin - Artifact.getFile() not set.

Hello,

I try to get the artifact name in a home-made plugin. I use the code below based on the maven-install-plugin.
I am expecting the plugin name to be set after the package phase but it is not the case.
I probably did not get a concept, could you let me know if something obvious is missing ?

Regards,



import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;

/**
 * Goal to get the artifact filename
 * 
 * @goal filename
 * @execute phase="package"
 */
public class ArtifactNameTest extends AbstractMojo

{
	/**
	 * @parameter expression="${project.artifact}"
	 * @required
	 * @readonly
	 */
	private Artifact artifact;

	public void execute() throws MojoExecutionException {
		File file = artifact.getFile();
		if (file == null) {
			getLog().error("artifact.getFile() == null");
		} else {
			getLog().info("artifact.getFile() == " + file.getAbsolutePath());
		}
	}
}

Maven version: 2.1.0-M1

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org