Maven: deleted files (antrun) still in final war file
I use the antrun plugin to delete and move some property files dependi开发者_高级运维ng on the profile that is used:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<delete>
<fileset dir="${project.build.outputDirectory}/com/.../props">
<exclude name="pm-web-${profile.id}.xml" />
</fileset>
</delete>
<move file="${project.build.outputDirectory}/com/.../props/pm-web-${profile.id}.xml"
tofile="${project.build.outputDirectory}/com/.../props/pm-web.xml" />
</tasks>
</configuration>
</execution>
</executions>
When I check the target/classes folder I can see that the 'unwanted' property files have been correctly deleted and that the move task was also correctly executed. However, when I look at the built war-file I see that the deleted files are still in there (the moved file is ok int the war).
I don't understand how this might be possible; I assume the war plugin basically jars up the target folder? Since the files have correctly been deleted from the target folder I would expect them not to be in the war as well.
To complicate things (sorry) I've noticed that the delete sometimes works partialy, meaning: sometimes some folders (not all) have been 'deleted from the war'.
I've tried changing the goal of the task (no luck) but I assume that most of the goals occur before building the war anyhow.
thanks for any help,
StijnThe war mojo builds the webapp in ${project.build.directory}/${project.build.finalName}
directory before to create the .war archive. Maybe your properties files were in there prior to adding the antrun stuff. In that case, deleting the properties file from target/classes
didn't remove them from ${project.build.directory}/${project.build.finalName}
and the files still ended up in the final .war. But maybe I'm guessing too much and I'm totally wrong. See if you can reproduce the problem now that you cleaned up everything.
Try change
<phase>compile</phase>
with
<phase>prepare-package</phase>
精彩评论