Frage

I have multi-project build in gradle. Right now I am injecting tasks into each project in the following way

Closure clo = {task -> println "Run task"}
configure(subprojects.findAll {it.name == 'project1' || it.name == 'project2'})
{
   task helloTask << clo
}

Instead of iterating through all projects and selecting projects by their names, are there any better alternatives to all this? I couldn't get it to work using 'project' method, as the project method refuses to accept lists.

project([':project1', ':project2']) {
            task helloTask << clo
}
War es hilfreich?

Lösung

There isn't anything fundamentally better. I might write it as follows:

// use a suitable name that describes the subset of projects
def myProjects = [project(":project1"), project(":project2")]

configure(myProjects) {
    task helloTask << {
        println "Run task"
    }
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top