UndefinedReference
UndefinedReference

Reputation: 1253

Gradle: Could Not Fetch Model of Type 'EclipseProject'

This is the first time I'm using Gradle, and I'm fairly new to Java as well. I'm using Eclipse Neon, Gradle 3.4 and JDK 1.8.

When attempting to set up a Gradle application, I get the following error:

Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method mainClassName() for arguments [com.mycompany.app.MyMapApp] on task ':run' of type org.gradle.api.tasks.JavaExec.

It's complaining about line 25 in my build.gradle file, which is:

run { mainClassName 'com.mycompany.app.MyMapApp'}

I'm not sure if the mainClassName I'm specifying should be different, or if there's something wrong with my version of Gradle?

Has anyone run into this themselves, and if so, how did you resolve it?

Upvotes: 0

Views: 1256

Answers (1)

Martin Linha
Martin Linha

Reputation: 1019

You are missing equal sign (=) between mainClassName and 'com.mycompany.app.MyMapApp'. You can take mainClassName 'com.mycompany.app.MyMapApp' outside of the run { ... } block.

Simple, complete example of your build.gradle can look like following

apply plugin: 'java'
apply plugin: 'application'

mainClassName = 'com.mycompany.app.MyMapApp'

Upvotes: 1

Related Questions