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.69k stars 114 forks source link

Gradle deprecation warning: Antlr plugin #685

Open boris-petrov opened 2 years ago

boris-petrov commented 2 years ago

Plugin version 1.4.0

Gradle version 7.4.2

Describe the bug Running buildHealth on my project leads to the following deprecation warning in the explodeCodeSourceMain and explodeCodeSourceTest tasks:

> Task :subproj:explodeCodeSourceMain
Execution optimizations have been disabled for task ':subproj:explodeCodeSourceMain' to ensure correctness due to the following reasons:
  - Gradle detected a problem with the following location: '/home/project/subproj/build/generated-src/antlr/main'. Reason: Task ':subproj:explodeCodeSourceMain' uses this output of task ':subproj:generateGrammarSource' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
Gradle detected a problem with the following location: '/home/project/subproj/build/generated-src/antlr/main'. Reason: Task ':subproj:explodeCodeSourceMain' uses this output of task ':subproj:generateGrammarSource' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.4.2/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.

To Reproduce I guess the issue is because I'm using the antlr built-in Gradle plugin:

plugins {
    id 'antlr'
}

It should be simple enough to reproduce the issue by just adding the plugin to the build-script. If you have troubles reproducing, I'll try creating a repo.

Expected behavior No deprecation warning

autonomousapps commented 2 years ago

Thanks for the issue.

boris-petrov commented 1 year ago

I just saw a new one (using Gradle 7.5.1):

> Task :subproj:explodeJarMain
Build service 'inMemoryCache' is being used by task ':subproj:explodeJarMain' without the corresponding declaration via 'Task#usesService'. This will fail with an error in Gradle 8.0. Declare the association between the task and the build service using 'Task#usesService'. Consult the upgrading guide for further information: https://docs.gradle.org/7.5.1/userguide/upgrading_version_7.html#undeclared_build_service_usage

I see a similar one for findInlineMembers and findDeclaredProcs.

autonomousapps commented 1 year ago

I just saw a new one (using Gradle 7.5.1):

> Task :subproj:explodeJarMain
Build service 'inMemoryCache' is being used by task ':subproj:explodeJarMain' without the corresponding declaration via 'Task#usesService'. This will fail with an error in Gradle 8.0. Declare the association between the task and the build service using 'Task#usesService'. Consult the upgrading guide for further information: https://docs.gradle.org/7.5.1/userguide/upgrading_version_7.html#undeclared_build_service_usage

I see a similar one for findInlineMembers and findDeclaredProcs.

Could you file this as a separate issue, please?

boris-petrov commented 1 year ago

Sure, here you go. :)

autonomousapps commented 11 months ago

A workaround for this:

// Workaround for https://github.com/gradle/gradle/issues/25885
// Technically it should be `explodeCodeSourceMain dependsOn generateGrammarSource` and
// `explodeCodeSourceTest dependsOn generateTestGrammarSource`, but this module is so
// small it isn't worth fine-tuning it.
tasks.withType(com.autonomousapps.tasks.CodeSourceExploderTask) {
  dependsOn('generateGrammarSource', 'generateTestGrammarSource')
}
sergeykad commented 4 months ago

I have a similar issue with https://github.com/jsonschema2dataclass/js2d-gradle plugin instead of Antlr.

Vampire commented 1 month ago

Instead of the manual dependsOn, it is better to fix the broken Antlr setup, so that all tasks that consume sources are worked-around properly at once. Please find the proper work-around at https://github.com/gradle/gradle/issues/19555#issuecomment-1593252653 :-)