简体   繁体   English

kotlin项目不能建立在gradle中

[英]kotlin project can't be build in gradle

I have a java project that write in kotlin ,i use intelliJ IDEA to develop this project. 我有一个用kotlin写的java项目,我使用intelliJ IDEA来开发这个项目。 I have trouble on the dependencies setting (multiple project). 我在依赖项设置(多个项目)上遇到了麻烦。 I already read lot of examples , but I can't find the workaround , here is my dependencies setting code, it can be build in java class correctly , but the kotlin class will get lot of error 'Unresolved reference' . 我已经阅读了很多例子,但我找不到解决方法,这里是我的依赖设置代码,它可以正确地在java类中构建,但是kotlin类会得到很多错误'未解析的引用'。 Is that any wrong about my setting or gradle is not suitable with kotlin . 我的设置或gradle有什么不对,不适合kotlin。

PS : when i only build core project , build process will successful , but build at test project will get the reference unresolved error PS:当我只构建核心项目时,构建过程会成功,但构建测试项目会得到参考未解决的错误

allprojects {
apply plugin: 'java'
apply plugin: 'kotlin'
group 'testProject'
version '1.0'
}



subprojects{
apply plugin:  'java'
apply plugin: 'kotlin'
def defaultEncoding = 'UTF-8'
compileJava.options.encoding = defaultEncoding
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
    mavenLocal()
}

dependencies {

    // Kotlin
    compile "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
}
project(':test') {
dependencies {
    compile project(':core')
    compile project(':testTwo')
}

project(':testTwo'){
dependencies{
    compile project(':core')
}

setting.gradle setting.gradle

include 'test','testTwo','core'

The kotlin-gradle-plugin is not a dependency of your subprojects, it is a dependency of the buildscript itself. kotlin-gradle-plugin不是子项目的依赖项,它是buildscript本身的依赖项。

Follow the instructions on Plugin and Versions 按照插件和版本的说明进行操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM