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 17, 2018 in DevOps Tools by Atul
• 10,240 points
773 views

1 answer to this question.

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 17, 2018 by shubham
• 7,340 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,240 points
7,162 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,980 points
1,205 views
0 votes
1 answer

How do I optimize Docker images for faster builds and lower resource usage?

Optimizing Docker images significantly enhances CI/CD build times and deployment ...READ MORE

answered Nov 4 in DevOps Tools by Gagana
• 2,450 points
36 views
0 votes
0 answers

How do you configure CI/CD for a Node.js app with unit and integration tests?

How do you configure CI/CD for a ...READ MORE

Nov 14 in DevOps Tools by Anila
• 3,390 points
26 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,035 views
+2 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP