2

我正在将 lein 用于 Clojure 项目,我试图在clojars中使用libgdx包。从该软件包安装的 jar 文件包含一个 lib 文件夹,其中包含用于 gdx 的多个 jar。

$ jar tf org/clojars/amu/libgdx/0.92/libgdx-0.9.2.jar

lib/ 
lib/gdx-openal.jar 
lib/gdx-backend-jogl-natives.jar
lib/gdx-backend-android.jar 
lib/gdx-backend-lwjgl.jar
lib/gdx-backend-lwjgl-natives.jar 
lib/gdx.jar 
lib/gdx-natives.jar
lib/gdx-backend-jogl.jar

我还在我的 project.clj 中添加了以下依赖项:[org.clojars.amu/libgdx "0.9.2"]

我不确定的是如何使用 :use 和 :require 关键字访问 libgdx jar 中的每个 jar?

(ns game.core
  (:import (libgdx.gdx Game)) <- does not work

我在 github 上放了一个 lein 项目的公共存储库:Project Link

我将更新该项目,以便在我解决它后作为其他人的示例。

4

2 回答 2

0

An uberjar won't work because the file in clojars is not a normal jar file containing classes but is a really a file that you are meant to download, extract the necessary jars and place them on the classpath or lib for your project.

While you could write a fancy classloader to do that, that goes contrary to the instructions from the libgdx site which include the instruction:

 Download the nightly zip and place gdx.jar and gdx-sources.jar in the libs folder.

The more appropriate thing to do is to extract the jars from that download jar and add them to clojars and refer to them individually. That or just add them to your local classpath or repo.

于 2012-09-21T01:53:03.983 回答
0

只是一个想法,但如果他们像那样打包它,那么也许他们已经提供了可以做正确事情的花哨的类加载器?

另外,您的导入对我来说看起来不正确。向量(不是列表)应该是正确的吗?

例如

(ns warscore.swing
  (:import
   [java.awt Color ]
   [java.awt.event MouseEvent]
   [javax.swing DefaultCellEditor JCheckBox JLabel JTable JTextField ]
   [javax.swing.table DefaultTableCellRenderer ]))
于 2012-09-21T04:19:34.033 回答