However this doesn’t work. I think perhaps the general configuration earlier is actually applied after the dependencies are declared, negating the specific transitive setting of the aws sdk.
Is there a way to globally set the transitivity to false while allowing specific cases to re-enable it?
It sounds like you’re expecting that setting transitive = false on the configuration is just a convenient way to set the transitive property for each dependency, but these are actually two different concepts.
When the configuration is set to transitive = false, you’re saying nothing in this configuration should resolve transitively. Adding transitive: true on your single dependency isn’t actually doing anything because true is already the default. All of your dependencies (unless they have transitive: false) are actually set to transitive = true, they just don’t resolve transitively because of the transitivity of the configuration. A dependency resolves transitively if it comes from a transitive configuration AND it is transitive itself.
To solve this simply, you probably don’t want to set transitive = false on the compile configuration for the sub-projects that require some transitive resolution. Instead, invert your logic and set transitive = false on the other dependencies.
I don’t want the transitivity of dependencies to be true by default.
Is there a way to set that?
There are thousands of dependencies in this build… I’m not going to each one and setting it transitive = false. I’d rather set the 5-6 which need to be transitive = true.
I understood your question, but in order to have a good conversation about possible technical solutions, it was important to understand what the issue was technically (the configuration set to transitive = false will prevent the transitive behavior on any dependency declared in the configuration).
But they are, even in your build, and you don’t really have a choice. True is the default when the dependency object is instantiated, and unless you configure the transitive property of the dependency explicitly, transitive will be true. In your example, “biz.aQute.bndlib” has transitive set to true, even though you didn’t set it.
You’re just setting the configuration transitive property to false, not the default of each dependency.
The suggestion was not to set every single dependency in your several hundred sub-projects to transitive = false. The suggestion was that you look at the sub-projects that contain those 5-6 dependencies, and see if you can make a change just in those few places without too much issue.
I wouldn’t want to add complexity in structure or implementation unless you really needed it.
This is what I would like to change… there’s no need for that to be statically defined.
Only because that is hard coded!
I’m asking how I would accomplish that.
This still implies lots of configuration. It means that in each module I have to set the configurationtransitive = false, this is already hundreds of duplications. Then in those few modules set every dependency except those few transitive = false instead of the configuration.
I’m going to try @Lance_Java’s proposal in the meantime.
If that proves not to work, I think I will make a PR to gradle to have a property which eliminates the hard coded transitive behaviour of true and merely sets it as the default.