Maven POM文件,用于安装多个第三方商业库 [英] Maven POM file for installing multiple 3rd party commercial libraries

查看:62
本文介绍了Maven POM文件,用于安装多个第三方商业库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多项目,这些项目依赖于一组商业第三方图书馆.我们目前没有公司资料库,因此我必须在自己的本地存储库中安装这些库.

I have a bunch of projects which are dependant on a set of commercial 3rd party libraries. We currently don't have a company repository so I have to install the libraries in my own local repo.

为每个文件运行mvn install:installFile -Dpackaging=jar -Dfile=<file> -DgroupId=<groupId> -DartifactId=<artifactId> -Dversion=<version>非常繁琐.可以创建一个bat文件,但是有没有办法使用maven做到这一点?

Running mvn install:installFile -Dpackaging=jar -Dfile=<file> -DgroupId=<groupId> -DartifactId=<artifactId> -Dversion=<version> for each file is rather tedious. Could create a bat file, but is there a way to do this using maven?

我正在考虑一个针对所有jar和一个pom文件的项目,其中包含所有组ID,工件ID,版本和文件名,然后可以在该项目中仅运行mvn install,或者遵循类似的方式.

I'm thinking a project for all the jars and a single pom file with all the group ids, artifact ids, versions and filenames and then the possibility of just running mvn install in that project, or something along those lines.

像这样可能吗?

注意::我使用的是Maven 3,但是与Maven 2兼容的解决方案也很好.

Note: I'm using Maven 3, but a Maven 2 compatible solution would be nice too.

推荐答案

最近发现了一个新的解决方案.基本上,您可以在项目内创建一个本地存储库,可以将其与其余的源代码一起签入.在此处发布博客: http://www.geekality.net/?p=2376 .

Recently discovered a new solution to this. Basically you can create a local repository within the project which can be checked in with the rest of the source code. Blogged about it here: http://www.geekality.net/?p=2376.

要点是将依赖项部署到项目中的文件夹中.

The gist is to deploy dependencies to a folder in your project.

mvn deploy:deploy-file
    -Durl=file:///dev/project/repo/
    -Dfile=somelib-1.0.jar
    -DgroupId=com.example
    -DartifactId=somelib
    -Dpackaging=jar
    -Dversion=1.0

然后简单地让Maven知道它,并通过pom.xml正常使用依赖项声明.

And then simply let Maven know about it and use dependency declarations as normal through your pom.xml.

<repositories>
    <repository>
        <id>project.local</id>
        <name>project</name>
        <url>file:${project.basedir}/repo</url>
    </repository>
</repositories>

<dependency>
    <groupId>com.example</groupId>
    <artifactId>somelib</artifactId>
    <version>1.0</version>
</dependency>

并非十分Maven'y,但是它可以正常工作,以后将依赖项移至公司存储库应该很简单.

Not extremely Maven'y, but it works and moving the dependencies to a company repository later should be quite simple.

这篇关于Maven POM文件,用于安装多个第三方商业库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆