Question

Below is the relevant section of the maven project I'm working on. I would like Maven to filter the persistence-context.xml file inside of the WEB-INF directory, and then place it into the WEB-INF directory inside of my war. When I run mvn clean package on this project I see the following two things.

  1. The successfully filtered persistence-context.xml in the target/projectname/ folder. This is NOT the correct place. I want it one directory up in the WEB-INF.

  2. The unfiltered persistence-context.xml in the target/projectname/WEB-INF/ folder. This is NOT what I want. I want the filtered one here.

I'm not even sure how two copies of this file are being generated! Any help would be much appreciated.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <webResources>
            <resource>
                <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                <filtering>true</filtering>
                <includes>
                    <include>persistence-context.xml</include>
                </includes>
                <targetPath>WEB-INF</targetPath>
            </resource>
        </webResources>
    </configuration>
</plugin>
Was it helpful?

Solution

I realized I had another plugin entry for the war plugin which was interfering (possibly overwriting?) with this one. Once I removed that my above entry worked okay!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top