§Importing an sbt project into Eclipse
If you used the Giter8 template to create a build as described in Creating and running Hello World with sbt, you will have an sbt project. To make it possible to import the project into Eclipse, sbt provides an sbt-eclipse plugin that generates Eclipse project artifacts for each of the subprojects.
Follow these steps to integrate your project with Eclipse:
§Import the project
-
In a console,
cd
to the top-level folder of your existing sbt project, and entersbt eclipse
to generate the Eclipse project files for all projects in your build.
The sbt plugin creates.project
and.classpath
files for the subprojects. The last few lines of output confirm success:... [info] Successfully created Eclipse project files for project(s): [info] hello-impl [info] hello-api [info] hello-stream-impl [info] hello-stream-api [info] lagom-internal-meta-project-service-locator [info] lagom-internal-meta-project-cassandra
-
Start Eclipse and switch to the Workspace you want to use for your Lagom project.
-
From the File menu, select Import.
The Select screen opens. -
Expand General, select Existing Projects into Workspace and click Next.
The Import Projects page opens. -
Click Browse, select the top-level sbt project folder, and click OK.
The sub-projects display in the dialog. For example: - Optionally, select Copy projects into workspace.
- Click Finish.
§Create an External Tool Configuration
- From the Eclipse toolbar, click External Tools and select External Tools Configurations.
- In the left pane, select Program and click New Launch Configuration.
- Create your configuration as follows:
- Enter a name.
- On the Main tab in the Location field, enter the location of your sbt installation.
For Windows, browse to the location where you installed sbt and selectsbt.bat
. On Linux, you can find the location of sbt by opening a terminal and enteringwhich sbt
. - For Working Directory browse to the top-level sbt project folder. (This is the folder containing the
build.sbt
file.) - In the Arguments field, enter
runAll
. - Click Apply. Your screen should look similar to the following:
- Click Run.
On success, the console shows that the services are running.
Verify that the services are indeed up and running by invoking the
hello
service endpoint from any HTTP client, such as a browser:``` http://localhost:9000/api/hello/World ```
The request returns the message
Hello, World!
.