KT-41425 Project can not be launched with Gradle runner

93a82060 introduced support of "delegate to Gradle" for Gradle-Kotlin.
This commit fixes an issue known as "Could not get unknown property
'sourceSets' for root project".
This commit is contained in:
Andrei Klunnyi
2020-08-26 15:12:20 +02:00
parent f57f920dc0
commit 5cf76aa950
@@ -170,33 +170,35 @@ class KotlinGradleAppEnvProvider : GradleExecutionEnvironmentProvider {
allprojects {
afterEvaluate { project ->
def overwrite = project.tasks.findByName(runAppTaskName) != null
project.tasks.create(name: runAppTaskName, overwrite: overwrite, type: JavaExec) {
if (javaExePath) executable = javaExePath
if (project.pluginManager.hasPlugin("org.jetbrains.kotlin.multiplatform")) {
project.kotlin.targets.each { target ->
target.compilations.each { compilation ->
if (compilation.defaultSourceSetName == sourceSetName) {
classpath = compilation.output.allOutputs + compilation.runtimeDependencyFiles
if (project.path == gradlePath) {
def overwrite = project.tasks.findByName(runAppTaskName) != null
project.tasks.create(name: runAppTaskName, overwrite: overwrite, type: JavaExec) {
if (javaExePath) executable = javaExePath
if (project.pluginManager.hasPlugin("org.jetbrains.kotlin.multiplatform")) {
project.kotlin.targets.each { target ->
target.compilations.each { compilation ->
if (compilation.defaultSourceSetName == sourceSetName) {
classpath = compilation.output.allOutputs + compilation.runtimeDependencyFiles
}
}
}
} else {
classpath = project.sourceSets[sourceSetName].runtimeClasspath
}
} else {
classpath = project.sourceSets[sourceSetName].runtimeClasspath
}
main = mainClass
$argsString
if(_workingDir) workingDir = _workingDir
standardInput = System.in
if(javaModuleName) {
inputs.property('moduleName', javaModuleName)
doFirst {
jvmArgs += [
'--module-path', classpath.asPath,
'--module', javaModuleName + '/' + mainClass
]
classpath = files()
main = mainClass
$argsString
if(_workingDir) workingDir = _workingDir
standardInput = System.in
if(javaModuleName) {
inputs.property('moduleName', javaModuleName)
doFirst {
jvmArgs += [
'--module-path', classpath.asPath,
'--module', javaModuleName + '/' + mainClass
]
classpath = files()
}
}
}
}