Maven Resources Plugin: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
<br>
<br>
<center>''In process of being migrated from https://home.feodorov.com:9443/wiki/Wiki.jsp?page=MavenResourcesPlugin''</center>
<br>
=External=
=External=


Line 33: Line 29:
</project>
</project>
</pre>
</pre>
!!!Copy Text Files in target and Final Artifact
We may need this when we implement a "[command usage help|Projects#CommandUsageHelp]" mechanism.
{{{
  <build>
        ...
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.txt</include>
                </includes>
            </resource>
        </resources>
        ...
  </build>
}}}
This will copy all text files found under src/main/java into ./target/classes and make them available in the class path.
__Warning!__ If you specify just the &lt;directory&gt;src/main/java&lt;/directory&gt; resource under  &lt;resources&gt;, this will remove all other implicit resources, including &lt;directory&gt;src/main/resources&lt;/directory&gt; so if you were relying on that (for log4j.xml or whatever else) you will need to add it explicitly:
{{{
  <build>
        ...
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.txt</include>
                </includes>
            </resource>
        </resources>
        ...
  </build>
}}}

Revision as of 08:18, 28 January 2016

External

Internal

Variable Substitution in Resource Files

Set "filtering" to true as follows, and all variables will be substituted on copy:

<project>
  ...
  <build>
    ...
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
      ...
    </resources>
    ...
  </build>
  ...
</project>



!!!Copy Text Files in target and Final Artifact

We may need this when we implement a "[command usage help|Projects#CommandUsageHelp]" mechanism.

{{{

 <build>
       ...
       <resources>
           <resource>
               <directory>src/main/java</directory>
               <includes>
                   <include>**/*.txt</include>
               </includes>
           </resource>
       </resources>
       ...
 </build>

}}}

This will copy all text files found under src/main/java into ./target/classes and make them available in the class path.

__Warning!__ If you specify just the <directory>src/main/java</directory> resource under <resources>, this will remove all other implicit resources, including <directory>src/main/resources</directory> so if you were relying on that (for log4j.xml or whatever else) you will need to add it explicitly:

{{{

 <build>
       ...
       <resources>
           <resource>
               <directory>src/main/resources</directory>
               <includes>
                   <include>**</include>
               </includes>
           </resource>
           <resource>
               <directory>src/main/java</directory>
               <includes>
                   <include>**/*.txt</include>
               </includes>
           </resource>
       </resources>
       ...
 </build>

}}}