Prelude Travis Maven

Alternative to import java.lang._, scala._, scala.Predef._. Prelude is a subset of the default imports, meaning that any code compiled under -Yno-imports & import prelude._ should also compile with the default scalac configuration.

build.sbt:

scalacOptions in ThisBuild +=
  "-Yno-imports"

libraryDependencies +=
  "in.nvilla" %%% "prelude" % "latest.integration"

*.scala:

import prelude._

Suggested migration:

  1. Update build.sbt

  2. Add a prelude import after the first empty line of each .scala file:

    git ls-files | grep -e '.scala$' |\
    while read file; do
      if ! grep -q "import prelude._" "$file"; then
        sed -i.class '1,/^$/ {/^$/aimport prelude._
    }' "$file"
      fi
    done
  3. Explicitly import what your project uses scala._ and scala.Predef._:

    git ls-files | grep -e '.scala$' |\
    while read file; do
      for import in                               \
          "import scala.collection.immutable.Seq" \
          "import scala.collection.immutable.Set" \
          "import scala.collection.immutable.Map" \
          ; do # ^ Add imports as needed
        class=$(echo $import | rev | cut -d "." -f1 | rev)
    
        if grep -q "$class" "$file" && ! grep -q "$import" "$file"; then
          sed -i.class '1,/^$/ {/^$/a'"$import"'
    }' "$file"
        fi
      done
    done