GWT: 2.6 -> 2.8 不再支持 System.getProperty("line.separator")。

3

我正在更新我的libgdx游戏,使用GWT 2.8代替2.6。然而,我遇到了一个问题,编译器不接受我的几个对System.getProperty("line.separator")的调用:

[ERROR] Errors in 'com/hgames/core/dm/grid/TextMapParser.java'
  [ERROR] Line 138: Property 'line.separator' is not defined.

我感到困惑,因为之前它被接受了,而且我找不到关于模拟系统属性的信息。我使用gradle构建,并使用“gwtVersion ='2.8.0'”指定了gwt的版本。

1个回答

3
这是2.8.0-beta1版本新增的功能(http://www.gwtproject.org/release-notes.html#Release_Notes_2_8_0_BETA1)。您可以使用System.getProperty方法获取在gwt.xml或使用命令行(-setProperty)中定义的用户属性。

使用命令行:

在您的模块中:

<define-configuration-property name="project.version" is-multi-valued="false"/>

在您的gwt编译器/开发模式命令行中

-setProperty project.version=1.2.3

示例 https://github.com/ibaca/gwt-dagger2-coffee

仅使用模块:

在您的模块中

<define-configuration-property name="someConfigurationProperty" is-multi-valued='false'/>
<set-configuration-property name="someConfigurationProperty" value="conf"/>

示例 https://github.com/gwtproject/gwt/blob/a90832fec9a56f4cb83ed009c7048e0a8d196fe8/user/test/com/google/gwt/emultest/java/lang/SystemTest.java#L320

此链接是指向GWT项目的一个Java测试文件中的第320行代码。

话虽如此,我不明白这怎么会导致回归,因为System.getProperty不应该在早期版本中起作用。 - Thomas Broyer
是的,我也这么想...也许gdx有超级源getProperty...嗯。 - Ignacio Baca
2
是的,这就是问题所在 https://github.com/libgdx/libgdx/commit/7ed40698018bb789916ffea6ca8b2a4f64961f92#diff-04e57b8ce51ea73dda5e3f402518370f - Ignacio Baca

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接