Application plugin won't run - "No value has been specified for property 'mainClassName'" error


(Douglas Bullard) #1

I’m trying to run code using the application plugin, and it won’t run - I get the “No value has been specified for property ‘mainClassName’” error.

Here’s a slimmed down version of my build.gradle script:

apply plugin: ‘java’ apply plugin: ‘application’

mainClassName = “com.nurflugel.ivybrowser.ui.IvyBrowserMainFrame”

repositories and Ivy dependencies listed…

When I run, I get

gradle run :compileJava UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :run

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:run’. Cause: No main class specified

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

The stacktrace, of course, says there’s no main class specified: Caused by: java.lang.IllegalStateException: No main class specified

According to the documentation page, I believe I’ve got my main class specified correctly - any clue why that’s not being picked up?

I’m using 1.0 milestone 7, btw.

Thanks,

Douglas Bullard


(René Groeschke) #2

Hi Douglas, your snippet looks okay. I’ve just double-checked the sample in the user guide and it works fine with milestone7. Do you manually change something of the run task itself? Can you provide your whole build script?

regards, René


(Douglas Bullard) #3

build.gradle now consists of:

apply plugin: ‘application’

mainClassName = “com.nurflugel.RunMe”

in src/main/java/com.nurflugel, there is a Java file called RunMe.java:

package com.nurflugel;

public class RunMe

{

public static void main(String[] args)

{

System.out.println(“This is running correctly”);

}

}

I tried running with the latest build of milestone 8, same result as before.

I know the class compiled, because I can see it:

find . -name RunMe.*

./build/classes/main/com/nurflugel/RunMe.class

./src/main/java/com/nurflugel/RunMe.java


(Douglas Bullard) #4

Ah, I figured it out - I had a “gradle.properties” file, where a while back I’d also tried to specify the mainClassName. Gradle doesn’t like it there. Take the same line from the build script, put it there, and it won’t work, even though the two lines are identical.

It works properly now, when I specify it only in build.gradle.