Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven resource filtering for single file

Tags:

spring

xml

maven

In pom.xml I have defined :

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <nonFilteredFileExtensions>
            <nonFilteredFileExtension>xml</nonFilteredFileExtension>
        </nonFilteredFileExtensions>
        <encoding>UTF-8</encoding>
    </configuration>
</plugin>

and

<resources>
    <resource>
        <filtering>true</filtering>
        <directory>src/main/resources</directory>
    </resource>
</resources>

Now the problem is all xml files are not filtered. Is there any possible way to filter single xml file?

like image 877
Domas Mar Avatar asked Aug 03 '15 09:08

Domas Mar


2 Answers

I don't know why Gabor's solution did not work, but I managed to solve this way:

Firstly I removed nonFilteredFileExtension tag:

<nonFilteredFileExtension>xml</nonFilteredFileExtension>

Then modified my resources this way:

<resource>
    <directory>src/main/resources</directory>
    <filtering>true</filtering>
    <includes>
        <include>**/myxml.xml</include>
    </includes>
</resource>

<resource>
    <directory>src/main/resources</directory>
    <filtering>false</filtering>
    <includes>
        <include>**/*.xml</include>
    </includes>
</resource>

Now my single xml file is filtered and other is leaved untouched by filter.

like image 175
Domas Mar Avatar answered Sep 25 '22 01:09

Domas Mar


Something like this works fine for me:

    <resources>
        <resource>
            <directory>src/test/resources</directory>
            <filtering>false</filtering>
        </resource>
        <resource>
            <directory>src/test/resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>my_file.xml</include>
            </includes>
        </resource>
    </resources>

This documentation helps me: Apache Maven - Filtering

like image 12
K. Gol Avatar answered Sep 25 '22 01:09

K. Gol