使用本地平面文件存储库而不是远程Maven存储库 [英] Use local flat file repository instead of remote maven repository

查看:123
本文介绍了使用本地平面文件存储库而不是远程Maven存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有Maven的经验,所以请问这个问题很愚蠢...

I have no experience with maven, so excuse me if this question is silly...

从另一个问题( Grails如何处理插件依赖项),我已经了解到,我可以通过Maven存储库避免发生混乱.但是我现在有以下要求...

From another question (How does Grails handle plugin dependencies), I've learned that I can avoid the jar-hell in grails through maven repositories. But I now have the requirements that...

  • 不允许我使用远程Maven存储库
  • 我想将所需的jar捆绑到我的插件中(但优先级较低)
  • 我想避免安装本地Maven存储库的努力

我已经使用了本地文件夹引用来解决插件问题.效果很好.

I already worked with a reference to a local folder for plugin resolution. This works great.

但是我必须如何构造本地文件夹才能使用此选项:

But how do I have to structure a local folder in order to use this option:

repositories {
  flatDir name:'myRepo', dirs:'/path/to/repo'
}

我的意思是,我可以将jar文件拖放到该文件夹​​中,但是然后如何引用这些jar文件呢?它们是否具有像artifact_version.jar这样的命名模式?还是我必须为此本地存储库创建XML配置?

I mean, I could just drop the jar files to this folder, but how do I then reference those jar files? Do they have a naming schema like artifact_version.jar? Or do I have to create an XML configuration for this local repository?

还是使用本地Maven存储库的努力很小,而Maven甚至已经通过grails在我的机器上了?

Or is the effort to use a local maven repo small and maven is even already on my machine through grails?

推荐答案

事实是Maven已经带有一个本地存储库(在Linux机器上是〜/.m2).如果您无权访问外部存储库,则只需使用此命令将jar安装在本地存储库中

The fact is Maven comes already with a local repository (~/.m2 on linux boxes). If you don't have access to an external repo, you just have to install your jars in the local repo, with this command

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

是'jar'(不带引号),并且可以确定group-id和artifact-id是否为第三方库(请在 mvnrepository.com (如果您不知道特定库的文件),或者您在其中放置了组ID和工件ID

is 'jar' (without quotes) and group-id and artifact-id are either determined if it's 3rd-party library (go make a search on mvnrepository.com if you don't know them for a particular library) or you put there your group and artifact ids

实际上,存储库下的命名方案是jexample.com的库示例版本1.2的com/jexample/example/1.2/example-1.2.jar(groupId:com.jexample,artifactId:示例,版本:1.0)

EDIT : In fact, the naming scheme under the repository is for the library example version 1.2 from jexample.com is usually com/jexample/example/1.2/example-1.2.jar (groupId : com.jexample, artifactId : example, version : 1.0)

这篇关于使用本地平面文件存储库而不是远程Maven存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆