playframework / twirl

Twirl is Play's default template engine
Apache License 2.0
546 stars 108 forks source link

Scala 3 support plans? #390

Closed rossabaker closed 2 years ago

rossabaker commented 3 years ago

Are there plans to cross-publish Twirl for Scala 3? We have an http4s integration I'd like to keep alive, and we're trying to identify the correct repo structure as we reorganize ourselves.

Thanks for the great tool!

(Bonus keyword: Dotty)

SethTisue commented 3 years ago

is there anyone watching the repo who would like to take a stab at a PR, even just to see what issues arise? you wouldn't need to commit to seeing it through to the end, any amount of progress would be helpful

rossabaker commented 3 years ago

I was able to keep it working for now thusly:

      libraryDependencies.value.map {
        case module if module.name == "twirl-api" =>
          module.withDottyCompat(scalaVersion.value)
        case module => module
      }

I don't recommend publishing libraries on withDottyCompat, but it seems a fair interim solution for applications.

SethTisue commented 3 years ago

There is a WIP PR at #394 that I intend to return to... hoping for May. We're a bit backed up dealing with the Bintray situation :-/

SethTisue commented 2 years ago

I am sorry, but I think at this point I need to just admit that I'm unlikely to return to this, so I'm going to close my PR. Someone else is free to tackle it.

brbrown25 commented 2 years ago

I'd be willing to pick up work on this. I should have some availability next week

mkurz commented 2 years ago

@brbrown25 That would be great! Is there anything I can help you with?

brbrown25 commented 2 years ago

@brbrown25 That would be great! Is there anything I can help you with?

I'll start hacking away at it and give you an update next week, just need to familiarize myself with the source as I've mostly been an end user of twirl!

mkurz commented 2 years ago

@brbrown25 Thanks, if you need guidance please let me know.

brbrown25 commented 2 years ago

Update, making some good progress. Gonna push up my WIP draft tomorrow. I got most of the basics in place, just need to work through the compiler pieces!

brbrown25 commented 2 years ago

Update, the WIP pr has the correct structure and the most of the cross compilation works. Only thing outstanding is updating the scala 3 version of the compiler module. There's some notes in the discussion on the pr what places will be to be updated. Also the majority of warnings have been resolved except for the CollectionConverts helper

shannonbarnes commented 2 years ago

I was able to keep it working for now thusly:

      libraryDependencies.value.map {
        case module if module.name == "twirl-api" =>
          module.withDottyCompat(scalaVersion.value)
        case module => module
      }

I don't recommend publishing libraries on withDottyCompat, but it seems a fair interim solution for applications.

This is how I am currently getting a project that uses twirl to cross-compile based on the above help.

libraryDependencies := {
      CrossVersion.partialVersion(scalaVersion.value) match {
        case Some((2, _)) => libraryDependencies.value
        case _ =>
          libraryDependencies.value.map {
            case module if module.name == "twirl-api" =>
              module.cross(CrossVersion.for3Use2_13).exclude("org.scala-lang.modules", "scala-xml_2.13")
            case module => module
          } ++ Seq("org.scala-lang.modules" %% "scala-xml" % "2.0.1")
      }
    }
brbrown25 commented 2 years ago

I was able to keep it working for now thusly:

@shannonbarnes the pr should hopefully get merged soon and then the interim solution can be replaced with the latest version :)

mkurz commented 2 years ago

Implemented in #461, please watch out for the twirl 1.6.0-M2 release coming this week, to help use test and give feedback.