Siarhei Skavarodkin
Siarhei Skavarodkin

Reputation: 118

Gradle & Spring Boot: choose dependency with implementation

I have:

The implementation of X depends on the client we prepare build for.

Options I have in mind:

Now there is a question what are the best practices to follow?

Upvotes: 2

Views: 447

Answers (1)

Opal
Opal

Reputation: 84766

Both mechanisms of handling the presented problem are more or less equivalent. I find including only single dependency (namely XN) not only easier to implement using this technology stack but also more reliable:

  • reliable because there's only one particular dependency found on runtime - it's impossible that spring will mess something up with DI
  • easier because if only one implementation is included there's no need for manually handling DI.
  • if only single implementation will be used at runtime - what's the reason for including the else?

Two important things here:

  • provide a detailed log message not only which implementation is included (during build time) but also which one is used (during runtime)
  • it can be done in gradle in two different ways on war level or in dependencies block. Personally I'd go for dependencies block - it make war easier to build.

Upvotes: 1

Related Questions