Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用Buildr导入第三方jar?_Java_Jar_Buildr - Fatal编程技术网

Java 如何使用Buildr导入第三方jar?

Java 如何使用Buildr导入第三方jar?,java,jar,buildr,Java,Jar,Buildr,我正在开发我的第一个Java应用程序。一个同事开始了,但没有时间完成。她是一位经验丰富的Java程序员,但我不是。但是,这个应用程序很小,看起来像是我可以作为第一个Java应用程序来承担的项目(我确实使用过Clojure等JVM语言,因此我对JVM世界有一些背景知识) 我添加了将数据输出为JSON的功能。我想使用Google的Gson类: com.google.code.gson 我的同事没有外部依赖项,所以她只是从命令行编译代码。现在我正在添加第三方依赖项,我想我应该切换到构建工具。我选择B

我正在开发我的第一个Java应用程序。一个同事开始了,但没有时间完成。她是一位经验丰富的Java程序员,但我不是。但是,这个应用程序很小,看起来像是我可以作为第一个Java应用程序来承担的项目(我确实使用过Clojure等JVM语言,因此我对JVM世界有一些背景知识)

我添加了将数据输出为JSON的功能。我想使用Google的Gson类:

com.google.code.gson

我的同事没有外部依赖项,所以她只是从命令行编译代码。现在我正在添加第三方依赖项,我想我应该切换到构建工具。我选择Buildr:

我决定下载构成com.google.code.gson的3个Jar文件:

gson-2.2.4-javadoc.jar

gson-2.2.4-sources.jar

gson-2.2.4.jar

我不知道如何将它们包括在我的Buildr项目中

我使用“buildr”命令来建立buildr喜欢的默认目录。但是对于第三方JAR没有明显的文件夹

我尝试了构建文件的许多变体。我的最新迭代是:

# Version number for this release
VERSION_NUMBER = "1.0.0"
# Group identifier for your projects
GROUP = "buildr_fdg"
COPYRIGHT = "2014, Open"

GOOGLEGSON = ['gson-2.2.4-javadoc.jar', 'gson-2.2.4-sources.jar', 'gson-2.2.4.jar']

# Specify Maven 2.0 remote repositories here, like this:
repositories.remote << "http://repo1.maven.org/maven2"

desc "The Buildr_fdg project -- creating JSON object full of fake data since we don't have enough real data ."
define "buildr_fdg" do

  project.version = VERSION_NUMBER
  project.group = GROUP
  manifest["Implementation-Vendor"] = COPYRIGHT
  compile.with GOOGLEGSON
  resources
  test.compile.with # Add classpath dependencies
  package(:jar)
end

我如何告诉Buildr我的第三方JAR

向Buildr项目添加依赖项的最简单方法是使用库的“maven”坐标。所以我相信你要做的就是用类似的东西取代谷歌

GOOGLEGSON = ['com.google.code.gson:gson:jar:2.2.4']

这与对Maven central的引用相结合,意味着Buildr将下载依赖项并将其添加到您的类路径中。

不相关,但显然构建只需要
gson-2.2.4.jar
GOOGLEGSON = ['com.google.code.gson:gson:jar:2.2.4']