0

I have an Eclipse webapp project that I am trying to migrate from Ant build to Maven build. I have a lot of non-Java files in my src/ folder, for example log4j2.xml, ehcache.xml, some .properties localization files etc.

When I run war:war target on this project, the resulting WAR file contains only the .class files in the WEB-INF/classes folder, all the non-Java files are missing. In Ant I did this:

<target name="copy-resources" depends="compile">
  <copy todir="${build}">
    <fileset dir="${src}">
      <exclude name="**/*.java"/>
    </fileset>
  </copy>
</target>

How do I achieve the same thing in Maven? I suspect I should be using the resources folder, but right now I am trying to migrate with as little changes to the original codebase as possible...

vektor
  • 3,312
  • 8
  • 41
  • 71
  • please take a look at this:http://stackoverflow.com/questions/4760827/maven-how-to-get-a-war-package-with-resources-copied-in-web-inf – user3487063 Aug 22 '14 at 18:40
  • 2
    Resources belong in `src/main/resources`. They will be packaged automatically. You will be better off putting them where they belong than twisting Maven around to fit a non-Maven project structure. – Dave Newton Aug 22 '14 at 18:53

1 Answers1

3

You can access these files from resources folder. I hope this link helps.

You can also specify the folder, if it is not the default resources folder, in the pom.xml. See Specifying resource directories.

For example, if your folder has these files in src/my-resources, then you need to add this to the pom.xml, and then you would be able access it in code.

   <resources>
     <resource>
       <directory>src/my-resources</directory>
     </resource>
   </resources>
kc2001
  • 5,008
  • 4
  • 51
  • 92