Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle Migration Script Failure and Rewrite Issues in Spring Boot Application Upgrading from OptaPlanner to Timefold Solver #757

Open
NaruRidan opened this issue Mar 27, 2024 · 5 comments
Labels
bug Something isn't working process/needs triage Requires initial assessment of validity, priority etc.

Comments

@NaruRidan
Copy link

Describe the bug
When attempting to migrate a Spring Boot application from OptaPlanner to Timefold Solver using the provided Gradle script, I encountered a failure during the execution process. The goal was to automate the upgrade via the Gradle script specified by Timefold's documentation, aiming for a seamless transition to leverage Timefold Solver's capabilities within my Spring Boot project.

Expected behavior
I anticipated a smooth migration process facilitated by the Gradle script, which would automatically update project dependencies, adjust import statements, and apply necessary configurations for integrating Timefold Solver with my Spring Boot application.

Actual behavior
The migration attempt was unsuccessful, resulting in a method signature error concerning the classpath in the dependencies block of the upgrade-timefold.gradle script. Additionally, the process encountered issues with the rewrite functionality, which was supposed to apply automatic code modifications for the migration but failed to execute as expected.

To Reproduce

Follow Timefold Solver's migration guide for obtaining the upgrade-timefold.gradle script.
In the Spring Boot project directory, execute: gradle -Dorg.gradle.jvmargs=-Xmx2G --init-script upgrade-timefold.gradle rewriteRun -DtimefoldSolverVersion=1.8.0
Encounter the error related to classpath usage and issues with rewrite functionality.
Environment
Timefold Solver Version or Git ref: 1.8.0

Output of java --version:

openjdk 17.0.2 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)

Windows 11

@NaruRidan NaruRidan added bug Something isn't working process/needs triage Requires initial assessment of validity, priority etc. labels Mar 27, 2024
@triceo
Copy link
Contributor

triceo commented Mar 27, 2024

Thanks for reporting, @NaruRidan. Can you please provide the version of Gradle you used?
Also, if you could send the specific errors you were shown, preferrably with stack traces, that would be useful.

@NaruRidan
Copy link
Author

NaruRidan commented Mar 27, 2024

Sure, Gradle 8.6.

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.8.0 --stacktrace; rm upgrade-timefold.gradle

FAILURE: Build failed with an exception.

  • Where:
    Initialization script 'C:\Nadir\timerbee\timerbee\upgrade-timefold.gradle' line: 1

  • What went wrong:
    Could not compile initialization script 'C:\upgrade-timefold.gradle'.

startup failed:
initialization script 'C:\upgrade-timefold.gradle': 1: Unexpected character: '?' @ line 1, column 1.
??
^

1 error

  • Try:

Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.

  • Exception is:
    org.gradle.groovy.scripts.ScriptCompilationException: Could not compile initialization script 'C:\Nadir\timerbee\timerbee\upgrade-timefold.gradle'.
    ...

Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
initialization script 'C:\Nadir\timerbee\timerbee\upgrade-timefold.gradle': 1: Unexpected character: '?' @ line 1, column 1.
??
^

1 error

    at org.apache.groovy.parser.antlr4.AstBuilder.collectSyntaxError(AstBuilder.java:4321)
    at org.apache.groovy.parser.antlr4.AstBuilder.createParsingFailedException(AstBuilder.java:4304)
    at org.apache.groovy.parser.antlr4.AstBuilder.convertException(AstBuilder.java:261)
    at org.apache.groovy.parser.antlr4.AstBuilder.buildCST(AstBuilder.java:235)
    at org.apache.groovy.parser.antlr4.AstBuilder.buildAST(AstBuilder.java:269)
    at org.apache.groovy.parser.antlr4.Antlr4ParserPlugin.buildAST(Antlr4ParserPlugin.java:58)
    at org.gradle.groovy.scripts.internal.DefaultScriptCompilationHandler.compileScript(DefaultScriptCompilationHandler.java:158)
    ... 173 more

`

@triceo
Copy link
Contributor

triceo commented Mar 27, 2024

I wasn't able to reproduce on Linux. Your problem is possibly platform-specific, seeing as you run on Windows. The problem with "unexpected character" tells me character encodings are in the mix. Did you make sure Gradle is reading the files in the correct encoding?

This doesn't seem like something that we can fix on our end. But if you can provide a project that I can run on my machine to try to reproduce it, that'd help.

@NaruRidan
Copy link
Author

Could you tell me how to adjust the encoding settings so that Gradle correctly reads the files?
Thank you. I appreciate your help.

@triceo
Copy link
Contributor

triceo commented Mar 27, 2024

I don't use either Gradle or Windows, but it seems that StackOverflow knows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working process/needs triage Requires initial assessment of validity, priority etc.
Projects
None yet
Development

No branches or pull requests

2 participants