apache / lucene

Apache Lucene open-source search software
https://lucene.apache.org/
Apache License 2.0
2.61k stars 1.02k forks source link

gradlew regenerate fails with current gradle version #13240

Closed rmuir closed 5 months ago

rmuir commented 6 months ago

Description

While working on #13239, I did find another pre-existing condition with gradlew regenerate besides the groovy version not being able to read java 21 .class files.

I think it is new pickiness of the gradle version we are on, that we've just yet to notice until now. it does not like something about how our tasks depend on each other:

$ ./gradlew regenerate --rerun-tasks
...
> Task :lucene:core:generateForUtilInternal FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':lucene:core:generateForUtilInternal' (type 'DefaultTask').
  - Gradle detected a problem with the following location: '/home/rmuir/workspace/lucene/lucene/core/src/java/org/apache/lucene/codecs/lucene99/ForUtil.java'.

    Reason: Task ':lucene:core:compileJava' uses this output of task ':lucene:core:generateForUtilInternal' 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 ':lucene:core:generateForUtilInternal' as an input of ':lucene:core:compileJava'.
      2. Declare an explicit dependency on ':lucene:core:generateForUtilInternal' from ':lucene:core:compileJava' using Task#dependsOn.
      3. Declare an explicit dependency on ':lucene:core:generateForUtilInternal' from ':lucene:core:compileJava' 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.

It isn't just this one task nor is it just lucene-core. If you try excluding troublesome tasks such as FOR generation, then you'll just hit it in StandardTokenizer, exclude that, and you'll just hit the same issue in lucene-analyzers with more tokenizers there.

NOTE: There's a workaround though for now, I moved past the issue like this:

$ ./gradlew compileJava && ./gradlew regenerate -x compileJava --rerun-tasks
dweiss commented 6 months ago

Eh. This is something that wasn't there in previous gradle versions. Now it's a bit paranoid about inputs/outputs overlapping because of caches (I think...). The suggestions it gives are not acceptable because we don't want that task to always run. The mustRunAfter is the closest to what I think is right... but it assumes regenerate and compilation run in the same execution cycle, which I don't think we "support"? I'm not sure what can be done about it.

rmuir commented 6 months ago

We can doc the workaround as a possible solution. When I run into trouble I just go to the help/

dweiss commented 6 months ago

Could you leave this issue open for me but add a comment to the help file for now, @rmuir ? I'll take another look at it but Easter holidays are quite intense in this part of the world so I need to find a time slot.

rmuir commented 6 months ago

I pushed https://github.com/apache/lucene/commit/e2110e0b8e8a38d93c387db9d0d67fb4fe577181 for now. Enjoy your holidays, there's no urgency to this, I just didn't want anyone else to struggle debugging it

dweiss commented 6 months ago

Thank you. I'll get back to this and will try to make it work again.