☕Tech Coffee — Multi-repo Java Spring with Gitpod Tasks

Arturo Batistute
3 min readMay 3, 2022
Matrioska loop

Problem

When developing your projects you may face with a multi-repo project. If you use the Gitpod platform, you know that you are not able to run more than one API each time.

To resolve this, there’s the Gitpod tasks that handles this in a simple way.

In this article we will focus in the problem above. You can learn more abou the Multi-repo here: Multi-repo Workspaces (gitpod.io)

How implement?

If you are using the Gitpod platform, make sure that you already have a .gitpod.yml file in your root directory. If not, use the command:

gp init

The .gitpod.yml file, allows you to configure your workspace.

Then, let’s follow the example below to implement a quick way to startup two Java Spring projects.

Project architecture

Now, open the .gitpod.yml file so we can start describe our tasks.

If you already have a experience with kubernetes, you will see that this step is the same as declaring a pod for example.

We’re going to declare two tasks, one for each API. First we use the before tag to enter into the project folder:

Then, using Java with Maven, we can make a mvn install with skip tests using the init tag:

And finally, we use command tag to run our application:

You can learn more about creating the tasks here: Start Tasks (gitpod.io)

This is the result of our gitpod file:

Now, after describing our tasks, don’t forget to commit/push your modifications.

To see the result, close and reopen your Gitpod instance!

At the right side of your console you will see both Spring projects up and running at the same time.

SpringBoot consoles

You can also see the open ports in the right side:

SpringBott app open ports

These ports were declared in each Spring feature file.

Plus

If you don’t have all the repos needed in your workspace, you can use the Multi-repo Workspace feature: Multi-repo Workspaces (gitpod.io).

With this, you set the external project url and the Gitpod will clone the same in the folder that you specify. I’m about to explain this better in future articles.

Note

When using a Java application with Gitpod, you can install the extension Language Support for Java(TM) by Red Hat. With it, you will be able to Ctrl+click into your class and select the option: Run Java. But, you are limited to select this for just one API. If you repeat the same in another one, Gitpod will just ignore.

Another option to run more than one API at the same time is use the command in the terminal: mvn spring-boot:run .

Now that you are aware of all option, choose the one that best fits you.

Any comments and sugestions, feel free to get in touch!

See you soon padawan!

--

--

Arturo Batistute

My name is Arturo and I’m a Mechatronics Engineer and software developer. Here, you will learn about new Techs while you drink your morning cup of coffee.