GWT compiler option to simply validate code

15 views
Skip to first unread message

MonkeyMike

unread,
Nov 18, 2009, 8:52:05 PM11/18/09
to Google Web Toolkit
Hello,

I am creating a GWT Overlay Type library, and have just written an
ant build file for creating the JAR file that GWT applications will
import. To maintain code integrity, I make the JAR creation depend on
a java compile of all the code, and also a gwt compile. Obviously,
this is meant to ensure that the code in the library is acceptable
Java, and also that it is acceptable GWT.

When I run the GWT compiler, however, I get an error related to the
fact that my library has no entry point...

-------------------------
Buildfile: C:\Data\Dev\EclipseWorkspaceTrunk\gwtgfx\build.xml
javac-compile:
[javac] Compiling 2 source files to C:\Data\Dev
\EclipseWorkspaceTrunk\gwtgfx\build\javac
gwt-compile:
[java] Compiling module gwtgfx.GwtGfx
[java] [ERROR] Module has no entry points defined

BUILD FAILED
C:\Data\Dev\EclipseWorkspaceTrunk\gwtgfx\build.xml:25: The following
error occurred while executing this line:
C:\Data\Dev\EclipseWorkspaceTrunk\gwtgfx\build.xml:45: Java returned:
1

Total time: 3 seconds
-------------------------

Of course, it makes perfect sense that my library has no entry point
since it is, in fact, a library... not an application.

Is there an option for the GWT compiler to do only the parts that I
want here? I want the GWT compiler to ensure, for example, that all
of my JavaScriptObject subclasses follow the specified restrictions
(has a protected no-arg constructor, instance methods are final,
etc)... and anything else that the GWT compiler might do now, or in
the future, to check that the GWT code is valid. If not having an
entry point means that there is no reasonable way to do one or more of
the compiler steps, then that should be okay because those steps
probably aren't relevant for a library anyways.

As a temporary hack, I guess I am going to include an entry point,
but I really don't want to ship this. Is there a better alternative?

Thanks in advance. :)

MonkeyMike

unread,
Nov 18, 2009, 9:29:47 PM11/18/09
to Google Web Toolkit
Although I'm still very interested to get an answer to my previous
post, I have just implemented the "temporary hack" that I mentioned,
and I actually would say that it's a good approach. I created a
"Build" gwt module, which has an entry point, and inherits the overlay
type library. I edited my ant file's gwt-compile target so that it
runs a gwt-compile on the "Build" module, and the gwt-compile
succeeded. There are 2 nice things about this approach...

1) The "make-jar" target can create a jar file which only contains
code from the library, and so I don't have to ship the build module.

2) The Build module's entry point actually is a nice space to write
some code which uses the library, as another set of tests. I haven't
done this yet, but in theory I could write some code which calls all
of the code in the library, and this would ensure that the intended
usage of the library is compliant with the GWT compiler as well.
However, perhaps this is redundant if the library has a suite of unit
tests.

Anyways, as I said, I'm still curious to know how I might be able to
run the gwt-compiler to execute only those compile steps which are
relevant to a library (as opposed to an application).

Cheers,
Mike

Thomas Broyer

unread,
Nov 19, 2009, 5:19:32 AM11/19/09
to Google Web Toolkit
There's a -validateOnly flag that doesn't mandate an entry point (and
should check that all public classes can be compiled).

MonkeyMike

unread,
Nov 19, 2009, 1:12:16 PM11/19/09
to Google Web Toolkit
Awesome! Thanks! :)

MonkeyMike

unread,
Nov 23, 2009, 8:56:14 PM11/23/09
to Google Web Toolkit
Now that I am using the -validateOnly option, I can see that it is a
much better option than the special "Build" module that I created.
The GWT compiler ignores unused code, and so much of the code in my
library was not being validated when I compiled via the "Build"
module. But now that I am using the -validateOnly option, I can run
the compiler directly on the library, and it validates all of the
code.

Thanks again,
Mike
Reply all
Reply to author
Forward
0 new messages