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

前端 未结 11 2011
[愿得一人]
[愿得一人] 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:33

    I figured it out for my project setup. I use Android Studio running with the gradle plugin 0.9.+ with gradle 1.11 The main project uses amazon ads and amazon inapp purchases. It depends on a library project using amazon device messaging(ADM).

    My main issue was with the the ADM where I got the "RuntimeException: Stub!" error.

    1.) Library Project: The "provided configuration" proposed by Lukas does not work, as stated by him, so I used Richards approach, which however did not work as well out of the box. I had to change it a little since I could not find the lib in the ext_libs folder of the aar file. Gradle seems to pack all libraries in the libs folder in the in the final aar-file.

    android.libraryVariants.all { variant ->
    variant.packageLibrary.exclude( 'libs/amazon-device-messaging-1.0.1.jar' )
    }
    

    2.) Application Project : Here, the approach with the "provided configuration" worked.

    configurations{
        provided
    } 
    dependencies {
        compile 'fr.avianey:facebook-android-api:+@aar'
        compile files('ext_libs/amazon-ads-5.3.22.jar')
        compile files('ext_libs/in-app-purchasing-1.0.3.jar' )
        provided files('ext_libs/amazon-device-messaging-1.0.1.jar')
    }
    
    android.applicationVariants.all {
        variant -> variant.javaCompile.classpath += configurations.provided
    }
    

提交回复
热议问题