简体   繁体   中英

mark dependencies provided with the gradle java mavenDeployer

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM