spring-gradle-plugins / dependency-management-plugin

A Gradle plugin that provides Maven-like dependency management functionality
686 stars 85 forks source link

Provide an option to not generate <dependencyManagement/> tag #309

Closed quaff closed 2 years ago

quaff commented 2 years ago

https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven:resolved_dependencies Gradle supports resolving version for every dependency now, then the <dependencyManagement/> is superfluous, Currently I need to remove it in pom.withXml {}.

publishing {
    publications {
        maven(MavenPublication) {
            from components.java
            versionMapping {
                usage("java-api") {
                    fromResolutionOf("runtimeClasspath")
                }
                usage("java-runtime") {
                    fromResolutionResult()
                }
            }
            pom.withXml {
                var node = asNode()
                node.remove(node.dependencyManagement[0])
            }
        }
    }
}
wilkinsona commented 2 years ago

As described in the documentation, customization of the pom can already be disabled.

quaff commented 2 years ago

👍 Great!

quaff commented 2 years ago

Could we check if versionMapping present then disable it by default?

wilkinsona commented 2 years ago

While I think that would be technically possible, I would prefer not to add the complexity that it would bring both in terms of the code and in the behaviour of the configuration option. For example, what would happen if customization of the pom has been explicitly enabled yet every dependency has a version?

quaff commented 2 years ago

While I think that would be technically possible, I would prefer not to add the complexity that it would bring both in terms of the code and in the behaviour of the configuration option. For example, what would happen if customization of the pom has been explicitly enabled yet every dependency has a version?

Only set the default enabled to false if versionMapping of MavenPublication present, if user set enabled explicitly, respect it no matter true or false.

wilkinsona commented 2 years ago

Thanks for the suggestion, but as I said above, I don't want to add the complexity.