2

I use enunciate (1.27) to generate rest documentation as part of an ant build (1.9.2), as follows:

<enunciate basedir="${java.src.dir}" verbose="true" configfile="${basedir}/enunciate.xml" >
  <include name="**/*.java"/>
  <classpath refid="test.class.path"/>
  <export artifactId="docs" destination="${war.temp.enunciate.dir}"/>
</enunciate>

This was working just fine until I moved to java 7. Since then, I get:

...
[enunciate] warning: [options] bootstrap class path not set in conjunction with -source 1.5
...
[enunciate]   (use -source 7 or higher to enable try-with-resources)
...

I have tried using javacArgument to specify java 7 (using -source 7 and -source 1.7):

<enunciate basedir="${java.src.dir}" verbose="true" configfile="${basedir}/enunciate.xml" >
  <include name="**/*.java"/>
  <classpath refid="test.class.path"/>
  <export artifactId="docs" destination="${war.temp.enunciate.dir}"/>
  <javacArgument argument="-source 7"/>
</enunciate>

But I get the following error:

invoking enunciate:compile step...
[enunciate] javac: invalid flag: -source 7
[enunciate] Usage: javac <options> <source files>
[enunciate] use -help for a list of possible options

Here's my configfile (enunciate.xml):

<?xml version="1.0"?>
<enunciate label="DocumentCrucible"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.27.xsd">
  <deployment host="example.com" context="service"/>
  <namespaces>
    <namespace id="service" uri="http://example.com/service"/>
    <namespace id="bean" uri="http://example.com/bean"/>
  </namespaces>
  <services>
    <rest defaultRestSubcontext="/rest"/>
    </services>
  <modules>
    <docs splashPackage="com.example.rest" title="REST API" copyright="www.example.com"
        css="enunciate.css">
    </docs>
    <java-client>
        <package-conversions>
            <convert from="com.example" to="com.example.client"/>
        </package-conversions>
    </java-client>
    <jersey disableWildcardServletError="true" disabled="true" ></jersey>
  </modules>
</enunciate>

It looks like the enunciate task is specifying version 1.5 to javac, but I can't find where or how to override it. Anyone know what I'm doing wrong?

I'm using enunciate to generate documentation, not provide the rest services.

YetAnotherMatt
  • 391
  • 4
  • 9
  • See: http://stackoverflow.com/questions/7856472/will-compiling-for-java-1-5-on-java-1-7-still-work – Mark O'Connor Oct 05 '13 at 09:58
  • @MarkO'Connor: Thanks for the response. I think the issue is that enunciate is specifying a version of 1.5 when I don't want it to - which is then giving rise to the bootstrap classpath warning and error. I'm trying to find out how to tell enunciate to use java 7. – YetAnotherMatt Oct 05 '13 at 12:22

2 Answers2

3

As of 1.28 RC2, there is an option to provide -source and -target configuration parameters:

<enunciate javacSourceVersion="1.7" javacTargetVersion="1.7"  ...>
  ...
</enunciate>

http://dist.codehaus.org/enunciate/enunciate-1.28-RC2.zip

Ryan Heaton
  • 1,173
  • 7
  • 11
  • The URL you specified is broken. I've struggled all day to get Enunciate to build artifacts from my project (using JDK 6, 7 and 8, and trying a combination of all manner of libraries). I've tried Enunciate 1.27 and 1.31RC. Can you send me your copy of the library please? Here's what I keep getting: `java.lang.NoSuchMethodError: com.sun.tools.apt.util.Bark.printLines(Ljava/io/PrintWriter;Ljava/lang/String;)V at com.sun.tools.apt.main.Main.bugMessage(Main.java:1186) at com.sun.tools.apt.main.Main.compile(Main.java:831) at com.sun.tools.apt.Main.processing(Main.java:113)` – Sayo Oladeji Apr 18 '15 at 17:53
0

Having had a look at the source, org.codehaus.enunciate.main.Enunciate.java hard-codes the source version as 1.5 (at least in version 1.27 of Enunciate). The only solution I can see is to modify the source code of enunciate.

YetAnotherMatt
  • 391
  • 4
  • 9