简体   繁体   English

如何使用gradle在Windows上构建jar

[英]How to build jar on windows with gradle

I'm fairly new to using external libraries with java, I'm currently trying to connect an Arduino to my windows 10 computer, and I found https://github.com/NeuronRobotics/nrjavaserial , which seems to do what I need done. 我对使用外部库和Java相当陌生,我目前正在尝试将Arduino连接到Windows 10计算机,并且发现https://github.com/NeuronRobotics/nrjavaserial ,这似乎可以满足我的需要。 The problem is I have never taken java libraries from GitHub before, so I don't know how to extract a jar file from the zip download. 问题是我以前从未从GitHub上获取过Java库,所以我不知道如何从zip下载中提取jar文件。 The readme says to use Gradle, but I don't know what that is or how to use it. 自述文件说要使用Gradle,但我不知道这是什么或如何使用。 Could someone please help me with this? 有人可以帮我吗?

What is Gradle? 什么是Gradle?

Gradle is an open source build automation system that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific language instead of the XML form used by Apache - Wikipedia Gradle是一个开源的构建自动化系统,它基于Apache Ant和Apache Maven的概念,并引入了基于Groovy的领域特定语言,而不是Apache使用的XML形式-Wikipedia

How to Use Gradle? 如何使用Gradle?

You need to install gradle command line tool from here . 您需要从此处安装gradle命令行工具。

Once installed gradle, follow the README of the git repository. 安装gradle后,请遵循git存储库的README

You also read here about gardle command line usage 您还可以在此处阅读有关gardle命令行用法的信息

Actuall you don't need Gradle to use that software. 实际上,您不需要Gradle即可使用该软件。
Gradle is a build system that makes building software from source to end-result much easier and more robust. Gradle是一个构建系统,它使从源到最终结果的构建软件变得更加容易和强大。
So if you want to build their software from source, you use Gradle. 因此,如果您想从源代码构建他们的软件,请使用Gradle。

If you just want to use what they provide, you can also simply consume their built result which you can eg download from http://search.maven.org/remotecontent?filepath=com/neuronrobotics/nrjavaserial/3.13.0/nrjavaserial-3.13.0.jar , but be aware, that they in turn also have dependencies you need to include in your software, otherwise the lib will not work. 如果您只想使用它们提供的功能,也可以简单地使用它们的构建结果,例如,可以从http://search.maven.org/remotecontent?filepath=com/neuronrobotics/nrjavaserial/3.13.0/nrjavaserial-下载3.13.0.jar ,但要注意,它们又具有您需要包含在软件中的依赖项,否则lib将无法工作。 Those are called transitive dependencies, dependencies your dependencies have. 这些被称为传递依赖,即您的依赖具有的依赖。

If you use a proper build system like Gradle, Ant+Ivy or Maven (order from best to worst from my personal point of view) then this tool amongst other things takes care about pulling in the transitive dependencies, so you just say to the tool "my project needs com.neuronrobotics:nrjavaserial:3.13.0 " and it cares automatically to also include its transitive dependencies. 如果您使用诸如Gradle,Ant + Ivy或Maven之类的适当构建系统(从我个人的观点出发,从最佳到最差的顺序),那么该工具尤其会考虑引入传递依赖项,因此您只需要对工具说“我的项目需要com.neuronrobotics:nrjavaserial:3.13.0 ”,它会自动关心是否也包括其传递依赖项。

I highly recommend using Gradle for each and every tiny software, even if no external dependencies are involved. 我强烈建议为每个微型软件都使用Gradle,即使不涉及外部依赖项也是如此。 If you want to learn Gradle, start with reading its Userguide at https://docs.gradle.org/current/userguide/userguide.html . 如果要学习Gradle,请先阅读https://docs.gradle.org/current/userguide/userguide.html上的《用户指南》

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM