Is there a way to force maven to copy resource folder changes incrementally?

后端 未结 5 2075
春和景丽
春和景丽 2021-02-20 17:38

I\'m using Maven 2.2.1 and m2eclipse.

I have two resource folders.

When I save a change to any file in any of the resource folders, the Maven incremental build k

5条回答
  •  深忆病人
    2021-02-20 17:56

    I chased the problem down to org.codehaus.plexus.util.FileUtils.copyFile() method. It is this method that is called by the maven-resource-plugin to ultimately copy the resource; the copyFile() method takes an 'overwrite' parameter, which the resource-plugin does pass in (and the default is indeed false), BUT...

    The copyFile() method ignores the 'overwrite' parameter if the list of filter-wrappers passed is non-empty! And if you have filtering set to true for your resources, this list is indeed non-empty.

    I can understand the reasoning behind copyFile() ignoring the 'overwrite': just because the destination file is newer does not mean that new filtered-file will be the same (i.e. the values for the variables in your resource file may have been changed since the last filtering).
    Ignoring the 'overwrite' flag is "convenient" for the FileUtils implementor. But this comes at a great price; a single resource file unnecessarily updated can trigger off time-consuming but redundant processes (i.e. rebuilding a jar-with-dependencies in my case). This may only be a few seconds but can be enough to disrupt the flow of an intensive code-compile-test cycle.

    I looked for open bug on FileUtils but did not find any. This was bugging me so I had to chase it down but I can't spend more time on it right now... in few days I would like to file a bug report (may just be quicker to implement the right solution); if anyone can post links to the appropriate bug-tracking/reporting system I would appreciate it.

提交回复
热议问题