cashapp / licensee

Gradle plugin which validates the licenses of your dependency graph match what you expect
https://cashapp.github.io/licensee/docs/1.x/
Apache License 2.0
626 stars 29 forks source link

Add test for apply licensee before kotlin/android plugins #140

Closed hfhbd closed 1 year ago

hfhbd commented 1 year ago

Just a test whether it is needed for dependency-substitution-replace-remote-with-include-build-ignored see #141

JakeWharton commented 1 year ago

afterEvaluate is used because you could apply the licensee plugin before the Kotlin and/or Android plugins are applied. If removed, it would mean hasPlugin would return false. We used to use plugins.withId and then set state as to whether you have a plugin applied, but you still need an afterEvaluate to know when the user's build script is done running such that no more plugins will be applied (at least not by the user). There's probably no test for this behavior, but it would basically be the same as the existing ones except with our plugin applied first. Perhaps we should switch all the tests to this form to ensure it remains working.

hfhbd commented 1 year ago

Okay, I added a test Personally, I like failing more, but let's keep this behavior.

Without afterEvaluate the tasks are not created at begin of the configuration stage, so Gradle does not generate the kotlin tasks accessors (the typed shortcuts).

JakeWharton commented 1 year ago

In a normal case when we depend only on one plugin we can fail. But in this case you could apply the Android plugin, then Licensee, and then the Kotlin plugin. Without afterEvaluate we would miss the fact that the Kotlin plugin was applied and only set up the project for the Android variants.