我正在使用Groovy和Kotlin进行一个小项目,我的Kotlin代码取决于我的Groovy代码,而不是相反.然而,Kotlin首先编译我的代码,而不是Groovy,因此,我会出现Unresolved reference: SiteRepository个错误

Any suggestions how I can fix this, by either changing the build sequence, or Kotlin depending explicitly on Groovy, or any other suggestion?

推荐答案

可以这样做:

After 4.10

Kotlin First:

//compileKotlin.dependsOn = compileKotlin.taskDependencies.values - 'compileJava'
compileGroovy.dependsOn compileKotlin
compileGroovy.classpath += files(compileKotlin.destinationDir)
classes.dependsOn compileGroovy

4点10分之前

Groovy First:

compileGroovy.dependsOn = compileGroovy.taskDependencies.values - 'compileJava'
compileKotlin.dependsOn compileGroovy
compileKotlin.classpath += files(compileGroovy.destinationDir)
classes.dependsOn compileKotlin

还是Kotlin First:

compileKotlin.dependsOn = compileKotlin.taskDependencies.values - 'compileJava'
compileGroovy.dependsOn compileKotlin
compileGroovy.classpath += files(compileKotlin.destinationDir)
classes.dependsOn compileGroovy

To be clear, you get to choose whether your Kotlin code depends on Groovy or Groovy on Kotlin, but you don't get to have it both ways.

Kotlin相关问答推荐

Android前台服务 list —Altbeacon

Gradle Jooq配置自定义生成器

我可以更改方法中泛型类的类型参数边界吗?

禁用 Gradle执行消息

如何注入返回通用列表的转换器?

为什么在jacksonObjectMapper上将DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES设置为false无效?

为什么 <= 可以应用于 Int 和 Long,而 == 不能?

在kotlin中匹配多个变量

Kotlin 协程按顺序执行,但仅在生产机器上执行

如何处理基于枚举提前返回的 forEach 循环,Kotlin 中的一条路径除外

将 SharedPreferences 中的值公开为流

如何在 Kotlin for Android 上使用setTextColor(hexaValue),

如何使用 Android CameraX 自动对焦

在 Kotlin 中实现 (/inherit/~extend) 注解

什么是开放式property?为什么我不能将其设置器设为private私有?

如何在Kotlin中获得KType?

Kotlin 接口属性:只需要公共 getter 而没有公共 setter

Kotlin reflect proguard SmallSortedMap

未解决的参考 dagger 2 + kotlin + android gradle

我们如何在Java注释声明中引用Kotlin常量?