Guava Dependency Breaking Jar Built With Kotlin

后端 未结 2 567
粉色の甜心
粉色の甜心 2020-12-21 17:23

Issue

The Java/Kotlin application runs as expected in from the Main Class in IntelliJ\'s IDE. However, when the app is built into a .Jar file the

相关标签:
2条回答
  • 2020-12-21 17:52

    Solution

    The Jar build started working again after updating my library dependencies and redefining the Project level SDK when re-pulling a version built on a different machine from Github.

    Update to dependencies

    1. Changed compile to implementation.
    2. Updated version numbers by searching for each project's latest version on Google.

    build.grade

    buildscript {
        ext.kotlin_version = '1.3.10'
        ext.junitJupiterVersion  = '5.3.2'
    
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.3'
        }
    }
    
    plugins {
        id 'java'
        id 'org.jetbrains.kotlin.jvm' version '1.2.51'
    }
    
    version '1.0-SNAPSHOT'
    
    sourceCompatibility = 1.8
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
        testImplementation group: 'junit', name: 'junit', version: '5.3.2'
        // JUnit Jupiter API and TestEngine implementation
        testImplementation("org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}")
        testRuntime("org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}")
        testImplementation "org.assertj:assertj-core:3.11.1"
        // To avoid compiler warnings about @API annotations in JUnit code
        testCompileOnly 'org.apiguardian:apiguardian-api:1.0.0'
        implementation 'com.squareup.retrofit2:retrofit:2.5.0'
        implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
        implementation 'com.squareup.retrofit2:adapter-rxjava:2.5.0'
        implementation 'io.reactivex.rxjava2:rxjava:2.2.4'
        implementation 'com.google.firebase:firebase-admin:6.6.0'
        implementation 'com.google.apis:google-api-services-youtube:v3-rev206-1.25.0'
    }
    
    compileKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }
    compileTestKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }
    
    0 讨论(0)
  • 2020-12-21 18:02

    add the current version 27.0:

    dependencies {
        api "com.google.guava:guava:27.0-jre"
    }
    

    and exclude both other versions 19.0 and 20.0, wherever they may be referenced.

    ./gradlew app:dependencies > dependencies.txt
    

    or check with:

    ./gradlew app:dependencies | grep guava
    

    for example (the firebase-admin is certainly a candidate):

    // https://mvnrepository.com/artifact/com.google.firebase/firebase-admin
    implementation ("com.google.firebase:firebase-admin:6.5.0") {
        exclude group: "com.google.guava", module: "guava"
    }
    

    there may be further references present.

    0 讨论(0)
提交回复
热议问题