美文网首页
在树莓派中编译gradle kotlin工程

在树莓派中编译gradle kotlin工程

作者: 鹅鹅鹅_ | 来源:发表于2019-01-16 12:58 被阅读0次

    原本在我的mac机以及阿里云上能编译的kotlin gradle工程,放到树莓派上就报错了

    FAILURE: Build failed with an exception.
    
    * Where:
    Build file '/home/pi/code/market_data_fetcher/build.gradle' line: 14
    
    * What went wrong:
    Plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.3.10'] was not found in any of the following sources:
    
    - Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
    - Plugin Repositories (could not resolve plugin artifact 'org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.3.10')
      Searched in the following repositories:
        Gradle Central Plugin Repository
    
    

    gradle脚本中相关配置代码

    plugins {
        id "org.jetbrains.kotlin.jvm" version "1.3.10"
        id 'com.github.johnrengelman.plugin-shadow' version '2.0.2'
        id 'java'
    }
    

    很奇怪的问题,在网上也没找到相关信息,有说是网络问题的,需要vpn,但是我手动ping是能ping通的,而且我也加了国内阿里云镜像。
    后来无意间看到kotlin官方gradle配置文档。


    image.png

    我现在使用的是新的语法方式plugins,我就试了试改成了第一种方式apply plugin: "kotlin"。然后,卧槽,可以了......从下载列表中可以看到是下载了embeddable嵌入式相关的编译器,因为我这里是使用的树莓派啊。

    Download https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.10/kotlin-gradle-plugin-1.3.10.pom
    Download https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-native-utils/1.3.10/kotlin-native-utils-1.3.10.pom
    Download https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin-model/1.3.10/kotlin-gradle-plugin-model-1.3.10.pom
    Download https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin-api/1.3.10/kotlin-gradle-plugin-api-1.3.10.pom
    Download https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.3.10/kotlin-stdlib-1.3.10.pom
    Download https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-annotation-processing-gradle/1.3.10/kotlin-annotation-processing-gradle-1.3.10.pom
    Download https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-android-extensions/1.3.10/kotlin-android-extensions-1.3.10.pom
    Download https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-compiler-runner/1.3.10/kotlin-compiler-runner-1.3.10.pom
    Download https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-scripting-compiler-embeddable/1.3.10/kotlin-scripting-compiler-embeddable-1.3.10.pom
    Download https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.3.10/kotlin-reflect-1.3.10.pom
    Download https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.3.10/kotlin-compiler-embeddable-1.3.10.pom
    Download https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.10/kotlin-stdlib-common-1.3.10.pom
    

    修正后的gradle

    buildscript {
        ext.kotlin_version = '1.3.10'
    
        repositories {
            maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'}
            mavenCentral()
        }
    
        dependencies {
            classpath "com.github.jengelman.gradle.plugins:shadow:2.0.3"
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        }
    }
    
    //plugins {
    //    id "org.jetbrains.kotlin.jvm" version "1.3.10"
    //    id 'com.github.johnrengelman.plugin-shadow' version '2.0.2'
    //    id 'java'
    //}
    //apply plugin: 'application'
    apply plugin: 'idea'
    apply plugin: 'java'
    apply plugin: 'kotlin'
    apply plugin: "com.github.johnrengelman.plugin-shadow"
    

    在Gradle中,使用plugins和apply plugin有什么区别?
    很奇怪为什么在树莓派中会出现这个问题,代码配置也是按照gradle官方仓库文档说明来配置的。难道这是一个和嵌入式平台有关gradle的bug吗?

    image.png

    相关文章

      网友评论

          本文标题:在树莓派中编译gradle kotlin工程

          本文链接:https://www.haomeiwen.com/subject/vqipdqtx.html