gradle-license-plugin icon indicating copy to clipboard operation
gradle-license-plugin copied to clipboard

Update README to show how to run this task automatically

Open jaredsburrows opened this issue 3 years ago • 3 comments

tasks.whenTaskAdded {
  if (name == "assembleDebug") {
    dependsOn("licenseDebugReport")
  }
}

tasks.whenTaskAdded {
  if (name == "assembleRelease") {
    dependsOn("licenseReleaseReport")
  }
}

jaredsburrows avatar Jan 23 '22 22:01 jaredsburrows

In order to accommodate Product variants in Android, something like this should also work:

tasks.whenTaskAdded {
    if (name.contains("assemble") && name.contains("Release")) {
        dependsOn("licenseReleaseReport")
    }
}

tasks.whenTaskAdded {
    if (name.contains("assemble") && name.contains("Debug")) {
        dependsOn("licenseDebugReport")
    }
}

This because the tasks are named: assembleProductVariantNameRelease.

Although your example would work too, in a very specific case where the exact task is run for generating all variants. The one suggested in this comment, could avoid extra processing of all variants to get the output.

nisrulz avatar Apr 24 '22 21:04 nisrulz

I might add automatic support for this, similar to https://github.com/jaredsburrows/gradle-spoon-plugin/blob/master/gradle-spoon-plugin/src/main/kotlin/com/jaredsburrows/spoon/projectAndroid.kt#L63.

jaredsburrows avatar Apr 24 '22 21:04 jaredsburrows

That looks much better. TIL 😸

Looking forward that being implemented.

nisrulz avatar Apr 24 '22 22:04 nisrulz