How to generate wadl via maven plugin
Tech-Today

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 own profile. For example api.
<plugin>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>maven-wadl-plugin</artifactId>
<version>1.18.3</version>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
<configuration>
<wadlFile>${project.build.directory}/docs/application.wadl</wadlFile>
<formatWadlFile>true</formatWadlFile>
<baseUri>http://czetsuya-tech.blogspot.com/api/rest</baseUri>
<packagesResourceConfig>
<param>com.broodcamp.api.rest</param>
</packagesResourceConfig>
<wadlGenerators>
<wadlGeneratorDescription>
<className>com.sun.jersey.server.wadl.generators.WadlGeneratorApplicationDoc
</className>
<properties>
<property>
<name>applicationDocsFile</name>
<value>${project.basedir}/src/main/resources/application-wadl-doc.xml</value>
</property>
</properties>
</wadlGeneratorDescription>
<wadlGeneratorDescription>
<className>com.sun.jersey.server.wadl.generators.WadlGeneratorGrammarsSupport
</className>
<properties>
<property>
<name>grammarsFile</name>
<value>${basedir}/src/main/resources/application-wadl-grammar.xml</value>
</property>
</properties>
</wadlGeneratorDescription>
</wadlGenerators>
</configuration>
</plugin>

2.) Looking at the plugin configuration above, we now have 2 define 2 files:
application-wadl-doc.xml
<?xml version="1.0" encoding="UTF-8"?>
<applicationDocs targetNamespace="http://wadl.dev.java.net/2009/02">
<doc xml:lang="en" title="czetsuya-tech api">czetsuya-tech api</doc>
</applicationDocs>

application-wadl-grammar.xml
<?xml version="1.0" encoding="UTF-8" ?>
<grammars xmlns="http://wadl.dev.java.net/2009/02" />

3.) Now all you need to do is run the command below in command prompt:
>mvn -Papi clean compile com.sun.jersey.contribs:maven-wadl-plugin:generate
// note that we use api profile as defined above.




- 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 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 Enable Jersey Rest Api In A Maven Web Project
This tutorial assumes that you already know how to create a maven project in eclipse. Steps: 1.) Create a new maven web project. (this assumes that you have maven plugin installed in your eclipse). 2.) In your META-INF/web.xml file make sure that you...

- 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








.