如何使用uploadArchives推送到本地和远程的Maven存储库? [英] How to push to local and remote Maven repository using uploadArchives?

查看:3201
本文介绍了如何使用uploadArchives推送到本地和远程的Maven存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为 gradle publishToMavenLocal rel =nofollow>maven-publish插件,它将一个构建安装到本地的〜/ .m2 文件夹中。因为我还在使用 gradle uploadArchives 我想知道是否有类似的东西可以在本地和远程部署之间进行选择?

I came across gradle publishToMavenLocal as part of the "maven-publish" plugin which installs a build into the local ~/.m2 folder. Since I am still using gradle uploadArchives I wonder if there is something similar which would allow to choose between local and remote deployment?

配置本地Maven存储库的手动方式如下:

A manual way to configure the local Maven repository is the following:

uploadArchives {
    repositories {
        mavenDeployer {
            repository url: 'file://' + new File(
                System.getProperty('user.home'), '.m2/repository').absolutePath
        }
    }
}

task install(dependsOn: uploadArchives)

我还提出了这样一个想法:每当将构建上传到远程存储库时,它也安装到本地存储库。但是我不知道是否要自动化这个 - 欢迎评论。

I also came up with the idea that whenever the build is uploaded to the remote repository it is installed to the local repository as well. But I am not sure if it is wanted to automate this - comments are welcome.

推荐答案

一旦应用了 maven 插件,所有你需要做的安装到本地的Maven仓库是执行 gradle install (没有任何进一步的声明在构建脚本)。安装可以通过 mavenInstaller (而不是外部存储库的 mavenDeployer )进行微调。

Once you have applied the maven plugin, all you need to do to install to the local Maven repository is to execute gradle install (without any further declarations in the build script). Installation can be fine-tuned via mavenInstaller (instead of mavenDeployer for an external repository).

这篇关于如何使用uploadArchives推送到本地和远程的Maven存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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