【问题标题】:Gradle can't find local dependency projectGradle 找不到本地依赖项目
【发布时间】:2021-02-02 21:52:42
【问题描述】:

我有这个 Gradle 项目:

G:\!Modding\jtta-primitive-lite

而且它应该有这个依赖(也是一个 Gradle 项目):

G:\!Modding\jtta-core

jtta-primitive-lite 应该依赖于jtta-core 项目(不包括)

我为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("../")
    }

但它只在根目录内搜索:

    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'.

我不知道为什么。如果您需要更多信息,我可以得到。

我也尝试includeBuild("../jtta-core"),但它也不起作用。

【问题讨论】:

标签: java gradle multi-project


【解决方案1】:

我试图模拟一个示例here。请注意,它使用相对路径,而不是绝对路径,但这应该没什么大不了的。布局是:

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

settings.gradle 文件:

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

这个build.gradleG_modding/jtta-primitive-lite:

apply plugin: 'java'

dependencies {
    implementation project(":G_modding:jtta-core")
}

希望这足以说明问题? (我不知道你的具体目标,所以我不知道确切的问题)。

【讨论】:

  • 是的。谢谢你帮助我!我使用的 gradle 插件存在一些非常具体的问题,但我认为我可以处理它。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-02-10
  • 1970-01-01
  • 2015-03-24
  • 2021-10-08
  • 2015-04-23
  • 1970-01-01
相关资源
最近更新 更多