0

I have a webservice that will be referring to an XSD file that is in another project (imported as a dependency). I am able to pull the XSD in using the plugin in the following post. However, this pulls it directly into the source. I would rather have it added to the build directory to avoid committing the file.

If I extract the xsd to my existing project structure:

<outputDirectory>schema</outputDirectory>

It shows up in the .jar. However, if I extract it to the build directory:

<outputDirectory>${project.build.directory}/generated/schema</outputDirectory>

It does not show up in the .jar (even if I add it to the build path).

I think I am missing some fundamental understanding of the maven lifecycle. What do I need to do in order to get a file into the .jar while keeping the file in the build directory?

Community
  • 1
  • 1
Tyler Murry
  • 2,705
  • 3
  • 29
  • 46

1 Answers1

1

You can use the Maven Resource Plugin in order to add additional resources (that will be packed into final archive) and which are not into the usual resource directory aka src/main/resources/:

<project>
 ...
 <build>
   ...
   <resources>
     <resource>
       <directory>${project.build.directory}/generated/schema</directory>
     </resource>
   </resources>
   ...
 </build>
 ...
</project>
tmarwen
  • 15,750
  • 5
  • 43
  • 62
  • Is there any way to tell Maven that I want to use this directory in addition to the directories that are already defined? This snippet is actually overriding them. – Tyler Murry Sep 06 '14 at 22:00
  • Where does those directories are defined? You can provide as many `` directories as you want, so that won't be that hard. – tmarwen Sep 06 '14 at 22:14