下载maven项目依赖,稍后离线构建 [英] Download maven project dependencies to build offline later

查看:44
本文介绍了下载maven项目依赖,稍后离线构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 maven 一段时间了,并且使用了开箱即用的设置,所以我理解它是什么,但我是 maven 设置的新手.

I've used maven for a while in common way with settings out of the box, so I understand what it is but I'm newbie in maven settings.

我需要组织这样的工作流程:

I need to organize such workflow:

  1. 开发人员编写 Java 代码,使用一些来自互联网的依赖项.
  2. 开发人员提交了他的工作.
  3. TeamCity 可以自动构建他的作品.没有任何手工工作,也没有互联网.

我知道怎么做:

  1. 开发人员使用 maven.公共"目录充当某些 Java 项目的存储库.
  2. 工作完成后,开发者将他的项目和公共目录提交到 svn 中.
  3. TeamCity 从 svn 更新项目和公共目录并运行mvn package".任何需要的东西都来自公共目录.无需担心互联网连接和启动关系,或其他回购服务.

我的问题是:如何使用文件系统上的简单目录作为某些项目的代理存储库?请告诉我如何实现这个想法或给我另一个想法来实现这样的工作流程.

My question is: How to use simple directory on filesystem as proxy repository for certain projects? Tell me please how to realize this idea or give me another idea to realize such workflow.

我可以只提交本地存储库,但有一些限制:

I can just commit local repository, but there are some limitations:

  1. 本地存储库 zip 工件.如果我对它做一点改动 - 整个缓存文件必须上传到/从 svn 下载.这需要很长时间.
  2. 所有项目的本地存储库工件.我只希望某些项目使用此存储库,因为开发人员不想检查更改并过滤未使用的依赖项.

我测试了本地目录以部署项目,简单的通过在 repo url 中写入file://testRespoDir",但我无法理解如何使此目录代理项目的所有远程工件(项目不得使用本地 repo 和仅使用公共目录.

I test local directory to deploy projects, simple by writing "file://testRespoDir" in repo url, but I can't understand how to make this directory proxy all remote artefacts for project(project must not use local repo and use only common directory.

推荐答案

我找到了简单而完美的解决方案:POM 包括 2 个存储库:

I found simple and perfect solution: POM include 2 repositories:

<repositories>
    <repository>
        <id>commonDep</id>
        <name>common dependency</name>
        <url>file://../common/repository</url>
    </repository>
    <!-- it used when collect dependencies before commit. If developer already download dependency, get it from local repo, save traffik and time -->
    <repository>
        <id>localPlugins</id>
        <name>local plugins</name>
        <url>file://${user.home}/.m2/repository</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>commonDep</id>
        <name>common dependency</name>
        <url>file://../common/repository</url>
    </pluginRepository>
    <!-- it used when collect dependencies before commit. If developer already download dependency, get it from local repo, save traffik and time -->       
    <pluginRepository>
        <id>localPlugins</id>
        <name>local plugins</name>
        <url>file://${user.home}/.m2/repository</url>
    </pluginRepository>
</pluginRepositories>

当开发人员打开项目时,他会按照这样的顺序使用本地、公共和中央存储库.这节省了他的流量.当他完成工作时,他调用脚本:

when developer opens project, he use local, common and central repositories in such order. It saves his traffic. When he finished work, he call script:

mvn dependency:go-offline -Dmaven.repo.local=../common/repository

项目的所有当前依赖项从他的默认本地存储库复制到公共存储库.然后开发者提交common.

all current dependencies of project copyed from his default local repository to common repository. Then developer commit common.

当我们在 teamcity 上运行 build 时,我们检查项目并通用并运行它.没有互联网连接,但所有依赖项都存在于公共存储库中.

When we run build on teamcity, we checkout project and common and run it. There is no internet connection, but all dependencies exist in common repository.

这篇关于下载maven项目依赖,稍后离线构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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