如何阻止Maven覆盖资源文件 [英] How to stop Maven from overwriting resource files
问题描述
我有默认的maven结构:
I have the default maven structure:
main
--java
--resources
--webapp
我看到每个 mvn编译
复制资源即使它们没有被更改。
如何使构建副本只更改文件?
I see that every mvn compile
copies resources even though they were not changed.
What should I do to make build copy only changed files?
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
...
</dependencies>
<properties>
<maven.resources.overwrite>false</maven.resources.overwrite>
</properties>
以下是调试模式下的输出:
Here is the output in debug mode:
[INFO] Using 'cp1252' encoding to copy filtered resources.
[DEBUG] resource with targetPath null
directory C:\core\src\main\resources
excludes []
includes []
[DEBUG] ignoreDelta true
[INFO] Copying 190 resources
[DEBUG] file batch.bat has a filtered file extension
[DEBUG] copy C:\core\src\main\resources\batch.bat to C:\core\target\classes\batch.bat
[DEBUG] file DataObject.hbm.xml has a filtered file extension
[DEBUG] copy C:\core\src\main\resources\com\data\DataObject.hbm.xml to C:\core\target\classes\com\data\DataObject.hbm.xml
推荐答案
使用属性 - Maven命令上的Dmaven.resources.overwrite = false
。请参阅覆盖参数nofollow noreferrer> 资源:资源
目标。
Use the property -Dmaven.resources.overwrite=false
on the Maven command. See the overwrite
parameter of the resources:resources
goal.
但是文档提到这是默认值行为,请检查项目配置中某处是否将此参数设置为true。
However the documentation mentions this is the default behavior so check if this parameter is set to true somewhere in your project configuration.
编辑:
如评论中所述,似乎即使日志表示复制,实际上文件也没有被更改(当 maven.resources.overwrite $时,时间戳保持不变c $ c>是假的。)
As mentioned in the comments, it seems that even though the log indicates copying, in fact the files are not being changed (the timestamps remain the same when maven.resources.overwrite
is false).
这篇关于如何阻止Maven覆盖资源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!