groovy / groovy-android-gradle-plugin

A Gradle plugin to support the Groovy language for building Android apps
Apache License 2.0
850 stars 116 forks source link

Building an app that has this applied and using `--debug` can lead to failures #169

Closed autonomousapps closed 5 years ago

autonomousapps commented 5 years ago

What kind of issue is this?

I have a reproducible sample project, with instructions, here. To summarize it, ./gradlew :app:assembleDebug succeeds, but ./gradlew clean && ./gradlew :app:assembleDebug --debug fails with a weird error. Even though I'm only requesting the debug variant, the plugin is trying to resolve the debugUnitTest variant, which it should not be doing.

When I asked someone at Gradle about it (thinking it a Gradle bug due to the --debug connection), they said:

Most likely a logging message is issued with a configuration as a parameter. Something like:

logger.debug("hi there {}", configurations.myConf.incoming.files)

Any ideas on where this is coming from?

autonomousapps commented 5 years ago

I would be willing to take a look at creating a PR for this, but I don't even know where to start with respect to finding the root cause. Any pointers?

AndrewReitz commented 5 years ago

@autonomousapps I guess I would search the code for debug log messages and see ones that are logging files. I'm pretty sure there are a few in the GroovyAndroidPlugin. The easiest way to test would be to create something in the GroovyAndroidPluginSpec that replicates the issue, that way you can attach the debugger.

autonomousapps commented 5 years ago

Ok, I'm thinking it's basically

log.debug('groovy sources for {}: {}', variantName, groovyTask.source.files)
// or
log.debug('Groovy classpath: {}', groovyTask.classpath.files)
autonomousapps commented 5 years ago

Cool, definitely

log.debug('Groovy classpath: {}', groovyTask.classpath.files)

I have a test case that proves my change passes. Will probably submit PR tomorrow.