【问题标题】:How do I publish a grails 3 plugin to my local nexus repo?如何将 grails 3 插件发布到我的本地 nexus 存储库?
【发布时间】:2016-04-17 19:08:45
【问题描述】:

运行grails publish-plugin 似乎没有任何作用,我能找到的唯一文档是关于发布到 bintray。

[编辑:]

我可以通过 gradle publish 发布插件,但想知道是否有 grails-y 方式来做,想知道 grails publish-plugin 实际做了什么:/

【问题讨论】:

    标签: grails grails-plugin grails-3.0


    【解决方案1】:

    我在Ryan Vanderwerfhttp://rvanderwerf.blogspot.com/2015/07/how-to-publish-grails-3-plugin.html 的帮助下解决了这个问题,他写道,有一堆 spring-boot 依赖项没有版本,这会导致 gradle 崩溃。要解决此问题,请删除 pom 中没有版本的所有依赖项:

    publishing {
        publications {
            mavenJar(MavenPublication) {
                pom.withXml {
                    def pomNode = asNode()
                    pomNode.dependencyManagement.replaceNode {}
    
                    // simply remove dependencies without a version
                    // version-less dependencies are handled with dependencyManagement
                    // see https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/8 for more complete solutions
                    pomNode.dependencies.dependency.findAll {
                        it.version.text().isEmpty()
                    }.each {
                        it.replaceNode {}
                    }
                }
                from components.java
            }
        }
        repositories {
            maven {
                credentials {
                    username "username"
                    password "password"
                }
                url "http://localhost/repo"
            }
        }
    }
    

    那么您可以使用grails publish-plugingradle publish 发布您的插件

    相关SO问题:Grails 3 - How to publish to Artifactory

    【讨论】:

    • 该解决方案对我有用。结果显示403错误。但在工件中,所有文件都呈现
    【解决方案2】:

    在 Grails 3.0.11 中,我使用 gradle 目标 publishToMavenLocal 进行本地开发。还有另一个目标publishMavenPublicationToMavenRepository。这似乎来自 gradle 插件:

    apply plugin: 'maven-publish'
    

    似乎在标准插件 build.gradle 中。

    (编辑:添加有关使用本地 maven 的注释)。

    在重新阅读您的问题和下面的评论后,我认为这不是您想要的。听起来您想要正常发布到系统上的存储库。 publishMavenPublicationToMavenRepository 可以处理。我上面描述的是使用本地 Maven 缓存来保存插件的快照,您可以在应用程序的机器上使用它。

    在开发应用程序中使用的插件时,这对我有用。

    我没有创建本地存储库。上面的 gradle 插件 (maven-publish) 有一个任务 publishToMavenLocal 会将 Grails 插件发布到本地 maven 缓存以进行本地开发。

    它将插件的 .zip 文件存储在 .m2 缓存目录中:

    C:\Users\xyz\.m2\repository\org\whatever\plugins\pluginName\0.3-SNAPSHOT
    

    然后,您可以在您机器上的 Grails 应用程序中使用该插件。

    【讨论】:

      【解决方案3】:

      在 grails 2.x 中 BuildConfig.groovy

      grails.project.dependency.distribution = {
          remoteRepository(id: '<repo name>',    url: '<url to your nexus repo>')
      }
      
      Then:
      
      grails clean
      
      grails compile 
      
      grails maven-deploy --repository=repo name
      

      在 grails 3.x+ 中:

      buildscript {
          repositories {
              mavenLocal()
              ...
          }
          dependencies {
              classpath "org.grails:grails-gradle-plugin:$grailsVersion"
          }
      }
      publishing {
          repositories {
              maven {
                  credentials {
                      username "xyz"
                      password "xyz"
                  }
                  url "http://example.com/nexus/content/repositories/nfb"
              }
          }
      }
      

      最后

      gradle 发布

      【讨论】:

      • grails 3 没有 BuildConfig.groovy
      猜你喜欢
      • 2019-11-22
      • 1970-01-01
      • 2017-09-08
      • 2011-12-09
      • 2011-04-13
      • 2018-02-09
      • 2016-09-03
      • 1970-01-01
      • 2019-08-03
      相关资源
      最近更新 更多