Gradle and Multi-Project structure

前端 未结 2 2089
暗喜
暗喜 2020-11-28 01:47

I\'m trying to understand how should I approach the following project setup:

┌Top Android Project
│
├── Project 1 - (Pure Java Modules)
│    │
│    ├── Modul         


        
2条回答
  •  醉梦人生
    2020-11-28 02:25

    If you have folders matching that structure you can apply the same build logic to multiple projects.

    If your settings.gradle contains

    include ':project2:moduleA2'
    

    then ':project2' is also a project, and it can have its own build.gradle, in which you can write:

    subprojects { project ->
        apply plugin 'android-library'
    
        // more configuration
    }
    

    If you don't apply any plugin to ':project2' itself then this project simply won't output anything (which is probably what you want) but that way you can configure all its sub-project in a simple go.

    Then you can also have all your submodule put some logic that's specific to them

    You can also technically do that in project2/build.gradle if you want to keep it all in the same file. You can read http://www.gradle.org/docs/current/userguide/multi_project_builds.html to see how to configure subprojects from a parent build.gradle file, accessing either all subprojects or a specific one, or using filtering.

提交回复
热议问题