简体   繁体   English

我可以在Maven之外使用Maven存储库管理器吗?

[英]Can I use Maven repository manager outside of Maven?

I already asked in Maven User List , let me duplicate here. 我已经在Maven用户列表中询问了,让我在这里复制一下。

I'm trying to create an application that will download and use Maven artifacts outside of Maven. 我正在尝试创建一个将在Maven之外下载和使用Maven工件的应用程序。 I think that in this case the smartest way would be to use Maven already existing classes. 我认为在这种情况下,最聪明的方法是使用Maven已经存在的类。 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"); 

I'm using Maven 3. 我正在使用Maven 3。

Aether does exactly what I need. 以太完全符合我的需要。

edit: A few weeks ago I created an open source tool that simplifies the interaction with Aether: jcabi-aether . 编辑:几个星期前,我创建了一个开源工具,简化了与Aether: jcabi-aether的交互。 Now it is as simple as (in maven plugin): 现在它就像(在maven插件中)一样简单:

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
);

您是否看过常春藤 ,看它是否符合您的需求?

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

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