Search code examples
javaspring-bootmavenspring-boot-maven-plugin

How to configure a Maven project to generate a different jar for each implementation of an interface


I have to build a small Springboot application where the Controller class uses an interface. The interface is implemented by four different classes. These four implementations represent four different platforms the application will run in and have dependencies based on the different platforms they run on. In any one platform, only one of the implementations will be used.

Therefore, I want to be able to package the application as four separate jars, each of which contains one implementation (so I can deploy the app based on the platform with only one implementation). I have no idea how to get this working. Any help is appreciated. Any hints on how I would have the folder structure of the project as well would help a lot too.


Solution

  • Use a multi-module project, with one common module and four modules for the different implementations.