在gradle中添加外部jar [英] Add external jar in gradle
问题描述
如何在gradle中添加外部库? build.gradle
包含: $ b
How can I add an external library in gradle? My build.gradle
contains:
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.1-SNAPSHOT'
}
}
我的根文件夹是 / FORGE /
。我想添加 /FORGE/build/libs/spigot.jar
作为依赖项。
My root folder is /FORGE/
. I want to add /FORGE/build/libs/spigot.jar
as a dependency.
推荐答案
正如文档所述:
dependencies {
compile files('libs/spigot.jar')
}
以上操作将 libs / spigot.jar
文件添加到编译
配置。您可以将其添加到任何其他配置(运行时等)。
The above will add the libs/spigot.jar
file to the compile
configuration. You can of course add it to any other configuration (runtime, etc.).
请注意,使用 build / libs
是一个非常糟糕的主意,因为只要执行 gradle clean
,整个构建目录就会被删除。构建目录用于存储构建生成的构件。
Note that using build/libs
is an extremely bad idea, since the whole build directory will be deleted as soon as you execute gradle clean
. The build directory is used to store artifacts generated by the build.
这篇关于在gradle中添加外部jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!