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
-
Take a look at this link. It describes how to customize navigation and add resources to the Maven generated site.
Charles O. : Thanks, I'd seen that link, and that's where I got the idea that's in my question about copying the .xsd file from my src/main/resources tree to the /src/site tree. Which is a solution I don't like... The link describes how to add static files to the src/site tree to appear in the report; I'm trying to avoid having two copies of my .xsd file. I'm hoping there's a way I can do this without writing my own Maven reporting plug-in.Taylor Leese : Just copy the file to the location you need as part of the Maven build. Pascal suggests one way to do this. -
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 thepre-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 (thesite.xml
file).Charles O. : Thanks, that works perfectly!Pascal Thivent : @Charles You're welcome.
0 comments:
Post a Comment