2013-03-19 62 views
4

我有github.com Maven项目:GitHub上依赖

<project ...> 
    ... 
    <groupId>com.example</groupId> 
    <artifactId>my-github-library</artifactId> 
    <packaging>jar</packaging> 
    <version>1.0.0</version> 
    ... 
</project> 

现在,我想我的,github上,库添加作为一个依赖于另一个我的本地应用程序项目:

<project ...> 
    ... 
    <groupId>com.example</groupId> 
    <artifactId>my-local-application</artifactId> 
    <packaging>jar</packaging> 
    <version>1.0.0</version> 
    ... 
    <dependencies> 
    ... 
    <dependency> 
     <groupId>com.example</groupId> 
     <artifactId>my-github-library</artifactId> 
     <version>1.0.0</version> 
    </dependency> 
    ... 
    </dependencies> 
    ... 
</project> 

这当然不起作用,因为GitHub不是Maven存储库。

如何添加一个额外的Maven仓库到项目pom文件?

回答

1

您可以从Sonatype OSS team请求您的Github项目工件的开源托管。然后,您将不得不设置您的项目,以便能够部署到其存储库(在pom.xml<servers/>中使用<distributionManagement/>,settings.xml)。部署了您所依赖的工件后,您可以通过<dependency/>使其他项目依赖于它,并在<repositories/>部分中指定<repository>指向Sonatype的库。