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.

Related Posts:

  • Apache Cassandra ClusteringThis tutorial will help us configure an Apache Cassandra's ring with 2 nodes. It will not explain what Cassandra is, use Google for that.There are act… Read More
  • Social Login using REST FBThis is an implementation tutorial on how we can use REST FB to enable facebook social login on our web application.Basically, it's a project created … Read More
  • Install Java8 in UbuntuA set of commands to install Java8 on Ubuntu.sudo add-apt-repository ppa:webupd8team/javasudo apt-get updatesudo apt-get install oracle-java8-installe… Read More
  • Hadoop MapReduce DemoVersions:Hadoop 3.1.1 Java10Set the following environment variables:JAVA_HOME HADOOP_HOMEFor WindowsDownload Hadoop 3.1.1 binaries for windo… Read More
  • Hibernate OGM for MongoDBSo lately I've been playing with Hibernate OGM MongoDB's latest version 5.4.0.Beta2 but I'm not able to run a demo project created from wildfly-javaee… Read More

0 nhận xét:

Đăng nhận xét