Is there an equivalent to the NoExport feature in Eclipse?


(Derek Ealy) #1

Hi

I have a multi-project build, where one of the sub-projects has a dpendency on something that I don’t want any of the other projects to depend on. In Eclipse you normally would just check the NoExport box for that project dependency.

Is there something similar in Gradle?

For example if I have a project that depends on bar
foo
-> bar

And another project baz that depends on foo, the dependency tree looks like this
baz
-> foo
-> bar

I don’t want bar’s files to be included in the final baz.APK, hence the notion of not exporting bar from foo sounds like what I’m after.

Is there some way to do this in Gradle? I’m sure that I can find a way to exclude bar from baz, but since I have many projects which will depend on foo, I’d rather make the change in foo if it is possible.

BTW, I’m not using Eclipse, just AndroidStudio or building from the command line.

thanks


(Lance Java) #2

You could try something like the following in your root project’s build.gradle

allprojects { Project p ->
   if (p.name != 'foo') {
      p.configurations.all*.exclude group: 'my-group', module: 'bar' 
   } 
} 

(Stefan Oehme) #3

You are looking for a compileOnly dependency, which Gradle brings out of the box starting with the upcoming 2.12 release.

If you are on an older Gradle version, you can also use the provided configuration from the nebula-extra-configurations-plugin