How to add a file from my source tree to the Maven site

I have a Maven 2 RESTful application using Jersey / JAXB. I am generating JAXB beans from a schema file where the schema file is in my resource directory, for example src / main / resources / foo.xsd.

I want to include the foo.xsd file in the Maven site I created for my project so that clients can see the XML schema when making RESTful calls.

How to include foo.xsd in the site?

I could copy the file to src / main / site / ... and then update my site.xml to point to it (or have a .apt file whose contents point to it), but I don’t know, It looks like that I am still setting up foo.xsd and don’t want to remember to copy it every time I update it. And this is just bad practice.

I also tried to have a .apt file that has a link to foo.xsd, which is copied to the target / classes directory. This works until I make the site: deploy, because it only copies the target / site directory.

Thanks,

Charles

+5
source share
2 answers

To add resources to your site, you must include them in the resource directory:

.
`- src
    `- site
        `- resources
            `- foo.xsd

To synchronize this file with the created one, you can simply use the maven antrun plugin to copy the generated file from src/main/resourcesto the above location, for example, during the phase pre-site:

  <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.xsdin the site descriptor (file site.xml).

+6

. , , Maven.

0

All Articles