junkdog / artemis-odb

A continuation of the popular Artemis ECS framework
BSD 2-Clause "Simplified" License
776 stars 111 forks source link

Fluid Entities circular dependency problem #507

Closed Ziamor closed 6 years ago

Ziamor commented 6 years ago

I decided to use Fluid Entities for my project but I've come across a problem. Some of my components use some classes I wrote (e.g Gradient class) which I originally had defined inside core. When I added Fluid Entities, the components that relied on my classes do not have access to them as Components is built first before Core. If I try to add a dependency to Core for Components I obviously get a circular dependency. I temporally solved the problem by moving the classes I defined into Components but from an organizational stand point it doesn't feel like they belong there. What is the proper way of doing this? Or am I stuck having them inside Components?

Here's how my projects build script looks like for components and core

project(":components") {
    apply plugin: "java"

    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
        compile "net.onedaybeard.artemis:artemis-odb:$artemisVersion"
    }
}
project(":core") {
    apply plugin: "java"

    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"
        compile "net.onedaybeard.artemis:artemis-odb:$artemisVersion"
        compile project(":components")
    }
}

I should also point out I'm very much new to gradle so my build scripts could be completely wrong.

junkdog commented 6 years ago

Yeah, I've had it happen too (but different use-case) - I'd recommend something like a project(":common"), if you feel it doesn't fit in :components.

DaanVanYperen commented 6 years ago

You could also consider renaming the components module to something more generic, like model. @junkdog's suggestion is what I do.