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?

0

1 Answer 1

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> 
Sign up to request clarification or add additional context in comments.

2 Comments

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.
Where does those directories are defined? You can provide as many <resource> directories as you want, so that won't be that hard.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.