MIB gradle tasks - mpopp/MIB GitHub Wiki

Gradle tasks

MIB comes with a few gradle tasks that are meant to make your live significantly easier. The following tasks are meant to be called from the cmd line directly and take some of the infrastructure burden from you.

All of these tasks are meant to be executed from within MIB directory.

createMS

This task creates a new microservice from the blueprint and registers it in the settings.gradle file in MIB directory.

You call the command like this: gradle createMS -Pmsname=microservicename

This steps are executed by the gradle task:

  1. Copies the blueprint folder to your domaincode directory and renames the copied folder to
  2. Overwrites the current settings.gradle file in MIB directory with the settings.gradle.blueprint file.
  3. Scans the domaincode directory for all direct child folders and registers them in the fresh settings.gradle file in MIB. (MIB does this by using the updateMicroserviceIncludes task)

updateMicroserviceIncludes

This task is responsible for scanning your domaincode folder and registering every child folder in the settings.gradle file of MIB (non recursive scan)

You call the command like this: gradle updateMicroserviceIncludes

installApp

This is just the standard gradle installApp command that comes with the application plugin. Still if you execute that command from MIB directory you have a little more comfort than just calling it from every microservice folder separately.

When you call the installApp task from within MIB directory, installApp is executed on all registered microservices. After successful installation, all files are moved to the directory specified in the "ext.serviceDir" in MIB's build.gradle file.

Usage Scenarios

Cloning on a new developers machine

You will often phase the situation, that you already have code (using MIB) and a new developer joins the team. So what will that developer have to do for getting ready to write code?

  1. Clone the repository (thx mr. obvious)
  2. Initialize the MIB submodule in your git repository
  3. From within the MIB folder run gradle updateMicroserviceIncludes
  4. From within the MIB folder run gradle idea (assuming you use IntelliJ for development)
  5. Open the project file created in MIB folder with IntelliJ

Adding a new microservice

  1. Run the gradle createMS -Pmsname=microservicename task (described above)
  2. Run the 'gradle idea' task

Removing a microservice

Since we currently feel that this will happen rarely, removing a microservice is currently not supported with a separate gradle task. However, you can remove a microservice with these few steps:

  1. Delete the microservice project folder on your hard drive.
  2. Remove all dependencies to that microservice. (If you don't call a microservice method directly from another microservice but let all the services communicate over events, you probably don't have any dependencies of that category)
  3. From within the MIB folder run gradle updateMicroserviceIncludes
  4. From within the MIB folder run gradle idea (assuming you use IntelliJ for development)