我可以将参数(延迟绑定属性)传递给GWT编译器吗?

时间:2022-01-03 13:40:05

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".

使用GWT编译器,是否可以将属性作为参数传递给GWT编译器?我知道您可以传入某些定义的参数,例如-war和style,但这是用于传递属性值,比如“user”。代理”或“语言环境”。

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.

我已经尝试寻找关于com.google.gwt.dev.Compile支持哪些参数的文档,但是似乎没有任何该类的引用文档。这些文档很长时间都在做如何做的事情,也很短的细节。

3 个解决方案

#1


12  

The answer is no!

答案是否定的!

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

我在commiters新闻组中问了同样的问题,目前没有可用的东西。

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.

他们正在考虑增加对提供额外的.gwt的支持。xml在外部覆盖/配置事物。这将涵盖我想要做的事情,但是如果您真的希望在编译时对属性进行通用访问,那么恐怕这是不可能的。

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.

也许你应该创建一个功能请求……请让我知道,我也将对它进行启动,因为从编译器命令行操作中打开/关闭某些东西是非常有用的。

#2


4  

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

它把参数。我在一个ant构建文件的例子中写道:

<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

调试和编译-谷歌Web工具包-谷歌代码

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

至于你是否通过用户代理,我还没见过,但我也没看过。

#3


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.

如果生成器是一个自定义类,那么您总是可以将-Dname=value参数传递给java命令,并使用System.getProperty(“name”)访问它们。即使生成器是封闭的,也可以通过封装传递给超类的GeneratorContext并替换其PropertyOracle对其进行子类化并注入/重写属性。

#1


12  

The answer is no!

答案是否定的!

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

我在commiters新闻组中问了同样的问题,目前没有可用的东西。

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.

他们正在考虑增加对提供额外的.gwt的支持。xml在外部覆盖/配置事物。这将涵盖我想要做的事情,但是如果您真的希望在编译时对属性进行通用访问,那么恐怕这是不可能的。

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.

也许你应该创建一个功能请求……请让我知道,我也将对它进行启动,因为从编译器命令行操作中打开/关闭某些东西是非常有用的。

#2


4  

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

它把参数。我在一个ant构建文件的例子中写道:

<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

调试和编译-谷歌Web工具包-谷歌代码

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

至于你是否通过用户代理,我还没见过,但我也没看过。

#3


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.

如果生成器是一个自定义类,那么您总是可以将-Dname=value参数传递给java命令,并使用System.getProperty(“name”)访问它们。即使生成器是封闭的,也可以通过封装传递给超类的GeneratorContext并替换其PropertyOracle对其进行子类化并注入/重写属性。