How do I define a compile-time *only* classpath in Gradle?

前端 未结 11 2115
[愿得一人]
[愿得一人] 2020-12-02 11:51

Can someone please give me a simple build.gradle example of how I can specify compile-time-only classes that are not included in the runtime deployment (war).

Gradl

11条回答
  •  [愿得一人]
    2020-12-02 12:41

    I didnt find a solution for Android Studio, but this what I tried:

    In android studio I had to update to version 0.5.+

    in gradle/gradle-wrapper.properties replace

    distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-rc-3-bin.zip
    

    by

    distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip
    

    in all my build.gradle replace

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.7.+'
        }
    }
    

    by

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.9.+'
        }
    }
    

    and in the library I wanted to use provided

    configurations {
        provided
    }
    
    //put applicationVariants in case it is apply plugin: 'android' and not apply plugin: 'android-library'
    android.libraryVariants.all {
        variant -> variant.javaCompile.classpath += configurations.provided
    }
    
    dependencies {
        provided files('ext_libs/amazon-device-messaging-1.0.1.jar')
    }
    

    and at the end it doesnt work, it seems that it works for jar but not for aar or apk as stated here https://groups.google.com/forum/#!topic/adt-dev/WIjtHjgoGwA

提交回复
热议问题