How do I filter test resources in maven?

后端 未结 1 1591
天命终不由人
天命终不由人 2020-12-14 06:52

I have the following pom.xml. When I run mvn clean resources:testResources, my test resources aren\'t being filtered (replacing placeholders in res

相关标签:
1条回答
  • 2020-12-14 07:29

    The resources and resource elements are for the resources:resources goal. resources:testResources uses testResources and testResource elements.

    The correct pom.xml is:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.example</groupId>
        <artifactId>foo</artifactId>
        <version>0.0.1</version>
        <packaging>jar</packaging>
        <name>foo</name>
    
        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.11</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    
        <build>
            <testResources>
                <testResource>
                    <directory>src/test/resources</directory>
                    <filtering>true</filtering>
                </testResource>
            </testResources>
        </build>
    </project>
    
    0 讨论(0)
提交回复
热议问题