开发者

Can I use Maven repository manager outside of Maven?

开发者 https://www.devze.com 2023-02-16 12:01 出处:网络
I already asked in Maven User List, let me duplicate here. I\'m trying to create an application that will download and use Maven

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

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

I'm using 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. 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
);


Have you taken a look at ivy to see if it fits your needs?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号