通过持续集成在Gradle中发布Snapshot和Publish发布 [英] Publish Snapshot vs Publish Release in Gradle With Continuous Integration

查看:2176
本文介绍了通过持续集成在Gradle中发布Snapshot和Publish发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚学习Gradle,来自Ant + Ivy和Maven背景,我试图用适当的方式来包装我的头,以使用gradle发布我的软件的发行版。我还需要不断整合我的项目,而不必不断发布独立的工件。


$ b Ant + Ivy
$ b

在Ant + Ivy世界中,我可以创建publishSnapshot和publishRelease目标。这些可以分别使用不同的Ivy解析器来解析并发布到我在Nexus中的单独快照或版本库中。


$ b

使用Maven,我可以在<$ c中定义一个 snapshotRepository repository $ c> distributionManagement 部分将maven发布到我在Nexus中的单独快照或发布存储库中。
$ b Gradle



现在输入gradle。我怎样才能实现这个相同的功能?我使用ivy风格的存储库。



感谢您提供的任何见解。

ANSWER



感谢René的回答,我终于能够创建一个可行的解决方案。问题的关键是我需要不断整合所有项目。要做到这一点,我认为使用版本号 latest.integration 声明一个依赖项是拉入我的库的最新版本的唯一方法,因此我需要使用ivy样式存储库。

实际上,还有其他方法可以使用最新版本的库来持续集成所有项目中的软件。解决方案是使用 uploadArchives ,就像René下面列出的一样(也请注意您需要 apply plugin:'maven'。在我的例子中,我在common.gradle和下游项目中列出了一个全局版本号,我用版本:version 来引用全局版本变量,这样我的系统中的每个工件都具有相同的版本,当它发布的时候,我可以将它从1.0-SNAPSHOT更改为1.0,并构建每个版本您可以配置快照发行版 >'上传'任务中的仓库(例如 uploadArchives )任务:

  uploadArchives {
repositories {
mavenDeployer {
repository(url:'http://myCompanyRepo.com:8081/releases'){
身份验证(用户名:'admin',密码:'密码');

snapshotRepository(url:'http://myCompanyRepo.com:8081/snapshots'){
authentication(userName:'admin',password:'password');
}
}
}
}

* - SNAPSHOT 版本使用 snapshotRepository 。否则,使用版本回购。


I'm just learning Gradle, coming from both an Ant+Ivy and Maven background and I'm trying to wrap my head around the proper way to publish a release version of my software using gradle. I also need to constantly integrate my projects without having to constantly release independent artifacts.

Ant + Ivy

In the Ant + Ivy world, I can create publishSnapshot and publishRelease targets. These can each use different Ivy resolvers to resolve and publish to my separate snapshot or release repositories in Nexus.

Maven

With Maven, I can define a snapshotRepository or repository in my distributionManagement section to have maven publish to my separate snapshot or release repositories in Nexus.

Gradle

Now enter gradle. How can I achieve this same functionality? I am using ivy style repositories.

Thank you for any insights you can provide.

ANSWER

Thanks to René's answer below, I was finally able to create a workable solution. The crux of the matter was that I needed to constantly integrate across all my projects. To do this I thought that declaring a dependency using version number latest.integration was the only way to pull in the latest version of my libraries, and therefore I needed to use ivy style repositories.

In fact, there are other ways to pull in the latest version of libraries in order to continuously integrate my software across all projects. The solution is to use the uploadArchives exactly as René has listed below (also note you will need to apply plugin: 'maven' for this to work. Make sure your repositories are also maven style, and when declaring a dependency, you can use dynamic version numbers as shown here. In my case, I listed a global version number in my common.gradle and in downstream projects, I used version: version to reference the global version variable. In this way, each artifact in my system has the same version. When it's time to release, I can change this from 1.0-SNAPSHOT to 1.0 and build each one in order.

解决方案

You can configure the snapshot and the release repository in the 'Upload' task (e.g. the uploadArchives) task:

uploadArchives {  
    repositories {  
        mavenDeployer {  
            repository(url: 'http://myCompanyRepo.com:8081/releases') {  
                authentication(userName: 'admin', password: 'password');  
            }  
            snapshotRepository(url: 'http://myCompanyRepo.com:8081/snapshots') {
                authentication(userName: 'admin', password: 'password');  
            }  
        }  
    }  
}

For *-SNAPSHOT versions the snapshotRepository is used. Otherwise the releases repo is used.

这篇关于通过持续集成在Gradle中发布Snapshot和Publish发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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