Skip to content

Instantly share code, notes, and snippets.

@metasim
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metasim/6230838cd5c309b37d2b to your computer and use it in GitHub Desktop.
Save metasim/6230838cd5c309b37d2b to your computer and use it in GitHub Desktop.
Quickly convert a bunch of Java files to Scala from the command line

Here's one way of brute-force converting a bunch of Java code to Scala without too much concern for correctness.

Hard stuff is done by scalagen.

If the project is Maven-based with an existing pom.xml, all you need to do is run the scalagen Maven plugin:

mvn com.mysema.scalagen:scalagen-maven-plugin_2.10.1:0.3.2:main -DtargetFolder=target/scala

You have to have a pom.xml file for this to work. If your project is configured with sbt (or have no project!), use the sbt makePom task to create one:

sbt makePom
...
cp target/scala-2.10/*.pom pom.xml # Or whatever your scala version is
mvn com.mysema.scalagen:scalagen-maven-plugin_2.10.1:0.3.2:main -DtargetFolder=target/scala
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment