I have a Maven 2 RESTful application using Jersey/JAXB. I generate the JAXB beans from a schema file, where the schema file is in my resources directory, e.g., src/main/resources/foo.xsd.
I want to include foo.xsd file in the generated Maven site for my project, so that clients can see the XML schema when writing RESTful calls.
How can I include foo.xsd in the site?
I could have a copy of the file in src/main/site/..., and then update my site.xml to point to it (or have a .apt whose contents point to it), but I don't like that because I'm still tweaking foo.xsd, and don't want to have to remember to copy it each time I update it. And that's just bad practice.
I also tried having a .apt file that has a link to the foo.xsd which gets copied to the target/classes directory. That works until I do a site:deploy, because that only copies the target/site directory.
Thanks,
Charles
To add resources to your site, you'll have to include them in a resources directory:
. `-- src `-- site `-- resources `-- foo.xsd
To keep this file in sync with the generated one, you could simply use the maven antrun plugin to copy the generated file from src/main/resources
to the above location, for example during the pre-site
phase:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>pre-site</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<copy file="src/main/resources/foo.xsd" todir="src/site/resources"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
Finally, add a link to this foo.xsd
in your site descriptor (the site.xml
file).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With