views:

167

answers:

2

I'm using Enunciate to build a prototype REST api and need to include a jar containing custom code as a library.

My Ant Script looks like this:

<!--include all jars-->
<path id="en.classpath">
    <fileset dir="${lib}">
        <include name="**/*.jar" />
    </fileset>
</path>

<!--define the task-->
<taskdef name="enunciate" classname="org.codehaus.enunciate.main.EnunciateTask">
    <classpath refid="en.classpath" />
</taskdef>

<mkdir dir="${dist}" />

<enunciate dir="${src}" configFile="${basedir}/enunciate.xml">
    <include name="**/*.java" />
    <classpath refid="en.classpath"/>
    <export artifactId="spring.war.file" destination="${dist}/${war.name}" />
</enunciate>

The problem is that my custom jar is being excluded from the WAR file. It is necessary to compile the enunciate annotated classes so the jar is obviously on the classpath at compile time but enunciate is failing to include it in the distribution. I have also noticed that several of the jars needed by enunciate are not being included in the WAR file.

Why are they being excluded and how do I fix it?

+1  A: 

I never used enunciate, but as a quick hack you can add the jars to the war:

<jar jarfile="${dist}/${war.name}" update="true">
   <fileset dir="${lib}">
        <include name="**/*.jar" />
    </fileset>
</jar>

Note: you probably want to add the jars to the WEB-INF/lib directory, instead of the root directory.

I'm guessing that enunciate does the mininum to interfere with your own build process, since you know best what to put within your jar file.

Miguel Ping
A: 

As it turns out one of the jars we're attempting to include has a dependency listed in it's Manifest file of a jar that Enunciate depends on (freemarker). Enunciate automatically excludes freemarker and at first glance it seems as though it automatically excludes anything that depends on freemarker as well. If we remove freemarker from the list of dependent jars in our code's manifest file it works just fine.

However; I've spoken with the main developer of Enunciate (Ryan Heaten) and he assures me this isn't what's happening. Including his response below:

Really?!

Wow. Interesting. I can't explain it; Enunciate doesn't look at what's in the Manifest in order to determine what to include in the war, so I'm kind of stumped here. It could also be some weird Ant behavior (not including that jar in the "en.classpath" reference for some reason).

~Ryan

Randyaa