Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrade project to Scala 2.13: JavaConversions is not a member of package collectio

Tags:

maven

scala

twirl

I want to upgrade Scala version in multimodule maven project from 2.11 to 2.13. I changed all Scala version and Scala suffix version in pom.xml, updated the dependency version. I got next error in compilation:

 \target\generated-sources\twirl\txt\template.template.scala:12: object JavaConversions is not a member of package collection

In target folder I found compiled object of twirl template:

import _root_.play.twirl.api.JavaScript
import _root_.play.twirl.api.Xml
....
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._

object analyze_template extends _root_.play.twirl.api.BaseScalaTemplate[pla

From twirl template:

@(sourceIncrementName: String, sourceSnapshotName: String)

Could you tell me how to resolve it?

In maven I have scala-maven-plugin and twirl plugin:

            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <jvmArgs>
                        <jvmArg>-Xms128m</jvmArg>
                        <jvmArg>-Xmx1024m</jvmArg>
                        <jvmArg>-XX:MaxPermSize=512m</jvmArg>
                    </jvmArgs>
                    <args>
                        <arg>-unchecked</arg>
                        <arg>-deprecation</arg>
                        <arg>-explaintypes</arg>
                        <arg>-feature</arg>
                        <arg>-language:implicitConversions</arg>
                    </args>
                    <recompileMode>incremental</recompileMode>
                    <scalaVersion>2.13</scalaVersion>
                </configuration>
            </plugin>
       <plugin>
           <groupId>com.jakewharton.twirl</groupId>
           <artifactId>twirl-maven-plugin</artifactId>
           <version>1.1.0</version>
           <executions>
               <execution>
                   <phase>generate-sources</phase>
                   <goals>
                       <goal>compile</goal>
                   </goals>
               </execution>
           </executions>
       </plugin>

And twirl dependency:

    <dependency>
        <groupId>com.typesafe.play</groupId>
        <artifactId>twirl-api_2.13</artifactId>
    </dependency>
like image 599
Vadim Avatar asked Sep 10 '25 15:09

Vadim


1 Answers

As of Scala 2.13, the object JavaConverters in scala.collection package has been deprecated. You have to use scala.jdk.CollectionConverters henceforth. You can find the full documentation here

like image 85
Yayati Sule Avatar answered Sep 13 '25 05:09

Yayati Sule