Gradle错误:"无法找到属性' ...'在根项目' ...'

时间:2014-04-29 03:49:45

标签: java groovy gradle build.gradle

我尝试使用Gradle构建我的Java项目,并且我得到以下内容:

Starting Build
Settings evaluated using settings file 'C:\Users\MyName\Java8\MyJavaProject\settings.gradle'.
Projects loaded. Root project using build file 'C:\Users\MyName\Java8\MyJavaProject\build.gradle'.
Included projects: [root project 'MyJavaProject']
Evaluating root project 'MyJavaProject' using build file 'C:\Users\MyName\Java8\MyJavaProject\build.gradle'.

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\MyName\Java8\MyJavaProject\build.gradle' line: 25

* What went wrong:
A problem occurred evaluating root project 'MyJavaProject'.
> Could not find property 'myJavaPackage' on root project 'MyJavaProject'.

<{1}}的行 25 build.gradle

mainClassName = myJavaPackage.runner.MainRunner我有:settings.gradle

项目目录结构

rootProject.name = 'MyJavaProject' - &GT; MyJavaProject - &gt; main - &gt; java - &gt; myJavaPackage - &gt; runner

我使用 Gradle 11.1

由于堆栈跟踪很大,我没有发布整个跟踪。

靠近底部显示:

  

引起:groovy.lang.MissingPropertyException:找不到   property&#39; myJavaPackage&#39;在根项目&#39; MyJavaProject&#39;。

我搜索了这种类型的错误,但答案主要是将Gradle从旧版本升级到新版本。

我做错了什么?

1 个答案:

答案 0 :(得分:9)

正确是(注意引号):

mainClassName = "myJavaPackage.runner.MainRunner"