Correct soft task ordering between tidy and any other dependency of regenerate.

This commit is contained in:
Dawid Weiss 2021-03-24 15:38:34 +01:00
parent bb5db1e16d
commit 4c2de7ef43
2 changed files with 17 additions and 3 deletions

View File

@ -134,7 +134,7 @@ configure(project(":lucene:analysis:common")) {
heapSize = "12g" heapSize = "12g"
doFirst { doFirst {
logger.lifecycle("Regenerating UAX29URLEmailTokenizerImpl. This may take a long time (and requires tons of memory).") logger.lifecycle("Regenerating UAX29URLEmailTokenizerImpl. This may take a long time (and requires ${heapSize} of memory!).")
} }
doLast { doLast {

View File

@ -30,12 +30,26 @@ configure([
group "generation" group "generation"
} }
// Make sure tidy dependency runs after any other generation task. // Make sure 'tidy' and its dependencies run after any other task in the dependencies
// of 'regenerate'. This ensures proper execution ordering so that tidy tasks run
// after whatever has been generated is complete.
afterEvaluate { afterEvaluate {
Set<Task> deps = regenerate.getTaskDependencies().getDependencies(regenerate) Set<Task> deps = regenerate.getTaskDependencies().getDependencies(regenerate)
def tidy = deps.find { it.name == "tidy" } def tidy = deps.find { it.name == "tidy" }
if (tidy) { if (tidy) {
tidy.mustRunAfter (deps - [tidy]) TaskDependency dep = tidy.taskDependencies
Set<Task> visited = new HashSet<>()
Queue<Task> queue = new ArrayDeque<>()
queue.add(tidy)
while (!queue.isEmpty()) {
Task t = queue.removeFirst()
if (visited.add(t)) {
queue.addAll(dep.getDependencies(t))
}
}
def otherDeps = deps - [tidy]
visited.each { Task t -> t.mustRunAfter(otherDeps) }
} }
} }
} }