Search code examples
javagradlemulti-project

Gradle can't find local dependency project


I have this Gradle project:

G:\!Modding\jtta-primitive-lite

And it should have this dependency (also a Gradle project):

G:\!Modding\jtta-core

jtta-primitive-lite should depend on jtta-core project (without including)

I made like this for jtta-primitive-lite :

    repositories {      
        flatDir {
            dirs '../'
        }
    }
    
    
    dependencies {
        
        //modApi "jtta-core:jtta-core:"
        modApi project("jtta-core").projectDir = new File("../jtta-core")
        // Also tried new File("../")
        //api project(":jtta-core").projectDir = new File("../")
    }

But its searches only inside root directory:

    FAILURE: Build failed with an exception.
    
    * Where:
    Build file 'G:\!Modding\jtta-primitive-lite\build.gradle' line: 34
    
    * What went wrong:
    A problem occurred evaluating root project 'jtta-primitive-lite'.
    > Project with path 'jtta-core' could not be found in root project 'jtta-primitive-lite'.

I don't know why. If you need additional info, I can get it.

Also i tried to includeBuild("../jtta-core") but it also doesn't work.


Solution

  • I've tried to mock up an example here. Note that it uses relative paths, not absolute paths, but that shouldn't be a big deal. The layout is:

    settings.gradle
    ./G_modding/jtta-core/build.gradle
    ./G_modding/jtta-primitive-lite/build.gradle
    

    The settings.gradle file:

    include ':G_modding:jtta-primitive-lite', ':G_modding:jtta-core'
    

    and this build.gradle in G_modding/jtta-primitive-lite:

    apply plugin: 'java'
    
    dependencies {
        implementation project(":G_modding:jtta-core")
    }
    

    Hopefully that is enough to illustrate the issue? (I don't know your specific goal, so I don't know the precise problem).