所有项目和子项目有什么区别? [英] What is the difference between allprojects and subprojects

查看:982
本文介绍了所有项目和子项目有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在多项目gradle构建中,有人能告诉我所有项目部分和子项目部分之间的区别究竟是什么?只是父目录?有人使用两者吗?如果是这样,你是否有通用的规则来决定每一个通常放在哪里?



相关问题:这两种语法之间有什么区别(对于所有项目和子项目):

 子项目{... 
}

$ p
$ b $ $ $ $ $ $ codeonfigure $($)$ $ $ $
$ b

什么时候你会比另一个更好?

解决方案

在多项目gradle构建中,您有一个rootProject和子项目。两者的结合都是项目。 rootProject是构建的起点。常见模式是rootProject没有代码,子项目是java项目。在这种情况下,您仅将java插件应用于子项目:

 子项目{
apply plugin:'java'
}

这相当于一个maven聚合pom项目,模块。



关于这两种语法,它们完全相同。第一个看起来更好。


On a multi-project gradle build, can someone tell me what exactly is the difference between the "allprojects" section and the "subprojects" one? Just the parent directory? Does anyone use both? If so, do you have general rules that determines what typically is put in each one?

Related question: what is the difference between the two syntaxes (really for allprojects AND subprojects):

subprojects {  ...
}

and

configure(subprojects) { ...
}

When would you one over the other?

解决方案

In a multi-project gradle build, you have a rootProject and the subprojects. The combination of both is allprojects. The rootProject is where the build is starting from. A common pattern is a rootProject has no code and the subprojects are java projects. In which case, you apply the java plugin to only the subprojects:

subprojects {
    apply plugin: 'java'
} 

This would be equivalent to a maven aggregate pom project that just builds the sub-modules.

Concerning the two syntaxes, they do the exact same thing. The first one just looks better.

这篇关于所有项目和子项目有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆