title: Maven: Bind plugin execution to the execution of another plugin, not to a lifecycle phase
body: <p><strong>Note regarding the accepted answer:</strong> I accepted the answer because of strong circumstantial evidence. Nonetheless, this is circumstantial evidence, so take it with a grain of salt.</p>
  
  <hr>
  
  <p>How can I have a plugin be triggered when the user runs a plugin goal, not a lifecycle phase? (This <a href="https://stackoverflow.com/questions/1393691/how-to-bind-a-plugin-goal-to-another-plugin-goal">has been asked</a> before, but the answer was to use a lifecycle phase.)</p>
  
  <p>Case in point: I need <code>release:branch</code> to invoke <code>regex-plugin</code> to generate a branch with the current version as its name, <em>minus the -SNAPSHOT suffix</em>. This is what I have, which requires the developer to activate a profile and invoke the <code>verify</code> phase. I need the developer to simply invoke <code>release:branch</code>, which in turn should cause <code>regex-plugin</code> to run. In a bit of a marriage to Gitflow.</p>
  
  <pre><code>&lt;profile&gt;
      &lt;id&gt;Release Branch&lt;/id&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;!-- On validate, compute the current version without -SNAPSHOT. --&gt;
              &lt;!-- Put the result in a property. --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;build-helper-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.7&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;validate&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;regex-property&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;value&gt;${project.version}&lt;/value&gt;
                              &lt;regex&gt;^(.*)-SNAPSHOT$&lt;/regex&gt;
                              &lt;replacement&gt;$1&lt;/replacement&gt;
                              &lt;name&gt;project.unqualifiedVersion&lt;/name&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
              &lt;!-- Also on validate, run the branch plugin, and use --&gt;
              &lt;!-- the non-SNAPSHOT version thus computed in the branch name. --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-release-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3.2&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;validate&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;branch&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;branchName&gt;release/${project.unqualifiedVersion}&lt;/branchName&gt;
                              &lt;updateWorkingCopyVersions&gt;true&lt;/updateWorkingCopyVersions&gt;
                              &lt;updateBranchVersions&gt;false&lt;/updateBranchVersions&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/profile&gt;
  </code></pre>
  
  <p>The intent is for <code>release:branch</code> to move the current snapshot version (say, <code>1.0.5-SNAPSHOT</code>) into a new branch, which should be named after the version but without the superfluous <code>-SNAPSHOT</code> suffix (<code>1.0.5</code>). The current branch should then take on a new snapshot version (<code>1.1.0-SNAPSHOT</code>, not <code>1.0.6-SNAPSHOT</code>, because we want release <code>1.0.x</code> to have room for hotfixes, so we reserve it for the branch) (I don't have the automatic computation of the next snapshot version figured out yet, so, if you run the Maven configuration above with <code>validate</code>, you will have to enter it at a prompt).</p>