如何将库添加到LIBGDX项目的依赖性毕业生 [英] how to add a library to the dependencies gradle of LIBGDX project
问题描述
添加编译fileTree(dir:'lib',include:'* .jar')
到我的build.gradle
将编译文件('lib / tween-engine-api-sources.jar')
添加到build.gradle
我想添加的图书馆是 吐温引擎 。
build.gradle文件:
buildscript {
存储库{
mavenCentral()
maven {urlhttps://oss.sonatype.org/content/repositories/snapshots/}
}
依赖关系{
}
allprojects {
应用插件:eclipse
应用插件:idea
version ='1.0'
ext {
appName ='my-gdx-game'
gdxVersion ='1.5.4'
roboVMVersion ='1.0.0-SNAPSHOT'
box2DLightsVersion ='1.3 '
ashleyVersion ='1.3.1'
aiVersion ='1.5.0'
}
存储库{
mavenCentral()
maven {urlhttps://oss.sonatype.org/content/repositories/snapshots/}
maven {urlhttps://oss.sonatype.org/content/repositories/releases/}
}
}
项目(:desktop){
应用插件:java
依赖关系{
编译项目(:core)
编译com.badlogicgames.gdx:gdx-backend-lwjgl:$ gdxVersion
compilecom.badlogicgames.gdx :gdx-platform:$ gdxVersion:natives-desktop
compilecom.badlogicgames.gdx:gdx-box2d-platform:$ gdxVersion:natives-desktop
compilecom.badlogicgames.gdx:gdx -mblet-platform:$ gdxVersion:natives-desktop
compilecom.badlogicgames.gdx:gdx-freetype-platform:$ gdxVersion:natives-desktop
compilecom.badlogicgames.gdx:gdx -tools:$ gdxVersion
compilecom.badlogicgames.gdx:gdx-controllers-desktop:$ gdxVersion
compilecom.badlogicgames.gdx:gdx-controllers-platform:$ gdxVersion:natives-桌面
}
}
项目(:core){
应用插件:java
依赖关系{
compilecom.badlogicgames.gdx:gdx:$ gdxVersion
compilecom.badlogicgames.gdx:gdx-box2d:$ gdxVersion
compilecom.badlogicgames.gdx:gdx-bullet:$ gdxVersion
compilecom.badlogicgames.gdx:gdx-freetype:$ gdxVersion
compilecom.badlogicgames.gdx :gdx-controllers:$ gdxVersion
compilecom.badlogicgames.gdx:gdx-ai:$ aiVersion
compilecom.badlogicgames.ashley:ashley:$ ashleyVersion
compile com.badlogicgames.box2dlights:box2dlights:$ box2DLightsVersion
compile fileTree(dir:'lib',include:'* .jar')
}
}
tasks.eclipse.doLast {
delete.project
}
在wiki文章依赖管理与Gradle ,您可以找到所需的所有信息。甚至还有一个关于Tween引擎的部分。
您的方法应该可以工作,但是您需要通过更新Eclipse右键点击您的项目 - > Gradle - >刷新依赖关系
。
对于我来说,尽管在本地存储库中安装依赖关系,然后从中引用它,而不是引用lib文件夹。 here 中已有描述。 p>
All is in the question , I've tried all the answers I found in SO and others sites but with no luck , this is what I've tried so far :
adding compile fileTree(dir: 'lib', include: '*.jar')
to my build.gradle
adding compile files('lib/tween-engine-api-sources.jar')
to build.gradle
the library I want to add is Tween engine .
build.gradle file :
buildscript {
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = 'my-gdx-game'
gdxVersion = '1.5.4'
roboVMVersion = '1.0.0-SNAPSHOT'
box2DLightsVersion = '1.3'
ashleyVersion = '1.3.1'
aiVersion = '1.5.0'
}
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"
compile "com.badlogicgames.ashley:ashley:$ashleyVersion"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
compile fileTree(dir: 'lib', include: '*.jar')
}
}
tasks.eclipse.doLast {
delete ".project"
}
In the wiki article Dependency management with Gradle, you can find all the information you need. There's even an extra part about the Tween Engine.
Your approach should work, however, you need to update Eclipse via a Right-Click on your projects -> Gradle -> Refresh Dependencies
.
For me it worked better though to install the dependencies in my local repository and then reference it from there, instead of referencing the lib folder. This is described here.
这篇关于如何将库添加到LIBGDX项目的依赖性毕业生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!