我可以在Maven之外使用Maven存储库管理器吗? [英] Can I use Maven repository manager outside of Maven?

查看:99
本文介绍了我可以在Maven之外使用Maven存储库管理器吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 Maven用户列表,让我在这里重复.

I already asked in Maven User List, let me duplicate here.

我正在尝试创建一个将下载并使用Maven的应用程序 Maven以外的文物.我认为在这种情况下,最明智的方法是 是使用Maven已经存在的类.谁能帮我提示 在哪里找?

I'm trying to create an application that will download and use Maven artifacts outside of Maven. I think that in this case the smartest way would be to use Maven already existing classes. Can anyone help me with a hint where to look for?

很高兴以这种方式工作:

Would be nice to make it working this way:

Repository rep = new Repository("~/.m2"); 
Artifact artifact = new Artifact("com.example", "foo", "1.0"); 
String path = rep.resolve(artifact); 
assert path.equals("~/.m2/repository/com/example/foo/1.0/foo.jar"); 

我正在使用Maven 3.

I'm using Maven 3.

推荐答案

Aether 确实正是我所需要的.

Aether does exactly what I need.

几周前,我创建了一个开放源代码工具,该工具简化了与以太的交互: jcabi-以太.现在,它很简单(在Maven插件中):

edit: A few weeks ago I created an open source tool that simplifies the interaction with Aether: jcabi-aether. Now it is as simple as (in maven plugin):

File repo = this.session.getLocalRepository().getBasedir();
Collection<Artifact> deps = new Aether(this.getProject(), repo).resolve(
  new DefaultArtifact("junit", "junit-dep", "", "jar", "4.10"),
  JavaScopes.RUNTIME
);

这篇关于我可以在Maven之外使用Maven存储库管理器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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