Lunchbox
Lunchbox

Reputation: 1550

IntelliJ IDEA 2016.3.4 gradle how to run the java project

how can I run my gradle project? Its a GUI application. I just want to run it so I can test it. Created a gradle project, copied my src file in and marked it as a source file (blue file). Now when I click run, the project runs all the gradle tasks but my application does not start. Here is my build.gradle file:

group '1'
version '1.0-SNAPSHOT'

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

mainClassName = 'Main'
version = '1'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

jar {

    baseName = 'JavaWinApp'
    from files(sourceSets.main.output.classesDir)
    from files(sourceSets.main.output.resourcesDir)
    from { configurations.compile.collect { zipTree(it) } }

    manifest {
        attributes 'Implementation-Title': 'JavaWinApp'
        attributes 'Implementation-Version': version
        attributes 'Main-Class': 'Main'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'org.codehaus.groovy:groovy-all:2.3.11'
    testCompile group: 'junit', name: 'junit', version: '4.11'
    compile 'com.intellij:forms_rt:6.0.5'
}

Can you see anything blatantly obvious that I should change or can you give me any pointers?

Please let me know if you require any other information and I will happily supply it. I am an utter noob with this. My only exposure to gradle is through Android Studio, there all just runs fine. Looks like I'm missing something obvious, but cannot seem to find it.

Thank you in advance

Upvotes: 1

Views: 8681

Answers (1)

dpr
dpr

Reputation: 10964

The gradle application plugin should add a run task to your build, that will start your application. To execute this task you will need to create a run configuration in IntelliJ for this task. See this documentation on how to create a gradle run/debug configuration.

Upvotes: 4

Related Questions