mikepenz / AboutLibraries

AboutLibraries automatically collects all dependencies and licenses of any gradle project (Kotlin MultiPlatform), and provides easy to integrate UI components for Android and Compose-jb environments
http://mikepenz.github.io/AboutLibraries/
Apache License 2.0
3.62k stars 419 forks source link

With configPath, Gradle uses task without declaring an explicit or implicit dependency #936

Closed blundell closed 8 months ago

blundell commented 9 months ago

About this issue

I have an app that uses config path:

aboutLibraries {
    configPath = "my-module"
}

Gradle doesn't seem to like that, (if I delete the above config, the error goes away)

1: Task failed with an exception.
-----------
* What went wrong:
A problem was found with the configuration of task ':app:prepareLibraryDefinitionsDebug' (type 'AboutLibrariesTask').
  - Gradle detected a problem with the following location: '/Users/blundell/dev/my-app/my-module'.

    Reason: Task ':app:prepareLibraryDefinitionsDebug' uses this output of task ':my-module:generateDebugResValues' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

    Possible solutions:
      1. Declare task ':my-module:generateDebugResValues' as an input of ':app:prepareLibraryDefinitionsDebug'.
      2. Declare an explicit dependency on ':my-module:generateDebugResValues' from ':app:prepareLibraryDefinitionsDebug' using Task#dependsOn.
      3. Declare an explicit dependency on ':my-module:generateDebugResValues' from ':app:prepareLibraryDefinitionsDebug' using Task#mustRunAfter.

    For more information, please refer to https://docs.gradle.org/8.4/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

This is a warning when AGP < 8, but build fails > 8.


One change I attempted was moving the configPath configuration to the my-module but the same error occurs with the error changing to be just that modules tasks.

1: Task failed with an exception.
-----------
* What went wrong:
A problem was found with the configuration of task ':my-module:prepareLibraryDefinitionsDebug' (type 'AboutLibrariesTask').
  - Gradle detected a problem with the following location: '/Users/blundell/dev/my-app/my-module'.

    Reason: Task ':my-module:prepareLibraryDefinitionsDebug' uses this output of task ':my-module:generateDebugResValues' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

    Possible solutions:
      1. Declare task ':my-module:generateDebugResValues' as an input of ':my-module:prepareLibraryDefinitionsDebug'.
      2. Declare an explicit dependency on ':my-module:generateDebugResValues' from ':my-module:prepareLibraryDefinitionsDebug' using Task#dependsOn.
      3. Declare an explicit dependency on ':my-module:generateDebugResValues' from ':my-module:prepareLibraryDefinitionsDebug' using Task#mustRunAfter.

    For more information, please refer to https://docs.gradle.org/8.4/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

Details

Checklist

mikepenz commented 9 months ago

Thank you for the report @blundell

Is this something you can also reproduce in the sample app? We use the configPath there too, and it does not seem to show the same behavior: https://github.com/mikepenz/AboutLibraries/blob/develop/app/build.gradle#L92

blundell commented 9 months ago

Hmm thanks let me see if I can!

blundell commented 8 months ago

Finally got round to this @mikepenz (Happy New Year!), sorry for the delay! :-)

Here is the error message being reproduced in your sample app: https://scans.gradle.com/s/5t6xzwhjzmxwo

Reason: 
Task ':app:prepareLibraryDefinitionsDebug' uses this output of task ':aboutlibraries:packageDebugResources' without declaring an explicit or implicit dependency. 
This can lead to incorrect results being produced, depending on what order the tasks are executed.

These are the only changes I made:

image

I made the :app module use the :aboutlibraries module (folder) as the source for the json files.

mikepenz commented 8 months ago

Happy new year to you too! I'll try to come back to this as soon as possible. Thank you!

mikepenz commented 8 months ago

I had a chance to look into this. So it seems the problem is because the aboutlibraries folder itself gets modified by tasks prior to the generation of the libs. (given it includes the build folder)

If you modify the location to something like aboutlibraries/configs then the problem will also go away.

Screenshot 2024-01-06 at 09 47 30

I am not sure if this is something the plugin needs to handle 🤔

Can you perhaps explain more, if you need to have the libraries and licenses in the root of the module instead of in a folder within your module?

blundell commented 8 months ago

Thanks for finding the time.

Can you perhaps explain more ... [why they are] in the root of the module instead of in a folder within your module?

It's an inherited legacy project, so I don't have an answer sorry :-)

However there is nothing blocking me from creating a new configs subfolder so that's a good workaround fix 👍

Thanks for the help! At least you know now if someone else raises it, perhaps a really small footnote in the documentation, but it now seems a very small edge case!

blundell commented 8 months ago

(Confirmed, making a subfolder under the project folder in the original project that had this issue, fixed the problem / stopped gradle raising a warning 👍 )

aboutLibraries {
    configPath = "my-module/configs"
}
mikepenz commented 8 months ago

You are welcome!

Thank you very much for confirming!