New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GRADLE_METADATA feature preview: task generateMetadataFileForMyIvyPublication failed with NullPointerException #5450
Comments
@gradle/dependency-management Can you please take a look? |
@ameliedagenais Thanks for the report, and glad to see someone giving the new metadata format a try. The error you see is definitely unexpected. I can see different possible causes:
I'm leaning towards 3, because I can reproduce with the following build file:
See https://scans.gradle.com/s/3gcahqhfqzd4i/failure?openFailures=WzBd&openStackTraces=WzEse31d#top=0 So while we should fix the NPE, it seems that you may have a configuration problem. Or not, because I'm not sure what publication corresponds to |
If the task to generate the module metadata file was explicitly called and that the publication didn't define any component to publish (aka, no call to `from components....`), then we would fail the generation with an NPE. This commit fixes the problem by adding a precondition before executing the task, which warns the user that the task shouldn't be called if there's no attached component, and disables the task. Fixes #5450
@melix Sorry for the confusion around the name of the task, I was trying to scrub out confidential information in the task name and just didn't replace it with anything which ended up being confusing. It would actually look more like
So you're right, there's no associated component to this publication, however, we define an artifact and the |
That's correct, but there's a good reason for that. Ivy and Maven metadata are not "variant aware", or, at a simpler level, component aware. We don't know what you are publishing: is it a Java library? Is it test fixtures? Is it a variant with an Eventually, we will have a public API for defining your own components, but in the meantime you are limited to the components Gradle knows about, which are, for now, Java libraries, platforms and native components. The PR I have submitted will not give you a Gradle metadata file, but at least, it will not fail with a NPE. |
If the task to generate the module metadata file was explicitly called and that the publication didn't define any component to publish (aka, no call to `from components....`), then we would fail the generation with an NPE. This commit fixes the problem by adding a precondition before executing the task, which warns the user that the task shouldn't be called if there's no attached component, and disables the task. Fixes #5450
Fixed by #5459 for 4.8 RC2. |
Thanks for fixing the NPE and providing a better error message. The explanation makes sense, I can fix my project to define components. |
Expected Behavior
module.json file should be generated successfully
Current Behavior
Task
generateMetadataFileForMyIvyPublication
fails with this error:And the module.json ends up being half-generated:
Context
I've been interested to try the GRADLE_METADATA feature for a while, because I'm very interested to use the module.json metadata file. I tried a few things, including running the samples from the https://github.com/gradle/dependency-management-samples project, but just couldn't figure out how to get the module metadata file generated for my project. But then I saw the
generateMetadataFileForPublication
task made available as of 4.8-rc-1 so I decided to give it a try. It worked nicely on the sample projects, but just didn't work for my project.Steps to Reproduce (for bugs)
My build.gradle is as simple as this, but references a custom plugin:
The custom plugin in the backgrounds does a bunch of things. It defines source/publish repos, artifacts to publish, etc. It also applies a few other plugins such as
java-library
,ivy-publish
,base
,jacoco
.I can try to dig deeper to recreate a simpler build.gradle which reproduces the issue if needed, but it might take me while, so I'd only do it if it can be useful.
Your Environment
The text was updated successfully, but these errors were encountered: