Skip to content

Commit

Permalink
Mention the Scala repl and its current gotchas in the docs (pantsbuil…
Browse files Browse the repository at this point in the history
…d#20445)

The Scala repl isn't currently mentioned at all in the docs, and 
you need to set an option to use it.
  • Loading branch information
jberkel authored Jan 21, 2024
1 parent 2179c2a commit ea7e37d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/docs/java-and-scala/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,31 @@ junit_tests(
)
```

## Repl

Pants supports the [Scala repl](https://docs.scala-lang.org/overviews/scala-book/scala-repl.html), but
doesn't yet autodetect it based on the active backend, it always defaults to using "python"
(see [#14133](https://github.com/pantsbuild/pants/issues/14133)), so for now you'll have to
explicitly add `--repl-shell=scala` to the command line:

```
❯ pants repl --repl-shell=scala src/jvm/org/pantsbuild/example/app/ExampleApp.scala
Welcome to Scala 2.13.8 (OpenJDK 64-Bit Server VM, Java 11.0.21).
Type in expressions for evaluation. Or try :help.
scala> import org.pantsbuild.example.app.ExampleApp
scala> ExampleApp.main(Array())
Hello World!
scala>
```

Alternatively, you can set "scala" to be the default repl in `pants.toml`:

```toml tab={"label":"pants.toml"}
[repl]
shell = "scala"
```

## Protobuf

There's support for [ScalaPB](https://scalapb.github.io/) and [protoc Java generated code](https://developers.google.com/protocol-buffers/docs/reference/java-generated), currently in beta stage. To enable them, activate the relevant backends in `pants.toml`:
Expand Down

0 comments on commit ea7e37d

Please sign in to comment.