https://kotlinlang.org logo
m

Mars

06/01/2020, 2:14 PM
Hello there, am I right in thinking that adding jvm target like so
Copy code
kotlin {
  jvm()
}
would create
jvmMain
source set? I then declare dependencies for the source set in the following way
Copy code
jvm().compilations["main"].defaultSourceSet {
    dependsOn(commonMain)
    dependencies {
    ...
    }
}
but I can't make this very simple project run. I'm getting
Copy code
SourceSet with name 'jvmMain' not found.
For details, please check: https://stackoverflow.com/questions/62132959/sourceset-with-name-jvmmain-not-found
c

christophsturm

06/01/2020, 2:19 PM
what gradle task do you run?
this looks strange to me: ``Initialization script '/private/var/folders/yc/sdfads/T/Home_main__.gradle' line: 20``
m

Mars

06/01/2020, 2:23 PM
I'm hitting the play button with Java application run configuration. Set to run the Main class with the classpath of module
jvmMain
.
c

christophsturm

06/01/2020, 2:25 PM
your gradle build file looks ok. what happens when you run
./gradlew build
?
m

Mars

06/01/2020, 2:27 PM
Oh, no, this one again
Copy code
* What went wrong:
Execution failed for task ':compileKotlinJvm'.
> kotlin/coroutines/Continuation
Not sure that's related though, happens every once in a while. I think deleting gradle cache helps. Let me try to fix this and run
build
.
c

christophsturm

06/01/2020, 2:27 PM
you could try to change
jvm()
to
Copy code
jvm {
    withJava()
}
m

Mars

06/01/2020, 2:28 PM
Building via the hammer icon worked fine before.
c

christophsturm

06/01/2020, 2:29 PM
and maybe add the
application
plugin
m

Mars

06/01/2020, 3:05 PM
withJava()
didn't seem to help.
build
is successful but running the Java class still results in
Copy code
SourceSet with name 'jvmMain' not found.
When I add
application
plugin, build fails with
Copy code
A problem was found with the configuration of task ':startScripts'.
> No value has been specified for property 'mainClassName'.
I tried to add the property like
Copy code
application {
    mainClass.set("Home")
}
or add to
gradle.properties
but it didn't do the trick.
I figured how to set the
mainClassName
for
application
plugin
Copy code
jvm().compilations["main"].defaultSourceSet {
    configure<JavaApplication> {
        mainClassName = "Home"
    }
It builds successfully now but
run
fails with
Copy code
> Process 'command '/Java/Contents/jre/jdk/Contents/Home/bin/java'' finished with non-zero exit value 134
Makes me think that the problem could be in the run configuration.. do you think this looks okay?
c

christophsturm

06/01/2020, 4:57 PM
the module name is pretty long, but it all looks ok
2 Views