Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

No clear sample/cannot override mainClassName for a task #1401

Open
NoPhaseNoKill opened this issue Apr 20, 2020 · 0 comments
Open

No clear sample/cannot override mainClassName for a task #1401

NoPhaseNoKill opened this issue Apr 20, 2020 · 0 comments

Comments

@NoPhaseNoKill
Copy link

NoPhaseNoKill commented Apr 20, 2020

Expected Behavior

Should be able to override mainClassName for a task.

Current Behavior

Uses the application's mainClassName - and does not use task's overridden mainClassName.
Currently it's using SomeService.kt, and I want it to be RunSomeServiceLocally.kt

Context

I'm trying to use a gradle task to run a local instance of a file which is found in the test directory.

Consider the following folder structure:
src/main/kotlin/com.service/SomeService.kt
src/test/kotlin/com.service/RunSomeServiceLocally.kt

Basically I want to make it so that when I do ./gradlew run - it uses the RunSomeServiceLocally.kt file.

Steps to Reproduce (for bugs)

Below is how I have configured the build.gradle.kts file:

application {
  mainClassName = "com.service.SomeService"
}

repositories {
  mavenLocal()
}

plugins {
  kotlin("jvm") version "1.3.72"
  application
}

tasks {
  named<JavaExec>("run").configure {
    main = "com.service.RunSomeServiceLocally"
    classpath = sourceSets.test.get().runtimeClasspath
  }
}

Your Environment

  • gradle --version: Gradle 6.0.1
  • Version of IntelliJ: #IU-201.6668.121
  • Version of the Kotlin Plugin used in IntelliJ: 1.3.72
    edit: formatting
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant