gradle-release插件+ maven发布插件 [英] gradle-release plugin + maven publishing plugin

查看:1063
本文介绍了gradle-release插件+ maven发布插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图重现maven的行为发布插件:
$ b


  • 将分支版本更改为发布版本号(在svn提交) (at svn)

  • 在Nexus OSS中部署版本标签

  • 将分支版本更改为新的快照编号(在svn提交)




  • 正如您所看到的,我正在使用:


    • Nexus OSS作为版本库

    • SVN作为scm

    • Gradle(2.8)


      我试图用这两个插件实现我的目标:


      1. Gradle-release Plugin


        • 将分支版本更改为发行版本号(在svn提交)

        • 创建标记(在svn) (在svn提交)



        命令行: gradle release


      2. 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:

      1. Gradle-release Plugin:

        • 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

      2. 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 and afterReleaseBuild. This tasks (and the dependencies you set) are executed before or respectively after the build task.

      https://github.com/researchgate/gradle-release#custom-release-steps

      这篇关于gradle-release插件+ maven发布插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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