且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

maven2:从 WAR 中排除目录

更新时间:2022-10-20 15:05:12

你的两个解决方案都无济于事,因为它们会添加一个额外的资源,然后被停用.webapp源文件夹默认复制,没有资源机制.

停用其中一部分的机制是通过 参数,像这样:

<groupId>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><version>2.1</version><配置><warSourceExcludes>webscripts/**</warSourceExcludes></配置></插件>

I tried this to exclude whole directory (${basedir}/src/main/webapp/webscripts) from my WAR file but it failed. What is wrong?

this doesn't work:

<configuration>
   <webResources>
      <resource>
       <directory>${basedir}/src/main/webapp/webscripts</directory>
       <excludes>
        <exclude>**/*.*</exclude>
       </excludes>
      </resource>
   </webResources>
</configuration>

this too:

<configuration>
   <webResources>
      <resource>
       <directory>${basedir}/src/main/webapp</directory>
       <excludes>
        <exclude>**/webscripts</exclude>
       </excludes>
      </resource>
   </webResources>
</configuration>

Can anybody help?

Both of your solutions wouldn't help, as they would add an additional resource that is then deactivated. The webapp source folder is copied by default, without the resource mechanism.

The mechanism to deactivate a part of that is through the <warSourceExcludes> parameter, like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1</version>
    <configuration>
        <warSourceExcludes>webscripts/**</warSourceExcludes>
    </configuration>
</plugin>