title: How to inject one file into another with Maven?
body: <p>I have two files in my src/main/resources and I want one file's body to be injected into specific place of another file. So one file should be a template and another file will the data to fill this template (something like in Apache Velocity).</p>
  
  <p>Can I do this with some existing Maven plugin?</p>
  
  <p>Thank you in advance.</p>
  
  <p>Solution:
  I decided not to use a special plugin but to add this to pom.xml:</p>
  
  <pre><code>    &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
              &lt;version&gt;1.6&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;rng-injection&lt;/id&gt;
                      &lt;phase&gt;generate-resources&lt;/phase&gt;
                      &lt;configuration&gt;
                          &lt;target&gt;
                              &lt;echo message="Injecting RNG schemes"/&gt;
  
                              &lt;copy file="${main.resources}/RNG/enets-template.rng"
                                    tofile="${main.resources}/RNG/enets.rng"
                                    verbose="true"
                                    overwrite="true"/&gt;
  
                              &lt;copy file="${main.resources}/RNG/modeldefinition-template.rng"
                                    tofile="${main.resources}/RNG/modeldefinition.rng"
                                    verbose="true"
                                    overwrite="true"/&gt;
  
  
                              &lt;property name="enets-def" value="${main.resources}/RNG/enetsdefinitions.rng"/&gt;
                              &lt;loadfile property="def-file" srcfile="${enets-def}"/&gt;
                              &lt;replace file="${main.resources}/RNG/enets.rng"&gt;
                                  &lt;replacefilter token="{!enets-definition!}" value="${def-file}"/&gt;
                              &lt;/replace&gt;
  
                              &lt;replace file="${main.resources}/RNG/modeldefinition.rng"&gt;
                                  &lt;replacefilter token="{!enets-definition!}" value="${def-file}"/&gt;
                              &lt;/replace&gt;
                          &lt;/target&gt;
                      &lt;/configuration&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;run&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
  
              &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>