Groovy SwingBuilder()apple.awt.CToolkit异常

ahm*_*mad 8 macos groovy gradle swingbuilder

我正在使用最新的Mac OS X,我正在Gradle文件中创建一个GUI元素.我目前正在使用jdk1.7.0_55并且我已导入groovy.swing.SwingBuilder,当我运行该项目时,我收到以下错误:

java.awt.AWTError:"找不到工具包:apple.awt.CToolkit

我已经尝试使用脚本作为无头服务器运行 System.setProperty('java.awt.headless', 'true')

我想有一个解决方案,我可以直接包含在Gradle项目文件中,而不是试图找出我的accesibilities.properties文件中的内容(在特定系统上可能不存在,就像我的系统上没有).

此外,项目必须使用内部解决方案,不允许使用外部库.

非常感谢你对此事的任何帮助.

编辑:示例代码

gradle.taskGraph.whenReady { taskGraph ->
if(taskGraph.hasTask(':CustomApp:assembleRelease')) {

    def pass = ''
    if(System.console() == null) {
        new SwingBuilder().edt {       // Error occurs here.
            dialog(modal: true, 
                alwaysOnTop: true,
                resizable: false,
                locationRelativeTo: null,
                pack: true,
                show: true 
        )
            {
                vbox {
                    label(text: "Enter password:")
                    input = passwordField()
                    button(defaultButton: true, text: 'OK', actionPerformed: {
                        pass = input.password;
                        dispose();
                    })
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Ren*_*tus 0

我在 Android Studio 0.8.6 中遇到了同样的问题,并通过自定义 gradle 安装解决了它。刚刚下载了 gradle 1.12 并在首选项中设置了它的路径。