scalac Command: Compile Scala in CI
scalac compiles Scala source files into JVM class files.
scalac is the Scala compiler. Real projects build through sbt or Mill, but scalac shows up in CI scripts and minimal images. Its flags control output, classpath, and how strictly warnings are enforced.
Common flags
-d OUT- output directory or .jar for class files-classpath/-cp PATH- dependency class path-deprecation- emit warnings for deprecated API use-feature- warn on language features requiring an import-Xfatal-warnings- turn all warnings into errors-release 17- target JVM bytecode and API level-language:postfixOps- enable a specific language feature
Example in CI
Compile a Scala source tree strictly, failing on any warning:
shell
scalac -deprecation -feature -Xfatal-warnings -release 17 -d build src/*.scalaCommon errors in CI
- error: not found: value X - unresolved identifier or missing import
- error: type mismatch; found: A, required: B
- error: object X is not a member of package Y - missing dependency on classpath
- error: No warnings can be incurred under -Werror (Scala 3) - a warning failed the build
Key takeaways
- Use
-Xfatal-warnings(Scala 2) or-Werror(Scala 3) to keep CI strict. -release Npins both bytecode and the JDK API surface.- Most CI failures are "not found" identifiers or type mismatches.
Related guides
kotlinc Command: Compile Kotlin in CIkotlinc is the Kotlin compiler. Reference for -include-runtime, -d, -classpath, -jvm-target, -Werror, and the…
javac Command: Compile Java in CIjavac is the Java compiler. Reference for -d, -cp/-classpath, --release, -source/-target, -Xlint, and the pac…
mvn Command: Build Maven Projects in CImvn is the Maven build tool. Reference for clean, install, verify, -B, -DskipTests, -P, -pl, and the Maven CI…