Grails gradle:如何设置系统属性

Grails gradle:如何设置系统属性,grails,gradle,build.gradle,Grails,Gradle,Build.gradle,我可以知道为什么在使用grails gradle插件时无法使用systemProperty方法设置系统属性吗 我的build.gradle如下所示: buildscript { repositories { jcenter() } dependencies { classpath "org.grails:grails-gradle-plugin:2.0.0" } } version "0.1" group "example" apply plugin: "gr

我可以知道为什么在使用grails gradle插件时无法使用systemProperty方法设置系统属性吗

我的build.gradle如下所示:

buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath "org.grails:grails-gradle-plugin:2.0.0"
  }
}

version "0.1"
group "example"

apply plugin: "grails"

repositories {
  grails.central() //creates a maven repo for the Grails Central repository (Core libraries and plugins)
}

grails {
  grailsVersion = '2.3.5'
  groovyVersion = '2.1.9'
  springLoadedVersion '1.1.3'
}

dependencies {
  bootstrap "org.grails.plugins:tomcat:7.0.50" // No container is deployed by default, so add this
  compile 'org.grails.plugins:resources:1.2' // Just an example of adding a Grails plugin
}

test {
  println "I'm in the test"
  //Could not find method systemProperty() for arguments [geb.env, sauce] on root project
  systemProperty 'geb.env', 'sauce'//Fails

}
在测试任务中,我在运行
$gradle grails test
时遇到以下错误: 在根项目上找不到参数[geb.env,sauce]的方法systemProperty()


这是grails gradle插件的问题吗?因为其他插件(如“java”)允许我使用setProperty?谢谢。

错误消息是正确的:没有systemProperty()方法

正如Joshua Moore所言,这应该是可行的:

test {
  println "I'm in the test"
  System.setProperty 'geb.env', 'sauce'
}

你试过System.setProperty('geb.env','saint')吗?