Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle - Apply configuration to all projects using plugin [duplicate]

In a multi-project Gradle build, how can I apply one bit of config to all projects that use a certain plug-in?

I want to see a bit more output from my java-based projects when tests are being run. I've found this snippet, which does what I want:

test {
    testLogging {
        events "passed", "skipped", "failed"
    }
}

Copy and pasting this into the five out of six projects that use Java (one uses the Android plugin) seems inelegant. How can I put this in once, but have Gradle not try and apply it to the non-Java project?

like image 232
EngineerBetter_DJ Avatar asked Aug 28 '15 11:08

EngineerBetter_DJ


1 Answers

See the organising build logic section in the gradle documentation for various options for code re-use.

I'd probably use a subprojects closure in the root build.gradle

subprojects {
    test {
        testLogging {
            events "passed", "skipped", "failed"
        }
    }
}
like image 172
lance-java Avatar answered Sep 23 '22 01:09

lance-java