示例 gradle 以正确顺序构建(清理、构建)多个项目的脚本
Example gradle script to build(clean, build) several projects in the right order
有几个项目需要按顺序构建。按顺序构建的含义:
1. clean, build - project 2
2. clean, build - project 1
3. clean, build - project 4
4. clean, build - project 3
每个项目。
-Root Folder
------- project1
-----------build.gradle
------- project2
-----------build.gradle
------- project3
-----------build.gradle
------- project4
-----------build.gradle
--build.gradle
--settings.gradle
build.gradle 个项目 (1,2,3,4):
apply plugin: 'java'
dependencies {
// other dependencies
}
root_folder/settings.gradle
include ':project1', ':project2', ':project3', ':project4'
root_folder/build.gradle
????????
请告诉我如何在脚本中组织所有项目的构建顺序?
在你的根目录中 build.gradle
:
dependencies {
compile project(':project1'), project(':project2')
}
现在,当您在根项目中 运行 gradle build
时,Gradle 总是保证首先构建 project1
和 project2
。
您可以在 User Guide 中阅读有关多项目构建和构建顺序的更多信息。
请注意,每次构建时都执行 "clean" 通常是一种不好的做法,因为它只会花费时间而不会带来任何好处。 Gradle 自动跟踪项目的哪些部分需要重新构建,哪些部分没有更改(因此不需要重新构建)。
您可以在 this section of the user's guide 中详细了解 Gradle 如何确定哪些任务是最新的。
Before a task is executed for the first time, Gradle takes a snapshot of the inputs. This snapshot contains the set of input files and a hash of the contents of each file. Gradle then executes the task. If the task completes successfully, Gradle takes a snapshot of the outputs. This snapshot contains the set of output files and a hash of the contents of each file. Gradle persists both snapshots for the next time the task is executed.
Each time after that, before the task is executed, Gradle takes a new snapshot of the inputs and outputs. If the new snapshots are the same as the previous snapshots, Gradle assumes that the outputs are up to date and skips the task. If they are not the same, Gradle executes the task. Gradle persists both snapshots for the next time the task is executed.
有几个项目需要按顺序构建。按顺序构建的含义:
1. clean, build - project 2
2. clean, build - project 1
3. clean, build - project 4
4. clean, build - project 3
每个项目。
-Root Folder
------- project1
-----------build.gradle
------- project2
-----------build.gradle
------- project3
-----------build.gradle
------- project4
-----------build.gradle
--build.gradle
--settings.gradle
build.gradle 个项目 (1,2,3,4):
apply plugin: 'java'
dependencies {
// other dependencies
}
root_folder/settings.gradle
include ':project1', ':project2', ':project3', ':project4'
root_folder/build.gradle
????????
请告诉我如何在脚本中组织所有项目的构建顺序?
在你的根目录中 build.gradle
:
dependencies {
compile project(':project1'), project(':project2')
}
现在,当您在根项目中 运行 gradle build
时,Gradle 总是保证首先构建 project1
和 project2
。
您可以在 User Guide 中阅读有关多项目构建和构建顺序的更多信息。
请注意,每次构建时都执行 "clean" 通常是一种不好的做法,因为它只会花费时间而不会带来任何好处。 Gradle 自动跟踪项目的哪些部分需要重新构建,哪些部分没有更改(因此不需要重新构建)。
您可以在 this section of the user's guide 中详细了解 Gradle 如何确定哪些任务是最新的。
Before a task is executed for the first time, Gradle takes a snapshot of the inputs. This snapshot contains the set of input files and a hash of the contents of each file. Gradle then executes the task. If the task completes successfully, Gradle takes a snapshot of the outputs. This snapshot contains the set of output files and a hash of the contents of each file. Gradle persists both snapshots for the next time the task is executed.
Each time after that, before the task is executed, Gradle takes a new snapshot of the inputs and outputs. If the new snapshots are the same as the previous snapshots, Gradle assumes that the outputs are up to date and skips the task. If they are not the same, Gradle executes the task. Gradle persists both snapshots for the next time the task is executed.