Closed dimsuz closed 6 years ago
Oh, I forgot to mention. I have kotlin-1.2.10
in my settings.xml, due to the infamous kotlin compiler bug :). Dunno if this is related. Without it I cannot even compile. But I set Build.kt
to have 1.2.10
deps too...
$ cat ~/.config/kobalt/settings.xml
<kobaltSettings>
<kobaltCompilerVersion>1.2.10</kobaltCompilerVersion>
</kobaltSettings>
I also want to note that without specifying a custom directory
a project created by ./kobaltw --init kotlin
builds and runs just fine. As soon as described modifications are done - it stops running.
OK, I believe I have found why this bug happens. I ran kobaltw run --log 3
:
Invoking separate kotlinc:
/usr/lib/jvm/java-8-jdk/bin/java -classpath /home/dima/.kobalt/cache/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.2.10/kotlin-compiler-embeddable-1.2.10.jar:/home/dima/.kobalt/cache/org/jetbrains/kotlin/kotlin-script-runtime/1.2.10/kotlin-script-runtime-1.2.10.jar:/home/dima/.kobalt/cache/org/jetbrains/annotations/13.0/annotations-13.0.jar:/home/dima/.kobalt/cache/org/jetbrains/kotlin/kotlin-stdlib/1.2.10/kotlin-stdlib-1.2.10.jar:/home/dima/.kobalt/cache/org/jetbrains/kotlin/kotlin-reflect/1.2.10/kotlin-reflect-1.2.10.jar:/home/dima/.kobalt/cache/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.2.10/kotlin-compiler-embeddable-1.2.10.jar org.jetbrains.kotlin.cli.jvm.K2JVMCompiler -no-stdlib -classpath /home/dima/.kobalt/cache/org/jetbrains/kotlin/kotlin-stdlib/1.2.10/kotlin-stdlib-1.2.10.jar:/home/dima/.kobalt/cache/org/jetbrains/kotlin/kotlin-runtime/1.2.10/kotlin-runtime-1.2.10.jar:/home/dima/.kobalt/cache/org/jetbrains/annotations/13.0/annotations-13.0.jar -d /home/dima/projects/kobalt-bug/kobaltBuild/classes customdir/src/main/kotlin
Notice this:
-d /home/dima/projects/kobalt-bug/kobaltBuild/classes
So it outputs classes to the root project dir. But assemble
task expects to find them in customdir
:
Creating customdir/kobaltBuild/libs/kobalt-bug-0.1.jar
Added 1 files to customdir/kobaltBuild/libs/kobalt-bug-0.1.jar
(this 1 file is MANIFEST.MF, so it doesn't count).
So assemble
task doesn't find the build MainKt.class
- which is indeed can be found at $PROJECT_ROOT/kobaltBuild/classes/MainKt.class
path
Should be fixed in 1.0.107. Run ./kobaltw --update
and then ./kobaltw run
again.
Yay, it works now! Thank you for the fix.
@cbeust I created a new kotlin project and i'm getting the same error: Could not find or load main class com.avently.testapp.Main
Inside a jar i see com/avently/testapp/MainKt.class but inside manifest of the jar this line: Main-Class: com.avently.testapp.Main
So i'm unable to start the app with ./kobalt run or with java filename.jar. What to do?
Upd: Cleaned the project after renaming Main to MainKt in build config and now it works fine.
The class should be called MainKt
.
To reproduce just clone this project and execute
Output:
I am able to reproduce both with
105
and106
versions of Kobalt.How I arrived at this project is I wanted to have a custom source directory. So I basically just did:
So now I have
./customdir/src/main/kotlin/com/example/Main.kt
Next I editedBuild.kt
of this project to containdirectory = "customdir"
.And now kobalt is still able to build it, but seems like it ignores
Main.kt
completely and trying to run causes an error.