How to generate jax-rs documentation using maven
Tech-Today

How to generate jax-rs documentation using maven


To generate the jax-rs documentation automatically using maven, we need to add some plugins in the build section of the project's pom file.

To avoid running this plugin every time you invoke mvn install, you can create a separate profile for it.

Here's the plugin definition:

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-plugin</artifactId>
<versionRange>[1.29,)</versionRange>
<goals>
<goal>docs</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-plugin</artifactId>
<version>1.29</version>
<executions>
<execution>
<goals>
<goal>docs</goal>
</goals>
<configuration>
<docsDir>${project.build.directory}/docs</docsDir>
<configFile>src/main/resources/enunciate.xml</configFile>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/generated-resources/schemagen/</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources/</directory>
<includes>
<include>jaxb.properties</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</pluginManagement>
</build>

And here's the content of enunciate.xml.
<?xml version="1.0"?>
<enunciate label="novaglobalapi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.25.xsd">

<api-classes>
<include pattern="org.broodcamp.api.rest.**" />
</api-classes>

<modules>
<docs docsDir="restapi" title="Broodcamp REST API" />
<c disabled="true" />
<csharp disabled="true" />
<obj-c disabled="true" />
</modules>
</enunciate>




- How To Package A Java Standalone App Using Maven Assembly
The sample codes below will assemble a zipped package of a java standalone app. Dependencies: maven-jar-plugin - to create the jarmaven-assembly-plugin - to assemble the distribution packagepom.xml<plugin> <groupId>org.apache.maven.plugins</groupId>...

- How To Generate Wadl Via Maven Plugin
So you've written your web service and would now want to create the wadl for it.  Assuming you have your web project in eclipse with maven integrated this is what you have to do: 1.) Add the lines below to your pom, you may want to create it's...

- How To Get Git Build Id Using Maven
There are times when git's build number is important for a release. Specially in development mode, when there are frequent releases. So if we want to append the build number on our page, how do we automate it? For us to achieve this we will need 2...

- A Maven Project That Have Multiple Property Files Via Maven Antrun Plugin
This tutorial will answer several questions (below) within a maven project that has several configuration files (dataset, property, persistence). 1.) How to have multiple persistence, datasource and property files depending on the profile or environment...

- How To Add Pmd Reporting To Maven
Before proceeding to this exercise, you may want to try my tutorial on how to setup a maven project to eclipse: http://czetsuya-tech.blogspot.com/2012/04/how-to-create-modularized-maven-project.html. Assuming you have follow the tutorial above, you should...



Tech-Today








.