timefold-solver icon indicating copy to clipboard operation
timefold-solver copied to clipboard

Upgrade from Optaplanner Failure: Missing rewrite() Method in upgrade-timefold.gradle Script

Open AvatarHwang opened this issue 1 year ago • 4 comments

Describe the bug Gradle build fails with an exception when running the upgrade script for Timefold Solver. The error indicates that the rewrite() method is not found.

Expected behavior he Gradle build should complete successfully, applying the necessary upgrades without any errors.

Actual behavior The build fails with the following error message:

No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.rewrite() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl) values: [ai.timefold.solver:timefold-solver-migration:1.15.0]
Possible solutions: wait(), wait(long), create(java.lang.Object), with(groovy.lang.Closure)
> Could not find method rewrite() for arguments [ai.timefold.solver:timefold-solver-migration:1.15.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

To Reproduce

  1. Run the following command in the terminal:
curl https://timefold.ai/product/upgrade/upgrade-timefold.gradle > upgrade-timefold.gradle
gradle -Dorg.gradle.jvmargs=-Xmx2G --init-script upgrade-timefold.gradle rewriteRun -DtimefoldSolverVersion=1.15.0

Environment

Optaplanner 8.30.0.Final:

Output of java -version:

java version "1.8.0_292"
openjdk version "21.0.3" 2024-04-16 LTS
OpenJDK Runtime Environment Corretto-21.0.3.9.1 (build 21.0.3+9-LTS)
OpenJDK 64-Bit Server VM Corretto-21.0.3.9.1 (build 21.0.3+9-LTS, mixed mode, sharing)

Output of uname -a or ver:

Darwin Sunyeols-MacBook-Pro.local 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:37:25 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6030 arm64

Additional information

The issue seems to be related to the rewrite() method not being available in the DefaultDependencyHandler class. This might be due to a missing plugin or an incorrect method call in the [upgrade-timefold.gradle] script.

AvatarHwang avatar Oct 29 '24 02:10 AvatarHwang

Hello @AvatarHwang, and thanks for reporting! Can you please share the version of Gradle you were using?

Also, these two versions do not match:

java version "1.8.0_292" openjdk version "21.0.3" 2024-04-16 LTS

Java 8 is not supported and any failure is possible there. That said, I am not sure how the same command can report both a version 8 (unsupported) and 21 (supported). Please ensure you actually run with Java 17+, and not Java 8.

triceo avatar Oct 29 '24 06:10 triceo

Hello! Thank you for your response.

I would like to clarify my environment:

  • Gradle version: 8.8
  • Please disregard the Java 1.8.0_292 version that was mistakenly included in my report.

Let me know if you need any additional information.

AvatarHwang avatar Oct 29 '24 06:10 AvatarHwang

Thank you for clarifying. We have had several similar reports in the past - unfortunately, we were never able to reproduce this locally, and therefore we do not have a fix.

There must be something environment-specific which causes this issue and we do not know what it is. I can only recommend running the migration through Maven, or doing it manually - both are described here:

https://docs.timefold.ai/timefold-solver/latest/upgrading-timefold-solver/upgrade-from-optaplanner

triceo avatar Oct 29 '24 07:10 triceo

Thank you for the alternative suggestions.

Thanks for your help!

AvatarHwang avatar Oct 29 '24 07:10 AvatarHwang