Gradle 无法找到本地依赖项目。

huangapple go评论107阅读模式
英文:

Gradle can't find local dependency project

问题

我有这个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')
        // 也尝试过 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"),但它也不起作用。

英文:

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.

答案1

得分: 0

我已经尝试在这里创建了一个示例模型。请注意,它使用的是相对路径,而不是绝对路径,但这应该不是一个大问题。布局如下:

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'

以及位于 G_modding/jtta-primitive-lite 中的 build.gradle 文件:

apply plugin: 'java'

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

希望这已足够说明问题?(我不知道您的具体目标,因此不了解确切的问题)。

英文:

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

huangapple
  • 本文由 发表于 2020年10月20日 13:18:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/64438893.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定