NullPointerException when publishing a Grails 3 plugin
I am trying to publish this Grails 3 plugin in Bintray following the steps in this tutorial . The last step is to run
gradle bintrayUpload
at the command line from the root of the project. When I do this I get the following error
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)
Any ideas on what is causing the problem?
Update
Following the suggestions below, I made the following changes to build.gradle
- updated bintray plugin to version 1.2
- changed
group "org.grails.plugins"
togroup "domurtag.plugins"
FAILURE: Build failed with exception.
- What went wrong: Execution completed for task ': bintrayUpload'.
Failed to create package 'grails / plugins / org.grails.plugins: grails-simple-captcha': HTTP / 1.1 403 Forbidden [message: Forbidden]
I added these environment variables
BINTRAY_USER=domurtag
BINTRAY_KEY=my_api_key
The error message indicates that the 403 reason is trying to publish the plugin to a repository grails/plugins
(which I don't have access to), but I don't know why this is happening?
I have seen exactly the same stack for my Gradle build. My Gradle build script was using com.jfrog.bintray
version 1.1. Build succeeds after upgrading to version 1.2.
Mistake
Could not create package 'grails/plugins/org.grails.plugins:grails-simple-captcha': HTTP/1.1 403 Forbidden [message:forbidden]
This is because you are trying to publish a repository grails/plugins
to which you do not have publish permission. You have to change the build.gradle
bintray configuration to publish to your own repository. Example:
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
}
}
}
Once you've published your own repository, you can request to include your plugin in grails/plugins
See this tutorial for a good guide: https://medium.com/@benorama/how-to-publish-your-grails-3-plugin-to-bintray-c341b24f567d
Your problem is your bintray config in build.gradle. By default, the Bintray Gradle plugin is configured with external files:
// 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'
so that you can override this config, then add your own config, for example:
// 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
}
}
}
in your case no value userOrg
is set (userOrg is used grails
) so you are not allowed to upload tohttps://bintray.com/grails/plugins/...
Alternatively, you can check https://raw.githubusercontent.com/grails/grails-profile-repository/master/profiles/plugin/templates/bintrayPublishing.gradle
to see the complete bintray configuration.