title: Is it possible to access Maven project information from a custom plugin?
body: <p>I'm writing a custom plugin in Maven and would like to access information about the project. As a simple example, within my Java code, I'd like to get the project's build directory. I know that I can get it using a parameter annotation like so:</p>
  
  <pre><code>@Mojo( name="myplugin" )
  public class MyPluginMojo extends AbstractMojo {
  
      // DOES work. The project.build.directory prop is resolved.
      @Parameter( property="myplugin.buildDir", defaultValue="${project.build.directory}", required=true )
  private File buildDir;
  
      public void execute () throws MojoExecutionException
      {
          System.out.println(buildDir.getPath());
  
          // DOES NOT work, prints the literal string.
          System.out.println("${project.build.directory}");
      }
  
  }
  </code></pre>
  
  <p>That <em>feels</em> like a hack. To start with, I have no need to expose this parameter to the pom.xml. I'm only doing it this way because within the annotation, the property gets resolved.</p>
  
  <p>I'd also like access to other properties, namely the project's dependencies.</p>
  
  <p>I've been googling for hours without luck. The closest thing I've found is the MavenProject plugin but I can't get it to work either and it hasn't been updated since 2009 from the looks of it.</p>
  
  <p>Gradle provides the "project" variable for this when writing plugins. Does Maven simply not allow this?</p>
  
  <p>--- Update ---</p>
  
  <p>Thanks to Robert's link to the documentation, I got this working. One thing that was a surprise to me was that the project.build.directory is not available through the injected project. According to the docs, you inject that separately. Here's what I added to my class to get both the project object and the build directory:</p>
  
  <pre><code>@Parameter( defaultValue="${project}", readonly=true, required=true )
  MavenProject project;
  
  @Parameter( defaultValue = "${project.build.directory}", readonly=true, required=true )
  private File target;
  </code></pre>
  
  <p>And a dependency to my pom:</p>
  
  <pre><code>  &lt;dependency&gt;
        &lt;groupId&gt;org.apache.maven&lt;/groupId&gt;
        &lt;artifactId&gt;maven-project&lt;/artifactId&gt;
        &lt;version&gt;3.0-alpha-2&lt;/version&gt;
    &lt;/dependency&gt;
  </code></pre>