-
Notifications
You must be signed in to change notification settings - Fork 89
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 missing version information #262
Comments
Thanks for the report. I'm not sure if this is an enhancement that needs to be implemented here, or something that Gradle should pick up automatically based on what this plugin's resolution strategy has done. What's your take on this please, @melix? If you're publishing Gradle's own metadata then I'd strongly encourage you to look at Gradle's platform and enforced platform support as a replacement for this plugin. |
Thanks for the tip @wilkinsona |
Answering for @melix. :) As @wilkinsona pointed out, you can basically do what you want with Gradle's built-in features now. The sample could look like this:
This will also publish the dependency constraint in the metadata. If you un-comment the platform dependency to the BOM, that will also be published and the BOM will automatically be pulled in by consumers as well. Another option you have if you want versions to be published on the dependencies directly, is to publish the resolved dependency versions. I think that should also work for the original sample with the Spring dependency management plugin. |
After looking at platforms it doesn't look like it fully meets what we want yet, or don't understand how to use it correctly. For now we will go with disabling consumption of gradle metadata from our hosted repositories by adding a metatdataSources block to our repositories.
Hopefully someone will in time provide examples of multi project builds using spring boot and gradle platforms |
I don't think Platforms have any special requirements in a multi-project build. You should declare a dependency on the Platform in every project where you want it to be used and for every configuration that you want to use it. You can do that in a I've made a note in #211 about publication of the resolved dependency versions. Given that there are no other changes needed here, I am going to close this issue. |
@brockj I am really curious what is blocking you from using Gradle Module Metadata and I am happy to point you at, or provide you with, additional examples. Unfortunately I am not sure what you mean by this:
There should be nothing special to multi-projects nor to spring boot BOM that should require some special setup beyond what exist and what is documented. Could you elaborate which issue you are still running in and/or which error you are facing that you can work around by disabling consumption of module metadata? Thanks a lot. |
@jjohannes The issue we had was that it was publishing with the unresolved version numbers (ie. blank) We use the dependency management plugin because that is what is in every spring boot example i have seen. It helps us manage groups of dependencies that do not offer a BOM (we currently don't produce BOMs for our own artifacts either) I will setup a repo tomorrow to reproduce the issue we are having. I am pretty sure we can work around it with the gradle platforms, but it would mean a fair bit of rework on our projects |
@jjohannes I have pushed a sample repo to It is only a single project as it should be enough to show the issue. Still happy to leave the issue closed as we have workarounds and will slowly migrate our structure to use more standard Gradle features. |
@brockj thank you for sharing the sample. Very much appreciated. I think in the discussion two new Gradle core concepts got mixed up platforms and dependency constraints.
I created a PR for your example repo to show it for that example. The resulting POM should be the same as before but the @wilkinsona You could investigate if you can wrap (parts of) your implementation around these new Gradle APIs and possibly get rid of a good chunk of your own POM-writing implementation in |
@jjohannes Could you add a demo show how to implement import bom with overriding properties dependencyManagement {
imports {
mavenBom("xxx") {
bomProperty("xxx.version", "1.2.3")
}
}
} |
@JasonMing Unfortunately, this is not (yet) supported by Gradle natively (gradle/gradle#9160). If you can provide a complete example of your use case, I can check if there is a good alternative solution or how you could best combine the Spring DM plugin with Gradle's features to get the best of both worlds. |
is there any way to make |
A platform is not applied to the annotation processor classpath by default. You need to declare it explicitly:
|
Thank you :) |
It seems that version metadata still missing in Gradle module metadata (checked with Gradle 6.7.1). @wilkinsona Is there a dedicated ticket for that issue? #211 does not have mentions of the missing version metadata in Gradle-s modules. This works as a temporary fix but it would be nice to get the issue fixed. metadataSources {
mavenPom()
ignoreGradleMetadataRedirection()
} |
@alexei-osipov Ideally, if you're interested in Gradle's module metadata you should use Gradle's native platform support rather than this plugin. If that's not possible then you may be able to configure Gradle to use the resolution result when determining the versions in the metadata. That's what the comment made on #211 is proposing to document. |
I'm pretty confused by all this. In the above, when I make the replacement suggested: // Spring DM plugin // Gradle core EVERYTHING in Spring Boot Platform is in my compile/runtime classpath, which I don't want, and which was not true when I imported the mavenBom. EDIT: hmmm....perhaps I'm wrong and there was always more in my classpath than I realized, coming in transitively. |
I assume you're looking at the output from Gradle's |
@wilkinsona I'm not interested in Gradle's module metadata. The problem that "this plugin + Gradle 6.7" results in broken project. I think that this plugin should do one of these options:
|
@alexei-osipov We seem to be going round in circles. As described above, #211 is already tracking some documentation updates that will describe how to achieve your second option. It will describe how to, as @jjohannes recommended above, configure Gradle to use the resolved versions. It may also be worth mentioning how to disable metadata publication but I don't think that's something this plugin should do by default. |
After upgrading gradle to 6.0 and the new metadata publishing we have noticed that dependencies aren't resolving due to missing version numbers.
Given the following build file
When generating the metadata file it produces a dependency section like this:
When we depend on this artifact from another artifact it fails to resolve the correct version of log4j-api unless we directly set a version number for it in the consuming build file. That is, we aren't getting the transitive version
The generated POM is also missing the version number, but there is a dependency management section in it that is used to define the version, so it works ok.
The only workaround we have so far is to not publish gradle metadata to our nexus and consume the POM instead.
We have found that if we specify the version directly (ie. don't use dependency management plugin) it produces a dependency section like this:
Note that it includes the required version number and we are able to consume the artifact correctly.
The text was updated successfully, but these errors were encountered: