简体   繁体   中英

How to depend on specific class or package in another Gradle module?

I have two gradle modules, :app and :backend . The backend contains some classes that I need in :app . So normally I would add compile project(':backend') to my app module's dependencies.

However, this adds all of backend and its dependencies to :app . Is there any way to tell gradle to add only specific classes or packages (and their dependencies) from :backend to :app ?

EDIT: :backend is a AppEngine module, which contains a whole host of duplicate google dependencies that clash with my android app when I don't use the android-endpoints configuration.

For removing all the transitive dependencies you can

compile (project(path: ':backend', configuration: 'android-endpoints')) {
  transitive = false
}

For ignoring some of them

compile (project(path: ':backend', configuration: 'android-endpoints')) {
  exclude(group: 'some.group', module: 'some.module')
}

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