Matthew Layton
Matthew Layton

Reputation: 42229

Gradle - Run Application From Test Module

I currently have the following gradle to run an application

apply plugin: 'application'

application {
    mainClassName = 'com.Example'
}

This doesn't work as the Example class is in the test module as it's not meant to be released in production code. Is there any way to specify to gradle to look in the test module, instead of the main module?

Upvotes: 0

Views: 115

Answers (1)

Matthew Layton
Matthew Layton

Reputation: 42229

Solution was to not use the application module; instead...

apply plugin: 'java'

task runExample(type: JavaExec) {
    classpath = sourceSets.test.runtimeClasspath
    main = 'com.Example'
}

Upvotes: 1

Related Questions