title: Finding the root directory of a multi module Maven reactor project
body: <p>Is there an easy way to find the root of a multi-module Maven project, like Gradle's <code>rootDir</code>?</p>
  <hr />
  <p>Background:</p>
  <p>I want to use the maven-dependency-plugin to copy artifacts from all sub-modules of my multi-module project to a directory that is relative to the root directory of the entire project.</p>
  <p>That is, my layout looks similar to this, names changed:</p>
  <pre><code>to-deploy/
  my-project/
      module-a/
      module-b/
      more-modules-1/
          module-c/
          module-d/
      more-modules-2/
          module-e/
          module-f/
      ...
  </code></pre>
  <p>And i want all the artifacts to be copied from the target-directories of their respective modules to <code>my-project/../to-deploy</code> so i end up with</p>
  <pre><code>to-deploy/
      module-a.jar
      module-b.jar
      module-c.jar
      module-d.jar
      module-e.jar
      module-f.jar
  my-project/
      ...
  </code></pre>
  <p>I could do it with a relative path in each module, like so:</p>
  <pre><code>        &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;copy&lt;/id&gt;
                      &lt;phase&gt;install&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;copy&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;artifactItems&gt;
                              &lt;artifactItem&gt;
                                  &lt;groupId&gt;${project.groupId}&lt;/groupId&gt;
                                  &lt;artifactId&gt;${project.artifactId}&lt;/artifactId&gt;
                                  &lt;version&gt;${project.version}&lt;/version&gt;
                                  &lt;type&gt;jar&lt;/type&gt;
                                  &lt;outputDirectory&gt;../../to-deploy&lt;/outputDirectory&gt;
                              &lt;/artifactItem&gt;
                          &lt;/artifactItems&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  </code></pre>
  <p>But i'd rather not specify a relative path in the <code>&lt;outputDirectory&gt;</code> element.
  I'd prefer something like <code>${reactor.root.directory}/../to-deploy</code>, but i can't find anything like this.</p>
  <p>Also, i'd prefer if there was some way to inherit this maven-dependency-plugin configuration so i don't have to specify it for each module.</p>
  <p>I also tried inheriting a custom property from the root pom:</p>
  <pre><code>&lt;properties&gt;
      &lt;myproject.root&gt;${basedir}&lt;/myproject.root&gt;
  &lt;/properties&gt;
  </code></pre>
  <p>But when i tried to use <code>${myproject.root}</code> in the module POM's, the <code>${basedir}</code> would resolve to the basedir of the module.</p>
  <p>Also, i found <a href="http://labs.consol.de/lang/de/blog/maven/project-root-path-in-a-maven-multi-module-project/" rel="nofollow noreferrer">http://labs.consol.de/lang/de/blog/maven/project-root-path-in-a-maven-multi-module-project/</a> where it's suggested that each developer and presumably the continuous integration server should configure the root directory in a profiles.xml file, but i don't consider it a solution.</p>
  <p>So is there an easy way to find the root of a multi-module project?</p>