For Gradle & Spring Boot, how do I choose dependency with implementation?

0 votes

I have library X with pure interfaces, libraries X1, X2, X3, ..., XN which implement interfaces from X and SpringBoot project Y built with Gradle 4 and using X

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

Options I have in mind:

  • Include all implementation as dependencies and have configuration variable which will be discovered runtime and define used implementation.
  • Conditional Gradle build gradle build -Pclient=client1 which will include only one specific implementation

So which among those is best to follow? Can anyone help me with this?

thanks

Jun 16, 2018 in DevOps Tools by Atul
• 10,200 points
46 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Below is the answer to your question:

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.

Hope above explanation will help you.

answered Jun 16, 2018 by shubham
• 6,480 points

Related Questions In DevOps Tools

0 votes
1 answer

How do I run “ant update” in Hybris with only “Update Running System”?

Here is what you can try. You can ...READ MORE

answered Jul 10, 2018 in DevOps Tools by Atul
• 10,200 points
775 views
0 votes
1 answer

How do I set maximum queue connection for nginx port in Windows?

Since increasing queue size did not fix your problem ...READ MORE

answered Aug 22, 2018 in DevOps Tools by Damon Salvatore
• 5,250 points
40 views
0 votes
1 answer

How do I kill Wagtail server?

Here is the explanation regarding the above ...READ MORE

answered Jun 25, 2018 in DevOps Tools by anonymous
33 views
+1 vote
3 answers

How do I check and export sonarqube analysis reports in embedded db?

Browse to sonarqube web instance to access ...READ MORE

answered Jul 2, 2018 in DevOps Tools by DareDev
• 6,520 points
1,498 views
0 votes
1 answer

How do I deploy to multiple servers using the same context root?

  If you're deploying to multiple servers ...READ MORE

answered Jul 2, 2018 in DevOps Tools by Kalgi
• 35,800 points
35 views
0 votes
1 answer

How to manage multiple components with IBM Bluemix Track & Plan

As of now, there is not a ...READ MORE

answered Jul 6, 2018 in DevOps Tools by Kalgi
• 35,800 points
36 views
+13 votes
2 answers
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.