Compiling subprojects in sbt

I have some subprojects that I need to compile with sbt. The structure looks like this:

main_project - sub_project1 - sub_project2 - sub_project3 

Of course, they have the correct directory hierarchy (src-mainscala ....). How can I compile them all and in each of them?

+13
source share
2 answers

See interactive projects :

At the sbt interactive prompt, type projects to list your projects and project <projectname> to select the current project. When you run a task of type compile , it starts in the current project. Therefore, you do not need to compile the root project, you can only compile the subproject.

You can use aggregate to compile them.

+17
source

Since the selected answer, the related documentation has changed, the answer is no longer so clear.

In the build.sbt OP main_project , in order to put them together, they will have to define aggregate , as the new (er) documentation refers to:

 lazy val root = (project in file(".")) .aggregate(util, core) lazy val util = (project in file("util")) lazy val core = (project in file("core")) 

And then running sbt compile in the project root directory will compile them all.

However, if you want to compile one at a time, you can go to the cmd line / terminal to the root project (here main_project ) and then run the following command:

user:main_project$: sbt <project name> / compile

use an example poster:

user:main_project$: sbt sub_project1 / compile

(if you are in the SBT terminal, you can omit sbt )

0
source

Source: https://habr.com/ru/post/952877/


All Articles