doc
Align versions of modules without a published platform
says:
The identifier, in this case `com.fasterxml.jackson:jackson-virtual-platform`, is something you as the build author define yourself. The "content" of the platform is then created by Gradle on the fly by collecting all `belongsTo` statements pointing at the same virtual platform.
a example:
dependencies {
api 'com.fasterxml.jackson.core:jackson-databind:2.9.5' // dep core
api 'com.fasterxml.jackson.core:jackson-core:2.9.7'
components.all(JacksonBomAlignmentRule)
}
abstract class JacksonBomAlignmentRule implements ComponentMetadataRule {
//@Override
void execute(ComponentMetadataContext ctx) {
// println("execute:"+ctx.getDetails())
ctx.details.with {
println("details:"+it.id+"->platform:"+id.version)
if (id.group.startsWith("com.fasterxml.jackson")) {
// declare that Jackson modules all belong to the Jackson virtual platform
belongsTo("com.fasterxml.jackson:jackson-virtual-platform:${id.version}")
}
}
}
}
by log:
details:com.fasterxml.jackson.core:jackson-databind:2.9.5->platform:2.9.5
details:com.fasterxml.jackson.core:jackson-core:2.9.7->platform:2.9.7
details:com.fasterxml.jackson.core:jackson-annotations:2.9.0->platform:2.9.0
details:com.fasterxml.jackson.core:jackson-databind:2.9.7->platform:2.9.7
details:com.fasterxml.jackson.core:jackson-annotations:2.9.7->platform:2.9.7 // where dose this jackson-annotations:2.9.7 comes from?
form 3 version virtual-platform:
platform:2.9.5
jackson-databind:2.9.5
platform:2.9.7
jackson-core:2.9.7
jackson-databind:2.9.7
jackson-annotations:2.9.7
platform:2.9.0
jackson-annotations:2.9.0
compileClasspath, runtimeClasspath:
+--- com.fasterxml.jackson.core:jackson-databind:2.9.5 -> 2.9.7
| +--- com.fasterxml.jackson.core:jackson-annotations:2.9.0 -> 2.9.7
| \--- com.fasterxml.jackson.core:jackson-core:2.9.7
\--- com.fasterxml.jackson.core:jackson-core:2.9.7
quetion:
The "content" of the platform is then created by Gradle on the fly by collecting all `belongsTo` statements pointing at the same virtual platform.
if the virtual-platform’s include libs by belongsTo, then the log should be:
details:com.fasterxml.jackson.core:jackson-databind:2.9.5->platform:2.9.5
details:com.fasterxml.jackson.core:jackson-core:2.9.7->platform:2.9.7
details:com.fasterxml.jackson.core:jackson-annotations:2.9.0->platform:2.9.0
details:com.fasterxml.jackson.core:jackson-databind:2.9.7->platform:2.9.7
form 3 version virtual-platform:
platform:2.9.5
jackson-databind:2.9.5
platform:2.9.7
jackson-core:2.9.7
jackson-databind:2.9.7
platform:2.9.0
jackson-annotations:2.9.0
but infact, there is this line in log:
details:com.fasterxml.jackson.core:jackson-annotations:2.9.7->platform:2.9.7 // where dose this jackson-annotations:2.9.7 comes from?
So there is chicken egg question:
is platform:2.9.7 comes first or jackson-annotations:2.9.7 comes first?
- if platform:2.9.7 comes first, how the relation between platform:2.9.7 and jackson-annotations:2.9.7 generated?
- if jackson-annotations:2.9.7 comes first, where is jackson-annotations:2.9.7 comes from?
and when add enforcedPlatform to the example, there is the same question, where is the relation belongsTo
of jackson-core:2.8.9 to platform:2.8.9 comes from?
implementation enforcedPlatform('com.fasterxml.jackson:jackson-virtual-platform:2.8.9')