【问题标题】:Can I use Maven repository manager outside of Maven?我可以在 Maven 之外使用 Maven 存储库管理器吗?
【发布时间】:2011-03-14 08:26:28
【问题描述】:

我已经在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。

【问题讨论】:

    标签: java maven maven-3 aether


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      您查看过ivy 是否符合您的需求?

      【讨论】:

        猜你喜欢
        • 2013-09-24
        • 1970-01-01
        • 2010-10-25
        • 2010-09-09
        • 1970-01-01
        • 2014-07-12
        • 2012-10-01
        • 2015-10-12
        • 1970-01-01
        相关资源
        最近更新 更多