title: Unable to pass maven property to ant run plugin
body: <p>I have a problem passing a custom maven property (version)
  to an script executed by maven using the <code>maven-antrun-plugin.</code></p>
  
  <p>I have already read <a href="https://stackoverflow.com/questions/18128706/maven-antrun-pass-maven-properties-to-ant">Maven antrun: pass maven properties to ant</a> but this didn't solve the problem.</p>
  
  <p>There is one difference between my problem and the one given within the mentioned SO question.</p>
  
  <p>In my case the <code>maven-antrun-plugin</code> is executed as a child of an parent project, where the property is defined as a global property for all modules.</p>
  
  <p>The maven-antrun-plugin is one module of the project.</p>
  
  <p>Parent pom snippet looks like this:</p>
  
  <pre><code>&lt;project ...&gt; 
    &lt;!-- Parent --&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;xxx&lt;/groupId&gt;
    &lt;artifactId&gt;xxx&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;pom&lt;/packaging&gt;
  
    &lt;properties&gt;
       &lt;my.project.version&gt;0.0.3-SNAPSHOT&lt;/my.project.version&gt;
       &lt;maven.compiler.source&gt;1.7&lt;/maven.compiler.source&gt;
       &lt;maven.compiler.target&gt;1.7&lt;/maven.compiler.target&gt;
       &lt;java.version&gt;1.7&lt;/java.version&gt;
       &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;/properties&gt;
  </code></pre>
  
  <p></p>
  
  <p>ant run pom looks like this. The property is named <code>target.version</code></p>
  
  <pre><code>&lt;project&gt;
        &lt;!-- Module --&gt;
   &lt;parent&gt;
      &lt;groupId&gt;xxx&lt;/groupId&gt;
      &lt;artifactId&gt;xxx&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;/parent&gt; 
  
   &lt;build&gt;
      &lt;plugins&gt;
           &lt;plugin&gt;
                  &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
                  &lt;executions&gt;
                    &lt;execution&gt;
                      &lt;id&gt;ant-magic&lt;/id&gt;
                      &lt;phase&gt;prepare-package&lt;/phase&gt;
                      &lt;goals&gt;
                        &lt;goal&gt;run&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                        &lt;tasks&gt;
                          &lt;property name="compile_classpath" 
                                    refid="maven.compile.classpath"/&gt;
                          &lt;property name="outputDir"
                                    value="${project.build.outputDirectory}"/&gt;
                          &lt;property name="sourceDir"
                                    value="${project.build.sourceDirectory}"/&gt;
                          &lt;property name="compile_classpath" refid="maven.compile.classpath"/&gt;
  
                          &lt;property name="target-version" refid="${my.project.version}"/&gt;
                          &lt;echo message="Passed target version to ant build script: ${target-version}"/&gt;      
  
                          &lt;ant antfile="${basedir}/src/main/ant/create-dist.xml"
                               target="deploy-ea"/&gt;
                        &lt;/tasks&gt;
                      &lt;/configuration&gt;
                    &lt;/execution&gt;
                  &lt;/executions&gt;
                &lt;/plugin&gt;
          &lt;/plugins&gt;
  &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>The following maven build error occurs during the excution of the build of  the child module which contains the antrun-maven-plugin.</p>
  
  <pre><code>`An Ant BuildException has occured: Reference 0.0.3-SNAPSHOT` not found
  </code></pre>
  
  <p>which is interesting because this is the value of the maven property.</p>
  
  <p>I also tried just to use the simple property name as argument for the </p>
  
  <pre><code>refid attribute 
  </code></pre>
  
  <p>In my case </p>
  
  <pre><code>&lt;property name="target-version" refid="my.project.version"/&gt;
  </code></pre>
  
  <p>Which leads to the following error:</p>
  
  <pre><code>   An Ant BuildException has occured: Reference my.project.version not found
  </code></pre>
  
  <p>The ant script uses the property as follows</p>
  
  <pre><code>&lt;property name="myproject-jar" value="mymodulename-${target-version}.jar"/&gt;
  </code></pre>
  
  <p>Do I have a mistake within my configuration or is the problem that the property is defined within the parent pom. And therefor maybe a maven lifecycle issue?</p>