playframework icon indicating copy to clipboard operation
playframework copied to clipboard

Add twirl toolchain support

Open Sineaggi opened this issue 3 years ago • 8 comments

Allows for the overriding of the java version used to invoke the twirl template compiler.

Resulting build.gradle.kts syntax would look like

tasks.compilePlayTwirlTemplates {
    javaLauncher.set(javaToolchains.launcherFor {
        languageVersion.set(JavaLanguageVersion.of(8))
    })
}

Note that if you're using a new version of java already, you can set the version of java used by the scala compiler via

tasks.compileScala {
    javaLauncher.set(javaToolchains.launcherFor {
        languageVersion.set(JavaLanguageVersion.of(8))
    })
}

Sineaggi avatar Jan 13 '22 23:01 Sineaggi

I've updated the mr to not directly depend on the JavaLauncher class being available, and have moved the code to a new extended TwirlCompile class. The code should now be compatible with the full gradle range currently supported.

Sineaggi avatar Jan 14 '22 20:01 Sineaggi

So it looks like the integration tests are failing for this reason

Property 'javaLauncher' annotated with @Internal should not be also annotated with @Optional. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.8/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.

I had fixed a similar issue in https://github.com/gradle/playframework/pull/175

Sineaggi avatar Jan 17 '22 04:01 Sineaggi

I misread, that error was about optional and not nullable. I've removed the @Optional annotation.

Sineaggi avatar Jan 18 '22 22:01 Sineaggi

@JLLeitschuh any chance somebody at https://github.com/gradle can check a look?

Sineaggi avatar Mar 24 '22 22:03 Sineaggi

Unfortunately, I'm not with Gradle anymore

JLLeitschuh avatar Mar 24 '22 23:03 JLLeitschuh

@JLLeitschuh Sorry for the ping then.

Sineaggi avatar Mar 29 '22 19:03 Sineaggi

@big-guy hello! Any chance somebody at gradle can review these changes?

Sineaggi avatar Mar 29 '22 19:03 Sineaggi

So toolchains were added in gradle 6.7, so versions under that would now be unsupported.

Example failure on Gradle 6.6

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:compilePlayTwirlTemplates'.
   > Could not create task of type 'TwirlCompile'.
      > Could not generate a decorated class for type TwirlCompile.
         > org/gradle/jvm/toolchain/JavaLauncher

Sineaggi avatar May 31 '22 18:05 Sineaggi