Invoking Enunciate
Enunciate can be invoked in a variety of different ways:
A set of source files to be enunciated is always required. While invoking Enunciate without any options is valid, doing so will probably not get you the result that you want because Enunciate won't know where to put its artifacts, defaulting to an unspecified temporary location. So make sure you specify an artifact to export or a specific location to which to build.
Each module exports its own set of artifacts. Here's a quick reference to the available artifacts. Refer to the module documentation to find more details on what each module does. Most often, it's the fully-packaged war exported by the spring app module, so you'll want to export the artifact identified by the id "spring.war.file".
Ant
There's an Ant task available, org.codehaus.enunciate.main.EnunciateTask. This task is an extension of a MatchingTask, so use the matching task functionality to select the source files on which to invoke Enunciate. Here's a table of the additional attributes:
Nested Elements
In addition to the nested elements of a MatchingTask that are used to select the source files on which to invoke Enunciate, the EnunciateTask supports two additional nested elements.
Example
... <path id="enunciate.classpath"> <fileset dir="${enunciate.home}/lib"> <include name="**/*.jar"/> </fileset> <fileset dir="${enunciate.home}"> <include name="enunciate-full-*.jar"/> </fileset> <fileset dir="${java.home}"> <include name="lib/tools.jar"/> </fileset> </path> <taskdef name="enunciate" classname="org.codehaus.enunciate.main.EnunciateTask"> <classpath refid="enunciate.classpath"/> </taskdef> <enunciate basedir="src/main/java"> <include name="**/*.java"/> <classpath refid="enunciate.classpath"/> <export artifactId="spring.war.file" destination="${tomcat.home}/webapps/myapp.war"/> </enunciate> ...
Exports the fully-packaged, fully operational war (the artifact identified by the id "spring.war.file") to ${tomcat.home}/webapps/myapp.war, assuming ${enunciate.home} refers to the enunciate home directory. Note that it's important to include $JAVA_HOME/lib/tools.jar on the classpath when invoking Enunciate.
Maven
The Maven 2 Enunciate plugin is used to invoke Enunciate in the context of a Maven 2 POM. The groupId of the artifact is "org.codehaus.enunciate" and the artifact is "maven-enunciate-plugin". There are actually two ways to use the Maven Enunciate plugin. The first is by attaching a standard goal named "assemble" to a phase in the build lifecycle. The second is by simply leveraging the "enunciate-app" packaging. Both methods provide the same result. The former is for use with the Maven "war" packaging and leverages the Maven War plugin to package up the war. The latter uses Enunciate's internal mechanisms to build and package the war.
Note the following configuration parameters:
Example
The following is a pom for the enunciate application. The enunciate configuration file is located at "path/to/enunciate.xml" relative to the pom directory. The JDK 1.4 client library jar (identified by artifact id "client.jdk14.library.binaries") is exported to "target/client.jar" during the "package" phase. Resources are copied and tests are run as usual with the Maven build lifecycle.
<project ...> <modelVersion>4.0.0</modelVersion> <groupId>com.ifyouwannabecool.war</groupId> <artifactId>ifyouwannabecool</artifactId> <packaging>war</packaging> <version>1.7</version> <name>ifyouwannabecool</name> <url>http://www.ifyouwannabecool.com</url> <build> <plugins> <plugin> <groupId>org.codehaus.enunciate</groupId> <artifactId>maven-enunciate-plugin</artifactId> <configuration> <configFile>enunciate.xml</configFile> <exports> <client.jdk14.library.binaries>client.jar</client.jdk14.library.binaries> </exports> </configuration> <executions> <execution> <goals> <goal>assemble</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.codehaus.enunciate</groupId> <artifactId>enunciate-rt</artifactId> <version>1.7</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project>
Command-Line Scripts
In the distribution bundle, you can find a bash script and a batch file that you should be able to use to invoke Enunciate. The script attempts to invoke org.codehaus.enunciate.main.Main with the full classpath (see dependencies). The scripts rely on the following environment variables being set:
The main argument(s) to the script are the list of source files that are to be enunciated. Options are passed passed with a dash ("-"). You will usually want to specify an artifact to export with the -E[artifactId] option. The following is a list of the other available options (options that specify a value will assume the argument after the option is the option value):
Programmatic Interface
The programmatic entry point is org.codehaus.enunciate.main.Enunciate. Just instantiate one of these, configure it as needed, and call execute(). Refer to the Javadocs and source code for more information.