maven2:从 WAR 中排除目录
我尝试 this 排除整个目录(${basedir}/src/main/webapp/webscripts) 来自我的 WAR 文件,但失败了。怎么了?
这不起作用:
<configuration>
<webResources>
<resource>
<directory>${basedir}/src/main/webapp/webscripts</directory>
<excludes>
<exclude>**/*.*</exclude>
</excludes>
</resource>
</webResources>
</configuration>
这也是:
<configuration>
<webResources>
<resource>
<directory>${basedir}/src/main/webapp</directory>
<excludes>
<exclude>**/webscripts</exclude>
</excludes>
</resource>
</webResources>
</configuration>
有人可以帮忙吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您的两种解决方案都没有帮助,因为它们会添加额外的资源,然后将其停用。默认复制webapp源文件夹,没有资源机制。
停用其中一部分的机制是通过
参数,如下所示: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:warSourceExcludes 似乎不只是被重命名为packagingExcludes。
有一个很大的区别:使用packagingExcludes,令牌被完全排除在最终的war文件中。使用 warSourceExcludes,将 war 目录复制到 war 文件时会忽略标记。
因此,例如,如果令牌存在于 webappDirectory 中,则在使用 warSourceExcludes 时它们不会被忽略,但在使用 packagingExcludes 时则会被忽略。
以及一个有效的语法示例:
warSourceExcludes seems not to have been just renamed packagingExcludes.
There is a big difference: With packagingExcludes, the tokens are completely excluded from the final war file. With warSourceExcludes, the tokens are just ignored when copying the war directory into the war file.
As a result, if the tokens are present in the webappDirectory for example, they will not be ignored when using warSourceExcludes but will be when using packagingExcludes.
And a working syntax example:
在版本 2.1-alpha-1 中,它被错误地命名为 warSourceExcludes。正确的参数是 packagingExcludes
使用示例 (从 WAR 中排除 WEB-INF/statics/ 文件夹):
In version 2.1-alpha-1, this was incorrectly named warSourceExcludes. The right parameter is packagingExcludes
Example of usage (excludes WEB-INF/statics/ folder from WAR):
为了删除源文件,我在 Maven 中使用了以下配置
Inorder to remove the source files i have used the below configuration in maven
有一个场景,我必须排除两个可以由
*scripts
匹配的文件夹,并且它们位于资源文件夹中。第一个困惑是是否以 src/main/resources/*scripts 或 WEB-INF/classes/*scripts 的形式提供排除值,即预编译结构或后编译结构。提供
/**
以使整个目录从 war 文件中排除非常重要。就我而言,*scripts/**
。这是最终有效的配置:
Had a scenario where I had to exclude two folders which could be matched by
*scripts
and they were in the resources folder. The first confusion was whether to provide the exclude value assrc/main/resources/*scripts
or asWEB-INF/classes/*scripts
, i.e. pre or post compilation structure.Was much important to provide
/**
to get the entire directory being excluded from the war file. In my case,*scripts/**
.Here is the final configuration which worked: