11

With the GWT compiler, is it possible set pass in properties as arguments to the GWT compiler? I know you can pass in certain defined parameters such as -war and -style, but this is for passing in property values, such as "user.agents" or "locale".

From what I can see of the documentation, the properties can only be set using from within the module descriptor. But I want to be able to control these properties externally, from my build script.

I've tried looking for documentation on what arguments are supported by com.google.gwt.dev.Compile, but there doesn't appear to be any reference documentation for that class. The docs are long on how-tos, and distressingy short on detail.

Mark Renouf
  • 30,697
  • 19
  • 94
  • 123
skaffman
  • 398,947
  • 96
  • 818
  • 769

3 Answers3

12

The answer is no!

I've asked the exact same question in the commiters newsgroup and currently there is nothing available.

They are thinking about adding support of supplying an extra .gwt.xml to override/configure things externally. This would cover what I wanted to do, but if you really want a generic access to the Properties at compile time then I'm afraid this is not possible.

Maybe you should create a Functional Request... let me know I'll put a start on it as well since it would be very usefull to switch on/off certain things from the compiler command line operation.

David Nouls
  • 1,895
  • 12
  • 21
  • Such certainty is appreciated, even if it's not what I wanted to hear :) – skaffman Jun 18 '09 at 15:24
  • 2
    The feature is in the works already. The plan is to be able to pass property values like user.agent and locale on the command line. This will be equivalent to adding a set-property in your .gwt.xml file. – Kelly Norton Sep 01 '09 at 17:41
  • @KellyNorton Any progress on this so far? – Piotr Sobczyk Feb 14 '12 at 13:24
  • 1
    @PiotrSobczyk Sadly no, the work to expose deferred binding properties to the command line was pushed back in priority because big apps were already using tools to generate module files. Of course, the practice of doing so confirms the need for this feature and I hope it will happen at some point in the future. – Kelly Norton Feb 18 '12 at 15:37
  • Yeah, we too ended up generating our module file. But passing properties from command line would be much easier and cleaner. I hope it will be implementet sooner or later. Thanks for your answer! – Piotr Sobczyk Feb 19 '12 at 10:54
  • Any progress on setting these from the command line? Thanks. Eugen. – Eugen May 03 '12 at 14:19
4

It does take arguments. An example from an ant build file I wrote:

<target name="compile.gwt" depends="compile">
    <java failonerror="true" classname="com.google.gwt.dev.Compiler" fork="true">
        <arg value="-war" />
        <arg value="${webcontent.dir}" />
        <arg value="-style" />
        <arg value="obfuscated" />
        <arg value="${module.name}" />
        <jvmarg value="-Xmx256m" />
        <jvmarg value="-Xss64M" />
        <classpath>
            <path refid="project.class.path" />
            <pathelement path="${gwt.home}/gwt-dev-windows.jar" />
        </classpath>
    </java>
</target>

I think this covers all the flags:

Debugging and Compiling - Google Web Toolkit - Google Code

As far as whether you pass user agents, I haven't seen it, but I haven't looked, either.

Don Branson
  • 13,631
  • 10
  • 59
  • 101
3

If the generator is a custom class, then you can always pass -Dname=value arguments to the java command and access them with System.getProperty("name"). Even if the generator is canned, perhaps you could subclass it and inject/override properties by wrapping the GeneratorContext passed to the superclass and replacing its PropertyOracle.

Nathan Williams
  • 951
  • 9
  • 12