Multiproject with different classLoaders


I have two projects which require different versions of a lib
project_1 - lib_v3
project_2 - lib_v4

The class - Class_in_project_2_Depending_On_Lib_v4 I need to run is in project_2 which depends on lib_v4. When I run it from project_2 everything is fine but when I configure project_2 as dependency of project_1:

compile project(“:project_2”){
transitive false
exclude module: “project_2” // make sure I do not inherit

and import Class_in_project_2_Depending_On_Lib_v4 into a class in project_1 - I start getting exceptions because it is using the old lib_v3

Could you please provide me with some guidance how I can reconfigure projects so to achieve:
Use “Class_in_project_2_Depending_On_Lib_v4” into project_1 but still resolving its dependencies from project_2

if i’m not mistaken, the solution that’s fits your needs is composite build. With composite build you can manage your dependencies in the right way.