Work with Hilt with submodules of a feature module - dagger-hilt

Is there any way to make dagger hilt work with clean architecture that uses the presentation-domain-data as submodules?
For example I have Feature A as a module. This module has 3 submodules:
Presentation module
Domain module
Data module
How could I provide the needed dependencies for every submodule? If I create a DI module (Another layer) then I'll need have them 3 submodules as a dependency and somehow I must return these dependencies and I'm not able to do that because that creates a circular dependency (At least that's what I think)
DI -> Domain -> DI
DI -> Data -> DI
DI -> Presentation -> DI
Also I'm breaking the rule "Domain should not depend on any module"

Related

Publish multiple Gradle modules in one Maven artifact

I have a library project that consists of two different APIs (a and b) which should operate on the same core and base code. core is hidden from the user of a or b so there is an implementation dependency to core. But base is exposed to the user of a or b so there is an api dependency to base.
This is all fine as long as you stay in the Gradle world. But it becomes more complicated when you're publishing a and b with the maven-publish Gradle plugin. It creates an artifact of each of the modules separately and (correctly) outlines dependencies between them. But I don't want to expose core and base separately. Instead, I'd like to bundle them into one artifact for a and b each, where types in core stay internal and those in base are exposed.
Is there a way to do this with maven-publish?
You'll want to create a fat/uber JAR. There are plenty of tutorials out there, but a common approach is to use the Shadow plugin: https://imperceptiblethoughts.com/shadow/
You would configure the Shadow plugin to have core and base to be embedded/included in a and b without having to publish them.
There are 4 projects
a (api) - depends on base, core
b (api) - depends on base, core
core (lib) - depends on base
base (api) - none
assuming that all are building with java-library plugin.
If I got your question right - you want the end-users to see api's -a, b, base but not core - I am assuming this is applicable for DEV / Compile-time;
if above is correct - this is not with maven-publish; but rather dependency declaration
please see https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_separation
in a and b build.gradle
api base
implementation core
in core build.gradle
api base

Best practices to implement an Interface across different project modules

I have a multi module application, consisting of an interface in module A and an implementation in module B. Module A is linked to module B using dependency inversion where module B is injected into module A via #Autowiring. The main application will implement both module A and B and thus will not have any error. However, if module A is running on its own, it will not be able to find the implementation and throw an error.
May I seek your advice how should we best implement dependency inversion to follow CLEAN architecture and also to allow module A to run on its own?
Hope this diagram gives a better illustration of our problem

Spring boot parent pom with custom parent

I read a lot of posts regarding the ways to use spring-boot-starter-parent in a spring boot project.
Essentially, I read posts (Spring documentation also talks about this) describing two ways to do this
To use spring-boot-starter-parent as the project parent directly. It gives us the benefits of having the dependency management as well as the plugin management.
The other way is to import the spring-boot-starter parent in the project pom (we may need this in case we already have a parent pom for the project).
It allows us to get the benefits of dependency management but not the plugin management)
I am creating a new Maven multi module project. Ideally I would like to have my own custom parent and also get all the benefits of using the Spring-boot-starter-parent.
I was wondering if it made sense to create a custom parent for my maven projects. This parent would in turn be a child of the spring-boot-starter-parent.
If I am not missing anything, this way I could get the benefits of having the dependency management and plugin management from spring-boot-starter-parent and at the
same time have a custom parent for all my projects where I could define some other common dependencies or if needed override the dependencies defined in the
spring-boot-starter-parent which would then be inherited by all my projects.
Does this design make sense or am I missing something.
What are the drawbacks of this approach?
There are no drawbacks -- this is exactly what you're meant to do if you want a multimodule spring-boot project. However, consider this: typically multi-module projects have all modules versioned together, released together, and dependant on each other. This rarely makes sense in a group of spring-boot modules, which are typically of the micro-service style and which require independent evolution. So, you should question your need for a multi-module project at all.

Gradle circular dependency, force ignore

I am trying to create a service registry where all the modules are added as compile(project(..)). The service registry module expose an unified function to call any function from any module. This is to reduce the direct coupling between two modules and to provide a proper separation of concern. To call any function from any module one can add dependency of service-registry as project and get the function. But if we do that the project has circular dependency.
Is there a way I can force gradle to ignore circular dependency,
project root
project A
-- compile(project(':SR'))
project B
-- compile(project(':SR'))
project SR
-- compile(project(':A')
-- compile(project(':B')
I will be moving the dependencies to nexus and use versioning, but in initial phase it would be great if somehow I can force gradle not to do so.
Can it be done by doing some condition as
if(calling_project_name!=root) compile(project(':A'),project(':B'))exclude(project(':calling project name')
is it possible to do? Other suggestions are also welcome.
I am using gradle 2.7.

maven multi module project repeated build issue

I have created a multi module maven project as below
- root module(parent module. Building this will build the below children modules)
dao
service
web
dao and service modules creates the jar file. web module creates the final war file to be deployed. service module has the dependency of dao module. web module has the dependency of service module.
Whenever I implement new functionality, I have to modify all the modules from dao to web. I have a maven jetty plugin configured in web module. To test any new implemented functionality in UI I end up building dao and service modules always. Are there anyway to avoid this process and reflect the changes from dao and service modules whenever I run mvn jetty:run in web module?
No, there is no way to da that, and this is the intended behavior.
If you have these 3 projects, this means the have their own lifecycle. If not, the best is to have only one project.
However, you could avoid mentioning a version number in the project, and rely on a parent version number (your root module could also be the parent).
So, you could rebuild everything from the multi-module project.
However, I don't really see the point.
Why do you have 3 projects ?

Resources