Question

in a library jar deployment I need to mark a dependency as provided - otherwise I get

has an indirect dependency on Android API level BAR, but minSdkVersion for variant 'XYZ' is API level FOO

there seems to be a way with the war plugin, but I found no way to do it with the java plugin

the code/build-script is here: https://github.com/ligi/AndroidHelper

anyone knows a way?

Was it helpful?

Solution

That's quite easy, you need to create a new configuration

    configurations {
      compileOnly
    }

than add the dependencies of this configuration to the source sets (otherwise compilation fails)

    sourceSets {
      main {
        compileClasspath += configurations.compileOnly
      }
      test {
        compileClasspath += configurations.compileOnly
      }
    }

The last thing is to tell your IDE that their is something additional, for example for Idea you have to use this

    idea {
      module {
        scopes.PROVIDED.plus += configurations.compileOnly
      }
    }

Now you can use the compileOnly configuration in your dependencies section as usual

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top