简体   繁体   English

将项目从 bitbucket 导入本地 maven 存储库

[英]Import project from bitbucket to local maven repository

I have a maven project in bitbucket account.我在 bitbucket 帐户中有一个 Maven 项目。 I need to add that the project in my local maven repository so that I can refer that project as a maven dependency in my main project's pom.xml.我需要在我的本地 maven 存储库中添加该项目,以便我可以将该项目作为主项目 pom.xml 中的 maven 依赖项引用。

That is, perform below steps也就是说,执行以下步骤

1) Clone the project 2) run maven build install This will add to local maven repository 1) 克隆项目 2) 运行maven build install这将添加到本地 maven 存储库

Please let me know if there is a way to achieve the same (in similar ways to connecting to maven public repository) ?请让我知道是否有办法实现相同的目标(以类似的方式连接到 Maven 公共存储库)?

You can achieve this by defining repositories in pom file of the project where you want to use project 1 as a dependency.您可以通过在要使用项目 1 作为依赖项的项目的 pom 文件中定义存储库来实现此目的。

For eg.例如。

Git clone path of Project 1: https://github.com/yogi21jan/project1项目1的Git clone路径: https : //github.com/yogi21jan/project1

Add below code in child project:在子项目中添加以下代码:

<repositories>
    <repository>
        <id>YOUR-PROJECT-NAME-mvn-repo</id>
        <url>https://raw.github.com/YOUR-USERNAME/YOUR-PROJECT-NAME/mvn-repo/</url>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
        </snapshots>
    </repository>
</repositories>

And finally Add this project as a dependency:最后将此项目添加为依赖项:

<dependency>
     <groupId>group id of project 1</groupId>
     <artifactId>artifcat id of project 1</artifactId>
     <version>required version</version>
</dependency>

Look into jitpack.io .查看jitpack.io It can create a Maven repository for a GitHub project and also other hosters like BitBucket, GitLab, Azure, Gitee .它可以为 GitHub 项目以及其他托管者(如BitBucket、GitLab、Azure、Gitee)创建 Maven 存储库。

I have choosen a random Maven based project, here fastconverter .我选择了一个随机的基于 Maven 的项目,这里是fastconverter It not GitHub is used, the full URL has to be provided.它不使用 GitHub,必须提供完整的 URL。 The created jar is published then here .然后 在此处发布创建的 jar。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM