users@jersey.java.net

Re: [Jersey] WADL + Ant

From: Andrew Ochsner <aochsner_at_cs.stanford.edu>
Date: Mon, 2 Feb 2009 15:21:47 -0700

So here's my first cut at it. Seems to work. Obviously could refactor out
the shared stuff between the Mojo and the Task. And could add more options
to make the Task more robust (various ways you could pass in things).

But all that aside, this is ultimately what I need for my project. Am open
to all sorts of changes or suggestions, but unfortunately that will have to
be in the free time I get as I'm already behind on getting this generated.
Hopefully someone will find this useful...useful enough to make it into this
contrib...

Obviously also had to add ant as a dependency to the pom:
        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant</artifactId>
            <version>1.7.1</version>
            <scope>provided</scope>
        </dependency>

And the example for hooking into your ant build looks like
(project.classpath contains all of my libs i'm dependent on including the
jersey libs and the maven-wadl-plugin-<version>.jar):
    <taskdef name="generatewadl"
classname="com.sun.jersey.wadl.GenerateWadlTask"
classpathref="project.classpath" />
    <target name="wadl" depends="jar" description="generate wadl doc">
        <mkdir dir="${build}/classes/wadl" />
        <javadoc access="public" classpathref="project.classpath">
            <fileset dir="${src.main}/java" defaultexcludes="yes">
                <include name="**/*Resource.java" />
            </fileset>
            <doclet name="com.sun.jersey.wadl.resourcedoc.ResourceDoclet"
pathref="project.classpath">
                <param name="-output"
value="${build}/classes/wadl/resourcedoc.xml" />
            </doclet>
        </javadoc>
        <generatewadl wadlFile="${build}/classes/wadl/application.wadl"
formatWadlFile="true" baseUri="<base_uri>">
            <classpath>
                <!-- have to add the path to your compiled resources as
well! -->
                <pathelement location="${build}/classes/main" />
                <path refid="project.classpath" />
            </classpath>
            <packages>
                <package name="<packages_with_resources>" />
            </packages>
            <wadlGenerators>
                <wadlGeneratorDescription
name="com.sun.jersey.server.wadl.generators.resourcedoc.WadlGeneratorResourceDocSupport">
                    <param name="resourceDocFile"
value="${build}/classes/wadl/resourcedoc.xml" />
                </wadlGeneratorDescription>
            </wadlGenerators>
        </generatewadl>
    </target>


So...whereto from here?


On Sat, Jan 31, 2009 at 7:43 PM, Martin Grotzke <martin.grotzke_at_freiheit.com
> wrote:

> On Sat, 2009-01-31 at 12:59 -0700, Andrew Ochsner wrote:
> > Yeah I'm actually at the point now that I want to generate the wadl
> > at build time I think because 1) i don't want to have to do a whole
> > deploy cycle to test out small changes in the docs and 2) i'd like to
> > apply a stylesheet to it (the wadl -> html one).
> Exactly the same reasons as for me at that time *g*
>
> >
> > Started down the path of doing the Ant task creation, but then the
> > weekend came. Think I'll pick it up on Monday. Shouldn't be too
> > difficult.
> Great! Do you want to contribute the ant task to jersey?
>
> If I can help with s.th. let me know.
>
> Cheers,
> Martin
>
>
> >
> > On Fri, Jan 30, 2009 at 3:21 PM, Martin Grotzke
> > <martin.grotzke_at_freiheit.com> wrote:
> > Hi Andrew,
> >
> > thanx for adding the part that shows how to use the
> > ResourceDoclet with
> > ant in the wiki!
> >
> > I suppose you're using the wadl from your running webapp and
> > that you do
> > not want/need to have the wadl generated at build time, right?
> >
> > My hint in the wadl-wiki page ([1]) referring to the
> > maven-wadl-plugin
> > and ant was also related to the part of the plugin, that
> > generates the
> > wadl at build time (the main purpose of the plugin,
> > demonstrated by the
> > generate-wadl sample). This part (the GenerateWadlMojo) should
> > be more
> > or less easily be ported to ant.
> >
> > The maven-wadl-plugin still contains the ResourceDoclet, which
> > should be
> > extracted as a separate artifact/project (see also my next
> > mail on this
> > topic).
> >
> > Cheers,
> > Martin
> >
> >
> > [1] http://wikis.sun.com/display/Jersey/WADL
> >
> >
> >
> > On Thu, 2009-01-29 at 12:02 -0700, Andrew Ochsner wrote:
> > > Hi everyone:
> > >
> > > Been perusing the WADL wiki pages as a start for generating
> > some
> > > documentation from our Rest implementation. Want to add the
> > javadoc
> > > parsing bits, but seems the only examples are for Maven
> > (with comments
> > > that anyone doing it Ant should contribute in).
> > >
> > > Just a quick check before I dive in, has anyone made any
> > progress on
> > > this?
> > >
> > > Thanks
> > > Andy O
> >
> > --
> > Martin Grotzke
> > http://www.javakaffee.de/blog/
>
> --
> Martin Grotzke
> http://www.javakaffee.de/blog/
>