gradle-release插件+ maven发布插件 [英] gradle-release plugin + maven publishing plugin
问题描述
我试图重现maven的行为发布插件:
$ b
- 将分支版本更改为发布版本号(在svn提交) (at svn)
- 在Nexus OSS中部署版本标签
- 将分支版本更改为新的快照编号(在svn提交)
- Nexus OSS作为版本库
- SVN作为scm
- Gradle(2.8)
我试图用这两个插件实现我的目标:
- 将分支版本更改为发行版本号(在svn提交)
- 创建标记(在svn) (在svn提交)
-
将 Maven Publish Plugin 部署到Nexus:
命令行: gradle publish
任何想法如何生成一个版本并自动将其部署到Nexus?
以下是我的 build.gradle :
插件{
id'net.researchgate.release'version' 2.3.4'
}
应用插件:'maven-publish'
/ * ----------- -------------
----- PUBLISH PLUGIN -----
----------------- ---------
https://docs.gradle.org/current/userguide/publishing_maven.html
---------------- ---------- * /
发布{
出版物{
maven(MavenPublication){
groupId ma venGroup
artifactId mavenArtifact
版本版本
$ b from components.java
}
}
储存库{
maven {$ b $如果(project.version.endsWith(' - SNAPSHOT')){
url$ {nexusUrl} / content / repositories / repo-snapshots
} else {
url$ { nexusUrl} / content / repositories / repo-releases
}
credentials {
username nexusUsername
password nexusPassword
}
}
}
}
/ * ------------------------
----- RELEASE PLUGIN - ----
--------------------------
https://github.com/researchgate/gradle-释放
-------------------------- * /
释放{
failOnCommitNeeded = false
failOnUnversionedFiles = false
scmAdapters = [
net.researchgate.release.SvnAdapter
]
解决方案您需要设置依赖项这两项任务之间。这可以通过在
build.gradle
中添加以下行来完成:
afterReleaseBuild.dependsOn发布
release-plugin有两个任务,它们完全适用于hooking other任务,即
beforeReleaseBuild
和afterReleaseBuild
。这个任务(和你设置的依赖关系)在build
任务之前或之后执行。
https://github.com/researchgate/gradle-release#custom-release-steps
I'm creating gradle builds as a new gradle user, but I have worked with maven in the past.
I'm trying to reproduce actions of the maven release plugin:
- Change branch version to Release number (commit at svn)
- Create a tag (at svn)
- Deploy the release tag in Nexus OSS
- Change branch version to new Snapshot number (commit at svn)
As you can see, I'm using:
- Nexus OSS as versioning repository
- SVN as scm
- Gradle (2.8)
I'm trying to achieve my objectives with these two plugins:
-
- Change branch version to Release number (commit at svn)
- Create a tag (at svn)
- Change branch version to new Snapshot number (commit at svn)
Command line: gradle release
Maven Publish Plugin to deploy to Nexus:
Command line: gradle publish
Any ideas how I could generate a release and automatically deploy it to Nexus in one shot?
Below is my build.gradle:
plugins { id 'net.researchgate.release' version '2.3.4' } apply plugin: 'maven-publish' /*------------------------ ----- PUBLISH PLUGIN ----- -------------------------- https://docs.gradle.org/current/userguide/publishing_maven.html --------------------------*/ publishing { publications { maven(MavenPublication) { groupId mavenGroup artifactId mavenArtifact version version from components.java } } repositories { maven { if(project.version.endsWith('-SNAPSHOT')) { url "${nexusUrl}/content/repositories/repo-snapshots" } else { url "${nexusUrl}/content/repositories/repo-releases" } credentials { username nexusUsername password nexusPassword } } } } /*------------------------ ----- RELEASE PLUGIN ----- -------------------------- https://github.com/researchgate/gradle-release --------------------------*/ release { failOnCommitNeeded = false failOnUnversionedFiles = false scmAdapters = [ net.researchgate.release.SvnAdapter ] }
解决方案You need to setup a dependency between the two tasks. This can be done by adding this line in your
build.gradle
:afterReleaseBuild.dependsOn publish
The release-plugin has two tasks which are exactly for the usecase of hooking other tasks in the release process, namely
beforeReleaseBuild
andafterReleaseBuild
. This tasks (and the dependencies you set) are executed before or respectively after thebuild
task.https://github.com/researchgate/gradle-release#custom-release-steps
这篇关于gradle-release插件+ maven发布插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
正如您所看到的,我正在使用:
命令行: gradle release