Maven
Getting Started
Configuring Bloop with Maven projects speeds up developer workflows and gives you access to a modern Scala toolchain, despite Maven traditionally lacking good Scala support.
However, the Maven integration has a few issues that are not actively being worked on. If you're a Maven user, please help out and introduce yourself in our Bloop Discord channel or comment on one of the open issues in its own repo at scalacenter/bloop-maven-plugin
.
Requirements
- Your build uses
scala-maven-plugin
Export your build
The Bloop plugin for Maven doesn't need to be installed, you can run bloopInstall
, the task to export your Maven builds to bloop, with the following command.
$ mvn ch.epfl.scala:bloop-maven-plugin:2.0.1:bloopInstall
In some cases, when you are using generated sources in you project you might need to run:
$ mvn generate-sources ch.epfl.scala:bloop-maven-plugin:2.0.1:bloopInstall
Note: if you've used this command before you'll have noticed the artifact name has changed. In the past you would have used maven-bloop_2.13
, however as of the 2.x series the artifact name has changed to bloop-maven-plugin
.
To build with a single Scala project foo
generates two configuration files:
$ mvn ch.epfl.scala:bloop-maven-plugin:2.0.1:bloopInstall (...) Generated '/disk/foo/.bloop/foo.json'. Generated '/disk/foo/.bloop/foo-test.json'.
where:
foo
defines the main project; and,foo-test
defines the test project and depends onfoo
The bloop-maven-plugin
generates two configuration files per Maven project. One project for the main sources and another one for the tests. Bloop will skip config file generation for those projects that are not either Java or Scala.
Verify installation and export
Verify your installation by running bloop projects
in the root of the Maven workspace directory.
$ bloop projects foo foo-test
If the results of bloop projects
is empty, check that:
- You are running the command-line invocation in the root base directory (e.g.
/disk/foo
). - The Maven build export process completed successfully.
- The
.bloop/
configuration directory contains bloop configuration files.
If you suspect bloop is loading the configuration files from somewhere else, run --verbose
:
$ bloop projects --verbose [D] Projects loaded from '/my-project/.bloop': foo foo-test
Here's a list of bloop commands you can run next to start playing with bloop:
bloop compile --help
: shows the help section for compile.bloop compile foo-test
: compiles foo'ssrc/main
andsrc/test
.bloop test foo-test -w
: runs foo tests repeatedly with file watching enabled.
After verifying the export, you can continue using Bloop's command-line application or any build client integrating with Bloop, such as Metals.
Next steps after installation
Use an IDE such as Metals or IntelliJ to write code or play with the CLI if you want to explore what CLI options are available.
If you need help, you can always come over our Discord channel.
Well-known issues
Detecting Java projects
At the moment, Java projects are only partially supported in the Maven export. If you experience issues with this please open an issue.