thombergs / buckpal

An example approach for implementing a Clean/Hexagonal Architecture
https://leanpub.com/get-your-hands-dirty-on-clean-architecture/overview
2.18k stars 666 forks source link

Cycle buckpal-application, buckpal-testdata #15

Closed LorenzoBettini closed 4 years ago

LorenzoBettini commented 4 years ago

Hi

when trying to import the projects into Eclipse (with Buildship for Gradle) I had a few issues, when trying to simply import it with the wizard; when using the automatic project detector from a git repository I finally managed to have projects imported but I get this error on most projects:

One or more cycles were detected in the build path of project 'buckpal-application'. The paths towards the cycle and cycle are:
->{buckpal-application, buckpal-testdata}

Indeed in buckpal-application there's a

dependencies {
...
    testImplementation project(':buckpal-testdata')
}

and in buckpal-testdata there's a

dependencies {
    implementation project(':buckpal-application')
}

I'm a Maven user and I'm not familiar with Gradle at all, but the above actually looks like a cycle to me...

In general, is the project meant to be imported in an IDE such as Eclipse?

thombergs commented 4 years ago

That cycle is actually not an accident.

The buckpal-testdata module provides some testdata factories to create instances of some domain classes that live in buckpal-application. That means the testdata module needs to have access to the application module. In order to be able to use the testdata factories in tests, the application module needs to have access to it, too, but only in test scope.

This is a cycle, but at test time only. Gradle recognizes this. IntelliJ does, too (because it's using Gradle under the covers). It seems that Eclipse does not. You can import it in the IntelliJ Community edition if you want to explore it in an IDE. Sorry, I can't give you a better answer, but this problem is new to me. I might explore this in a blog post one day :).

I don't consider this cycle "bad form" because it provides a nice way of "exporting" test data factories to other modules

LorenzoBettini commented 4 years ago

I can have Eclipse ignore the cycle error (turn it into a warning), so that I can go on. In any case, IMHO, a cycle is still a cycle and it sounds like a code smell. Maven would not allow that, Gradle might allow that, but it still sounds strange ;)