What is the difference between allprojects and subprojects

前端 未结 2 664
庸人自扰
庸人自扰 2020-12-23 13:18

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 directo

2条回答
  •  误落风尘
    2020-12-23 13:42

    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.

提交回复
热议问题