sihrc
sihrc

Reputation: 2848

Adding local directory as gradle dependency

I've seen gradle compile remote repos and local jars, but not directories.

Is this possible? If so, what's the syntax for compiling a directory?

I have jbox2d as a directory (I needed to make some changes to source files), but I'm trying to figure how to add it in gradle.

I can add it manually in my IDE, but I'd much rather have it done by gradle.

Thank you, Tar for your suggestion. I've modified my build.gradle to contain:

dependencies { compile 'junit:junit:4.+' compile 'com.esotericsoftware:kryonet:2.+' compile 'org.slick2d:slick2d-core:1.0.+' compile project ':JBox2D' compile 'org.lwjgl.lwjgl:lwjgl:2.+' compile 'org.lwjgl.lwjgl:lwjgl_util:2.9.+' }

Gradle complains that it can't find JBox2D:

Could not find property ':JBox2D' on DefaultProjectDependency{dependencyProject='root project 'pong-the-moba'', configuration='default'}.

I made JBox2D a module and it's living right under root:

project/ jbox2d/ src/ build.gradle

Upvotes: 0

Views: 2241

Answers (1)

tar
tar

Reputation: 1568

How about adding your modified jbox2d as a module then using Gradle to build it by referring to the module?

compile project(':CustomJbox2d')

For instance, my Android project builds with Gradle, and I have a facebook library that is built with this section of my build.gradle in teh module that depends on it.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':libraries:facebook')
}

My file structure is something like this:

project/
    libraries/
        facebook/
            build.gradle
    my_module/
        build.gradle (this is the one I took the above Gradle code from)
build.gradle
settings.gradle

Upvotes: 1

Related Questions