The maven documentation for this 开发者_开发问答has to be wrong.
Here are the various permutations I have tried with all failing to exclude the file:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceExcludes>**/*server.properties</warSourceExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>src/main/resources/com/mycom/myapplication/</directory>
<!-- there's no default value for this -->
<excludes>
<exclude>**/*server.properties</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>
A mail list entry suggests using this older version and a string list:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.1</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>src/main/resources/com/pictage/provendirect/</directory>
<!-- there's no default value for this -->
<excludes>**/*server.properties</excludes>
</resource>
</webResources>
</configuration>
</plugin>
Which results in:
(found static expression: '/*server.properties' which may act as a default value). Cause: Cannot assign configuration entry 'excludes' to 'interface java.util.List' from '/*server.properties', which is of type class java.lang.String
Also tried:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.1</version>
<configuration>
<packagingExcludes>
**/server.properties
</packagingExcludes>
</configuration>
</plugin>
Any ideas? I am going crazy with this.
A more careful reading of the maven docs suggests:
<configuration>
<webResources>
<resource>
should only be used when excluding resources outside /src/main/resources. To do it inside this folder, you need to use warSourceExcludes and possibly warSourceDirectory parameters if the property isn't in the root of the directory.
I cry a little inside when it takes me hours to to do something via configuration in maven when it could have been handled in two seconds with a scripting language but I guess it's the 'right' way to implement it.
精彩评论