0

Consider the following project structure as a Gradle build:

backend
|- adapters
   |- adapter-common
   |- bar-adapter
      |- bar-entrypoint
      |- bar-models
      \- bar-services
   \- foo-adapter
      |- foo-entrypoint
      |- foo-models
      \- foo-services
|- backend-common
|- db-conn
|- backend-entrypoint
|- build.gradle
\- settings.gradle

The dependency structure is as follows:
foo-adapter depends on foo-entrypoint and adapter-common
foo-entrypoint depends on foo-services
foo-services depends on foo-models
adapter-common depends on backend-common & db-conn

Now I have a separate project api where I need foo-adapter as a dependency. I found this Q&A which seems to be the same situation but when I tried it I get errors about how none of the other projects (adapter-common, db-conn, etc.) are found.

Am I asking too much from Gradle by telling it to just import foo-adapter and then expecting it to pull in and resolve all the dependencies itself?

Is there any way to get this to work without declaring basically the whole backend project in my api settings file?

Community
  • 1
  • 1
rorschach
  • 2,871
  • 1
  • 17
  • 20

1 Answers1

1

If your foo-adapter project use some classes from other projects it cannot be added without the others. Not matters it's a jar or just uncompiled stuff. You need the others too. It's a really bad approach to depend a project on another. Better you use only interfaces and put them into a separate project. Thus your projects can be compiled independently and you need just one configuration project that combines all that stuff.

CyberAleks
  • 1,545
  • 1
  • 14
  • 17