When to use gradle.properties vs. settings.gradle?

后端 未结 2 869
谎友^
谎友^ 2020-12-22 23:37

A gradle build has three files

  • build.gradle that defines the build configuration scripts
  • gradle.properties
  • s
2条回答
  •  礼貌的吻别
    2020-12-23 00:11

    settings.gradle

    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.

    gradle.properties

    The gradle.properties file is a simple Java Properties file that only gains a special role by being automatically included into the scope of the Project object (as so-called 'project properties'). It's a simple key-value store that only allows string values (so you need to split lists or arrays by yourself). You can put gradle.properties files to these locations:

    • directly in the project directory (for project-related values)
    • in the user home .gradle directory (for user- or environment-related values)

提交回复
热议问题