V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
heavyrainn
V2EX  ›  程序员

请教, kotlin 升级到 1.5.0 之后无法 gradle build 了,会报 Could not find method compile() XXXX 错误

  •  
  •   heavyrainn · 2021-05-23 23:44:33 +08:00 · 1500 次点击
    这是一个创建于 1040 天前的主题,其中的信息可能已经有所发展或是发生改变。

    build.gradle 的内容如下:

    plugins {
        id 'org.jetbrains.kotlin.jvm' version '1.5.0'
    }
    
    group 'org.example'
    version '1.0-SNAPSHOT'
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        compile "org.jetbrains.kotlin:kotlin-stdlib"
        // https://mvnrepository.com/artifact/com.linkedin.migz/migz
        compile group: 'com.linkedin.migz', name: 'migz', version: '1.0.4'
    }
    
    jar {
        manifest {
            attributes 'Main-Class': 'Main1Kt'
        }
        from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    }
    

    执行 gradle build 报错:

    E:\kotlinProject\trySomeCode>gradle build
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Build file 'E:\kotlinProject\trySomeCode\build.gradle' line: 13
    
    * What went wrong:
    A problem occurred evaluating root project 'trySomeCode'.
    > Could not find method compile() for arguments [org.jetbrains.kotlin:kotlin-stdlib] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 1s
    

    同样的内容,只要把 kotlin 的版本改成 1.4.32 就可以正常 build,请问是 kotlin1.5 的 gradle build 配置方式改了吗?谢谢大家

    6 条回复    2021-05-25 10:52:18 +08:00
    winterbells
        1
    winterbells  
       2021-05-24 08:20:40 +08:00 via Android
    implementation ?
    youxiachai
        2
    youxiachai  
       2021-05-24 10:43:47 +08:00
    compile 应该被废弃了吧...
    Goooler
        3
    Goooler  
       2021-05-24 10:55:21 +08:00
    compile 被删掉了,用 implementation
    iseki
        4
    iseki  
       2021-05-24 13:12:52 +08:00
    compile 弃用的警告都给了好多个版本了吧
    unco020511
        5
    unco020511  
       2021-05-24 15:54:49 +08:00
    compile 被废弃了呀
    AoEiuV020
        6
    AoEiuV020  
       2021-05-25 10:52:18 +08:00
    这个记得是 gradle 5 开始删除了的,按理说和 kotlin 没关系才对,
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5404 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 07:06 · PVG 15:06 · LAX 00:06 · JFK 03:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.