gpt4 book ai didi

java - 如何将库添加到 LIBGDX 项目的依赖项 gradle

转载 作者:行者123 更新时间:2023-11-30 08:12:48 26 4
gpt4 key购买 nike

一切都在问题中,我已经尝试了我在 SO 和其他网站上找到的所有答案,但没有运气,这就是我到目前为止所尝试的:

添加 compile fileTree(dir: 'lib', include: '*.jar') 到我的 build.gradle

添加编译文件('lib/tween-engine-api-sources.jar')到build.gradle

我要添加的库是 Tween engine

build.gradle 文件:

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"
}

最佳答案

在维基文章中Dependency management with Gradle ,您可以找到所需的所有信息。甚至还有关于 Tween 引擎的额外部分。

您的方法应该可行,但是,您需要通过右键单击您的项目 -> Gradle -> Refresh Dependencies 来更新 Eclipse。

对我来说,在我的本地存储库中安装依赖项然后从那里引用它,而不是引用 lib 文件夹,效果更好。这是描述here .

关于java - 如何将库添加到 LIBGDX 项目的依赖项 gradle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30253612/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com