gradle fails to compile java classes using kotlin class -


i have gradle 4.1 multiproject containing "projecta" containing 2 subfolders "api" , "implementation".

the multiproject uses kotlin , java-library plugins defined in subprojects section of main build.gradle. implementation project avec api dependency :projecta:api

in api folder have kotlin , java files inside 'src/main/java' , in implementation project i'm creating new instance of kotlin class api.

inside intellij idea, don't have compilation errors ; when compile whole project using gradle have error: cannot find symbol. if compilejava doesn't have access folder kotlin-classes.

inside build/kotlin-classes, see file.class class file on build/classes dir also

details of error :

task :projecta:api:compilekotlin using kotlin incremental compilation

task :projecta:implementation:compilejava (...) error: cannot find symbol (the import fails)

update 1 : removing java-library solved problem

this known issue of java-library plugin: when used in project jvm language (kotlin, scala, groovy etc.) , not register classes of other language dependent projects them consume classes.

fortunately, has workaround well. adapted kotlin, like:

configurations {     apielements {         outgoing.variants.getbyname('classes').artifact(             file: compilekotlin.destinationdir,             type: artifacttypedefinition.jvm_class_directory,             builtby: compilekotlin)     } } 

if use kapt1, it's file: compilekotlinafterjava.destinationdir, , gradle versions lower 4.0 use builtby: copymainkotlinclasses instead.

this issue tracked in kotlin issue tracker: kt-18497, follow issue see when it's fixed on kotlin gradle plugin side, above workaround no more necessary.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -