2011-03-14 88 views
0

我已经在Maven User List问过了,让我在这里复制。我可以在Maven之外使用Maven仓库管理器吗?

我正在尝试创建一个应用程序,它将下载并使用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

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

你已经采取了看看ivy,看它是否符合您的需求?