Search code examples
mavenmaven-antrun-plugin

maven-antrun-plugin copy resources works only on validate phase


I am using maven-antrun-plugin version 1.8 to copy some files to the src/main/resources folder so that it gets included in jar in package phase.

If the execution phase of the task defined to copy to resources folder is validate everything works fine but if it is compile/test the files are copied to src/main/resources folder but are not included in jar


Solution

  • It is because Resources folder gets copied to target folder at process-resources phase of Maven. Therefore to get files in the resources folder of jar/war you need to copy files to resources folder before the process-resources phase i.e. you can pick validate, initialize and generate-sources phase of maven for same.