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

时间:2011-03-14 08:26:29

标签: java maven maven-3 aether

我已经在Maven User List询问了,让我复制一下。

我正在尝试创建一个可以下载和使用Maven的应用程序 Maven以外的文物。我认为在这种情况下最聪明的方式 是使用Maven已经存在的类。任何人都可以帮我提示一下 在哪里寻找?

以这种方式工作会很高兴:

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。

2 个答案:

答案 0 :(得分:2)

Aether完全符合我的需要。

编辑:几周前,我创建了一个开源工具,简化了与Aether的交互:jcabi-aether。现在它就像(在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
);

答案 1 :(得分:0)

您是否看过ivy以确定它是否符合您的需求?