[英]Using a maven artifact into a non-maven project
I have never worked with Maven and I just came across it while trying to use an external API for my Non-Maven project. 我从未与Maven合作,而我在尝试使用外部API进行非Maven项目时遇到过它。 The documentation for the External API says:
外部API的文档说:
The JAR is not currently available on any central Maven repositories, but you can easily
clone this repository and install it to your local Maven just by typing:
mvn compile install
Since my project is not a Maven project, OI am wondering how can I still use this external API which does not have a JAR file that I could otherwise import into my project? 由于我的项目不是Maven项目,OI想知道我怎么还能使用这个没有JAR文件的外部API,否则我可以导入到我的项目中?
I know that I can convert my project into a Maven project, but is that the only/best option? 我知道我可以将我的项目转换为Maven项目,但这是唯一/最佳选择吗? Thanks!
谢谢!
mvn package
mvn package
target/
directory of the project and use it in your non maven project. target/
目录中找到JAR,并在非maven项目中使用它。 Converting to Maven (or Gradle) if you're not using any build-management system is almost certainly the preferable option; 如果你没有使用任何构建管理系统,转换为Maven(或Gradle)几乎肯定是更好的选择; learning Maven will take a little while, but it prevents a multitude of headaches with dependency and classpath management, predictable build integration, and so on.
学习Maven需要一段时间,但它可以防止因依赖和类路径管理,可预测的构建集成等问题而产生的大量麻烦。
That said, there's nothing magic about jars that have been built with Maven; 也就是说,用Maven建造的罐子并没有什么神奇之处; it's simply a tool that automates calling all of the tools you'd use anyway like the compiler and JUnit.
它只是一个工具,可以自动调用您使用的所有工具,如编译器和JUnit。 It produces a regular jar that you use just like you'd use any other jar by adding it to your classpath.
它生成一个普通的jar,就像你使用任何其他jar一样,将它添加到类路径中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.