且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

摇篮绝对/相对路径

更新时间:2023-02-09 23:10:02

尝试一下,它将包括本地存储库中的所有JAR,因此您不必每次都指定它:

Try this, it would include all JARs in the local repository, so you wouldn't have to specify it every time:

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

此外,您应该知道在通过引用文件时

Also, you should know that when referencing a file via

files("relative/path/to/a.jar")

路径是相对于此片段所在的构建脚本进行评估的.因此,当您的 build.gradle 文件位于/a/project/build.gradle 中时,jar应该位于/a/project/relative/path/to/a.jar 中.在多项目gradle构建中,您可以将jar放在相对于根-项目的文件夹中,并通过

path is evaluated relative to the buildscript this snippet is in. So when your build.gradle file is located in /a/project/build.gradle, then the jar should be in /a/project/relative/path/to/a.jar. In a multiproject gradle build you can put the the jar in a folder relative to the root - project and reference it in all subprojects via

rootProject.files("relative/to/root/a.jar")

因此请考虑到这一点,然后重新检查gradle设置是否正确.

So take this to account and re-check if your gradle settings are correct.