Gradle 多工程依赖

在build.gradle文件中:

compile (project(':com.test.model'))

在settings.gradle文件中写:

include ':com.test.model'
project(':com.test.model').projectDir = new File(settingsDir, '../com.test.model')

如果还有其他项目依赖,只要重复添加上面的依赖就行。

因为我的项目会出现重复依赖关系,比如c依赖a、b,b又依赖a,我添加了上面的依赖之后报错了,后来发现是我写的语法有错误,在build.gradle文件中的写法必须是加上括号的,就是上面红背景的那个地方,这样就正确了。

最开始的时候是这样写的,后来发现还是有问题,在另外一个地方发现了答案。http://blog.csdn.net/w8452960/article/details/53415415

我的就是多个工程平行,有互相依赖关系.

比如

A

B

C

三个工程

B依赖A,需要在settings.gradle中写上:

includeFlat 'A'

在build.gradle写上:

compile project(':A')

如果C要依赖B的话,需要把A也写上

settings.gradle中

includeFlat 'A','B'

build.gradle中

compile project(':A')

compile project(':B')

 

在编译时还有问题的话,可以试试:

gradle cleanEclipseClasspath eclipseClasspath

-----------------------

【https://stackoverflow.com/questions/30508993/invalid-classpath-publish-export-dependency-ouat-contract-project-entries-not】

  1. Run command: gradle cleanEclipse eclipse

    • as a result of this command Eclipse forgets that the project was supposed to have a gradle nature.
  2. Add gradle nature back to the project by doing Configure -> Convert to Gradle Project.

    • as a result of this command the error reappears.
    • if incompatible plugin java version error appears then just delete .settings directory and refresh.
  3. Run command: gradle cleanEclipseClasspath eclipseClasspath

    • this final step should get it fixed until the next time.

转载于:https://my.oschina.net/ayyao/blog/920058

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值