how to attach a task to run after the tasks from a plugin in gradle

413 views Asked by At

I have installed the detekt plugin in gradle-kotlin with

plugins {
  id("io.gitlab.arturbosch.detekt").version("1.10.0")
}

This yields tasks for me when I run tasks:

Verification tasks
------------------
check - Runs all checks.
detekt
detektBaseline - Creates a detekt baseline on the given --baseline path.
detektGenerateConfig - Generate a detekt configuration file inside your project.
detektMain - EXPERIMENTAL & SLOW: Run detekt analysis for main classes with type resolution
detektTest - EXPERIMENTAL & SLOW: Run detekt analysis for test classes with type resolution
test - Runs the unit tests.

This generates checkstyle xml files. Unfortunately, I am forced to use teamcity, and in order to display the results of detekt in teamcity, it wants all the xml files to be rolled up into a zip file.

So my thought is that for each subproject, I want to run a task that copies the detekt output into a toArchive folder under the subproject's name, and then after detekt has run against ALL subprojects, I want to run the zip task.

The subprojects are each their own top level folder, per gradle practices:

$ tree -L 2
.
├── build
│   └── kotlin
├── build.gradle.kts
├── config
│   └── detekt
├── gradle
│   └── wrapper
├── gradlew
├── gradlew.bat
├── jobs
│   ├── build
│   ├── build.gradle.kts
│   └── src
├── lib
│   ├── build
│   ├── build.gradle.kts
│   └── src
├── README.md
├── settings.gradle.kts
└── SETUP.md

But I can't even begin to see how to do this.

I don't really care where the output folder is. I was gonna do the toArchive folder at the top level that is in the gradle zip tasks docs. But I don't think it matters much.

I am new to gradle and I find it very confusing.

0

There are 0 answers