Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle error: "Could not find property '...' on root project '...'

I try do build my Java project with Gradle and I'm getting the following:

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

Line 25 of build.gradle: mainClassName = myJavaPackage.runner.MainRunner

In settings.gradle I have: rootProject.name = 'MyJavaProject'

Project directory structure:

MyJavaProject-> main -> java -> myJavaPackage -> runner -> MainRunner

I'm using Gradle 11.1

Since the stack trace is huge I did not post the entire one.

Close to the bottom it shows:

Caused by: groovy.lang.MissingPropertyException: Could not find property 'myJavaPackage' on root project 'MyJavaProject'.

I searched for this type of error but the answers were mostly about upgrading Gradle from an old version to a newer one.

What did I do wrong?

like image 230
PM 77-1 Avatar asked Apr 29 '14 03:04

PM 77-1


People also ask

How do I pass project property in gradle?

Using the -D command-line option, you can pass a system property to the JVM which runs Gradle. The -D option of the gradle command has the same effect as the -D option of the java command. You can also set system properties in gradle. properties files with the prefix systemProp.

Where is the root build gradle?

gradle files are located. The build. gradle (Project: MyApplication) file is in the root folder of the project and its configuration settings apply to every module in the project.

How to resolve gradleout could not resolve problem?

A problem occurred configuring root project 'gradleOut'. > Could not resolve al 1 1.Change the position of jcenter and google in project gradle file and in also all the other module you have in your... 2 Before building your project again go to your project folder and delete the .gradle folder from your project and then... More ...

Why can't I see Gradle in my system?

If not, here are some things you might see instead. If you get "command not found: gradle", you need to ensure that Gradle is properly added to your PATH. If you get something like: ERROR: JAVA_HOME is set to an invalid directory Please set the JAVA_HOME variable in your environment to match the location of your Java installation.

How do I add Gradle-processors to a subproject?

You need to apply the gradle-processors plugin to your subprojects, not the top-level project. I would recommend configuring your subprojects in a separate file, e.g. A/build.gradle, B/build.gradle, rather than having one huge top-level file like this. You can pull those files in in your settings.gradle: Sorry, something went wrong.

Why does Gradle get permission denied?

If you get "permission denied", that means that Gradle likely exists in the correct place, but it is not executable. You can fix this using chmod +x path/to/executable on *nix-based systems.


1 Answers

Correct is (notice the quotes):

mainClassName = "myJavaPackage.runner.MainRunner"
like image 171
Peter Niederwieser Avatar answered Nov 10 '22 03:11

Peter Niederwieser