发布Grails 3插件时出现NullPointerException

时间:2015-06-12 17:20:33

标签: grails

我正在尝试按照this Grails 3中的步骤将this guide插件发布到Bintray。最后一步是运行

gradle bintrayUpload

在项目根目录的命令行上。当我这样做时,我收到以下错误消息

FAILURE: Build failed with an exception.

* What went wrong:
java.lang.NullPointerException (no error message)

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
java.lang.NullPointerException
    at org.gradle.api.internal.tasks.DefaultTaskDependency.add(DefaultTaskDependency.java:109)
    at org.gradle.api.internal.AbstractTask$11.run(AbstractTask.java:327)
    at org.gradle.api.internal.tasks.TaskMutator.mutate(TaskMutator.java:37)
    at org.gradle.api.internal.AbstractTask.dependsOn(AbstractTask.java:325)
    at com.jfrog.bintray.gradle.BintrayPlugin$_apply_closure2_closure5.doCall(BintrayPlugin.groovy:96)
    at com.jfrog.bintray.gradle.BintrayPlugin$_apply_closure2.doCall(BintrayPlugin.groovy:88)

关于问题原因的任何想法是什么?

更新

根据以下建议,我在build.gradle

中进行了以下更改
  • 将bintray插件更新为1.2版
  • group "org.grails.plugins"更改为group "domurtag.plugins"
  

失败:构建因异常而失败。

     

      
  • 出了什么问题:任务执行失败':bintrayUpload'。

         
        

    无法创建包'grails / plugins / org.grails.plugins:grails-simple-captcha':HTTP / 1.1     403 Forbidden [message:forbidden]

  •     

  

我添加了这些环境变量

BINTRAY_USER=domurtag
BINTRAY_KEY=my_api_key

错误消息表明403的原因是因为尝试将插件发布到grails/plugins存储库(我无权访问),但我不知道为什么这发生了吗?

3 个答案:

答案 0 :(得分:3)

我看到了Gradle构建的完全相同的堆栈跟踪。 My Gradle构建脚本使用com.jfrog.bintray 1.1版。升级到1.2版后,构建成功运行。

答案 1 :(得分:2)

错误

Could not create package 'grails/plugins/org.grails.plugins:grails-simple-captcha': HTTP/1.1 403 Forbidden [message:forbidden]

是因为您尝试发布到您无权发布到的grails/plugins存储库。您必须修改build.gradle bintray配置才能发布到您自己的存储库。例如:

version "0.1"
group "benorama.plugins"
bintray {
  pkg {
    userOrg = '' // If you want to publish to an organization
    name = "benorama.plugins:$project.name"
    issueTrackerUrl = "https://github.com/benorama/grails-$project.name/issues"
    vcsUrl = “https://github.com/benorama/grails-$project.name"
    version {
      attributes = ['grails-plugin': "benorama.plugins:$project.name"]
      name = project.version
    }
  }
}

一旦您发布到自己的存储库,您可以请求将您的插件包含在grails/plugins

有关优秀指南,请参阅本教程:https://medium.com/@benorama/how-to-publish-your-grails-3-plugin-to-bintray-c341b24f567d

答案 2 :(得分:0)

您的问题出现在build.gradle中的bintray配置中。 默认情况下,Bintray Gradle插件配置了外部文件:

// Used for publishing to central repository, remove if not needed
apply from: 'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/grailsCentralPublishing.gradle'
apply from: 'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/bintrayPublishing.gradle'

因此您必须通过以后添加配置来覆盖此配置,例如:

// Used for publishing to central repository, remove if not needed
apply from: 'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/grailsCentralPublishing.gradle'
apply from: 'https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/bintrayPublishing.gradle'

version '0.1'
group 'org.grails.plugins'

bintray {
    pkg {
        userOrg = '<your bintray username>'
        repo = 'plugins'
        name = "org.grails.plugins:$project.name"
        desc = "Grails $project.name plugin"
        websiteUrl = "http://grails.org/plugin/$project.name"
        issueTrackerUrl = "https://github.com/<username>/grails-$project.name/issues"
        vcsUrl = "https://github.com/<username>/grails-$project.name"
        licenses = ['Apache-2.0']
        version {
            attributes = ['grails-plugin': "org.grails.plugins:$project.name"]
            name = project.version
        }
    }
}

在您的情况下,userOrg的值未设置(使用了userOrg grails),因此您无法上传到https://bintray.com/grails/plugins/...

此外,您可以查看https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/bintrayPublishing.gradle以查看完整的bintray配置。