JakeWharton / twirl-maven-plugin

A Maven plugin which compiles Twirl templates into Scala source files.
Apache License 2.0
40 stars 16 forks source link

Generated sources are not scala-2.13 compatible #16

Closed andreak closed 4 years ago

andreak commented 4 years ago

The generated scala-file contains reference to JavaConversions which doesn't exist in scala-2.13

package com.visena.invoice.report.pdf.xml

import _root_.play.twirl.api.JavaScript
import _root_.play.twirl.api.Xml
import _root_.play.twirl.api.Html
import _root_.play.twirl.api.TwirlHelperImports._
import _root_.play.twirl.api.TwirlFeatureImports._
import _root_.play.twirl.api.Txt
import java.lang._
import java.util._
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._

My maven-config is:


    <properties>
        <version.twirl>1.5.0</version.twirl>
        <version.scala>2.13</version.scala>
        <version.scala-parser-combinators>1.1.2</version.scala-parser-combinators>
    </properties>
<plugin>
    <groupId>com.jakewharton.twirl</groupId>
    <artifactId>twirl-maven-plugin</artifactId>
    <version>1.2.0</version>
    <dependencies>
        <dependency>
            <groupId>com.typesafe.play</groupId>
            <artifactId>twirl-compiler_${version.scala}</artifactId>
            <version>${version.twirl}</version>
        </dependency>
        <dependency>
            <groupId>org.scala-lang.modules</groupId>
            <artifactId>scala-parser-combinators_${version.scala}</artifactId>
            <version>${version.scala-parser-combinators}</version>
        </dependency>
    </dependencies>
</plugin>

Any hints?

JakeWharton commented 4 years ago

I don't actually use this project anymore so I'm ill-suited to solving the issue, unfortunately. If you or anyone can come up with a fix to make the tool compatible with 2.13 I'd be happy to integrate and release, though.

andreak commented 4 years ago

Over at gitter: https://gitter.im/playframework/playframework?at=5d039661325b465cc328e7b0# the concept of default-imports was mentioned, and that the sbt-plugin is configured with default-imports for twirl. Can you point me to the default-imports are configured in the maven-plugin?

andreak commented 4 years ago

I solved it with the useJavaHelpers=false config-parameter:

<configuration>
    <useJavaHelpers>false</useJavaHelpers>
</configuration>

Closing the issue