6 Ekim 2021 Çarşamba

Gradle settings.gradle Dosyası - Multi-project Build İçindir

Giriş
Çoklu modülden oluşan projelerde kullanılır. Eğer tek modülden oluşan bir projemiz varsa, bu dosyaya gerek yok. Açıklaması şöyle. Tüm projede ilk çalıştırılan dosyadır
The settings.gradle file is a Groovy script, just like the build.gradle file. Only one settings.gradle script will be executed in each build (in comparison to multiple build.gradle scripts in multi-project builds). The settings.gradle script will be executed before any build.gradle script and even before the Project instances are created. Therefore, it is evaluated against a Settings object. With this Settings object you can add subprojects to your build, modify the parameters from the command line (StartParameter), and access the Gradle object to register lifecycle handlers. As a consequence, use settings.gradle if your settings are build-related and not necessarily project-related or require logic before possible subprojects are included.
Projenin ismi bu dosyaya yazılır. Şöyle yaparız
rootProject.name = 'gradle-example'
Örnek - Alt Modüller
Şöyle yaparız
include 'foo'
include 'bar'
Örnek
Elimizde şöyle bir proje olsun
(root)
  +- settings.gradle       
  +- build.gradle          # optional (commonly present)
  +- gradle.properties     # optional
  +-- buildSrc/            # optional
  |     +- build.gradle    
  |     +-- src/...
  +-- my-gradle-stuff/     # optional
  |     +- utils.gradle    # optional
  +-- sub-a/
  |     +- build.gradle
  |     +- src/
  +-- sub-b/
        +- build.gradle
        +- src/
settings.gradle dosyasında şöyle yaparız
rootProject.name = 'project-x'

include 'sub-a', 'sub-b'

Hiç yorum yok:

Yorum Gönder