我mavenizing一些项目。
这些项目都依赖于许多图书馆,其中大部分是在Maven回购可用。对于其他图书馆,我想创建一个Maven构件,这样我就可以使用它作为一个依赖。问题是,我只有这些库的jar文件。
什么是从现有的jar文件文物的最好方法?
如果你不使用远程存储库(这是个人发展的一个常见的情况),只需install
使用install:install-file
的魔力在你的本地库这些文物:
mvn install:install-file
-Dfile=<path-to-file>
-DgroupId=<group-id>
-DartifactId=<artifact-id>
-Dversion=<version>
-Dpackaging=<packaging>
-DgeneratePom=true
Where: <path-to-file> the path to the file to load
<group-id> the group that the file should be registered under
<artifact-id> the artifact name for the file
<version> the version of the file
<packaging> the packaging of the file e.g. jar
但很明显,这将使您的构建非便携式(这可能不是一个虽然问题)。为了不牺牲便携性,你将不得不作出在远程存储库中的文物。在企业方面,应对,共同的办法是安装一个企业的资源库(在这种情况下,为了确实deploy
文物)。
更新:一旦你的神器被安装在你的本地库,只需在您的POM像任何其他的依赖,e.g声明<dependency>
元素:
<dependency>
<groupId>aGroupId</groupId>
<artifactId>aArtifactId</artifactId>
<version>1.0.12a</version>
<packaging>jar</packaging>
</dependency>
您可以使用Maven Deploy Plugin上传您的JAR文件(也可以选择POM文件,虽然在默认情况下系统会为您创建)到你的Maven仓库。
作为danben said,你必须部署这些罐子到资源库。但是,我似乎从你的问题要明白,你没有,除了全球行家一个资源库。
你可以使用Nexus,或Artifactory。
您也可以不在存储库是在项目罐子创建“系统”的依赖。例如,
<dependency>
<groupId>com.example</groupId>
<artifactId>MySpecialLib</artifactId>
<version>1.2</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/MySpecialLib-1.2.jar</systemPath>
</dependency>
我知道你的问题。 Mavenizing罐子有时是疼痛(特别是如果它们具有进一步传递依赖,这也需要在pom.xml中被定义)。
检查过这些库是否真的不会存在如行家DEPS?看看常规的做法:
有时候,我喜欢用的Nexus罐子上传对话框,让创建的pom.xml文件。