更新时间:2023-11-20 09:07:10
settings.gradle
settings.gradle
文件是Groovy脚本,就像 build.gradle
文件一样。每个版本中只会执行一个 settings.gradle
脚本(相比之下,多个版本中的多个 build.gradle
脚本项目构建)。 settings.gradle
脚本将在任何 build.gradle
脚本之前甚至在 Project
实例已创建。因此,将根据 进行评估设置
对象。使用此设置
对象,您可以将子项目添加到构建中,从命令行修改参数( StartParameter
),然后访问 Gradle
对象来注册生命周期处理程序。因此,如果您的设置与构建相关,而不一定与项目相关,或者需要之前包含子项目,则使用 settings.gradle
。
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
文件是一个简单的Java 属性
文件仅通过自动包含在 Project $ c的范围内而具有特殊作用$ c>对象(即所谓的项目属性)。这是一个简单的键值存储,仅允许使用字符串值(因此,您需要自己分割列表或数组)。您可以将
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:
.gradle
目录(用于与用户或环境相关的值).gradle
directory (for user- or environment-related values)