autonomousapps / dependency-analysis-gradle-plugin

Gradle plugin for JVM projects written in Java, Kotlin, Groovy, or Scala; and Android projects written in Java or Kotlin. Provides advice for managing dependencies and other applied plugins
Apache License 2.0
1.77k stars 116 forks source link

Use the 'shadowed' subprojects from source #1055

Closed jjohannes closed 9 months ago

jjohannes commented 10 months ago

The reason why I would like to have this working is that currently you can't use the plugin via:

pluginManagement {
    includedBuild("/path/to/dependency-analysis-android-gradle-plugin")
}

Because the moment it becomes an included build, the composite build dependency substitution starts working and then the 'shadowed' components are used from source - which does not work without this change.

autonomousapps commented 10 months ago

Build failed

jjohannes commented 10 months ago

Configuring the Shadow plugin is such a pain. Right now you need to be a super expert in Gradle to get it right...

autonomousapps commented 10 months ago

I use this plugin as an included build all the time. What error are you seeing specifically? Does it have to do with trying to update those shadowed components?

jjohannes commented 10 months ago

Alright. I was assuming this is a general problem. Feel free to discard this PR if this is not an issue in other "include" scenarios.

I get the following error, without these fixes: https://scans.gradle.com/s/fkqwok5fyqc3o/console-log?anchor=384&page=1 It's trying to compile the plugin, but does not find the shaded classes.

You can reproduce it in a setup like this one: https://github.com/jjohannes/gradle-project-setup-howto/tree/__include_dagp (branch __include_dagp and change the two places where it says includeBuild("/Users/jendrik/projects/gradle/plugins/dependency-analysis-android-gradle-plugin") to your local path)

autonomousapps commented 10 months ago

Huh interesting. I'll take a look. One of the reasons for my current setup is that those shadowed components don't change much, and I think one at least is quite large, so I was trying to reduce the size of the DAGP jar. Would your change impact normal consumers in any way? Would they still use the pre published binaries?

jjohannes commented 10 months ago

This should not change anything about how the plugin is published and used by "normal" consumers.

The only difference now is that when you build locally, it always takes the locally built version of the shadowed dependencies to compile and test against. Right now, it sometime takes the published ones (if you just build the plugin or include it like you do) and sometimes takes the local ones (if you include it like I did).

In my mind, the changes to the shadowed/*/build.gradle.kts files are valid fixes in the setup. Without these, using the shadowed libs from source is broken. You could also just take this part of the changes in – and not the includeBuild("."). Then my way of including works, and the normal plugin building keeps working as before.

In any case, this is not meant to change anything about how the plugin is published or used. It should just make it easier for others to use the plugin from source if they want to test or contribute something. I can make these adjustments locally, if you feel uncomfortable with integrating this.