Open Vampire opened 5 years ago
Hi @Vampire I'm not sure I understand the point of optional dependencies is that they have a version in POM file. For example, you consume artifact A
which has an optional transitive dependency B
in version 1.0
That means if you add B
as you direct dependency you don't have to specify version because the optional path will be considered and version will be supplied from there. Publishing it as optional without version would be against this use case. Am I misunderstanding something?
According to https://blog.gradle.org/optional-dependencies the optional dependencies are purely informational in both Maven and Gradle. Gradle once had some feature preview where the optional dependencies versions were considered as version constraints, so that you indeed could declare the dependency without version and get the one from the POM. But afair this caused too much hassle and was different from Maven which just ignores it, so before making that feature preview stable, they removed the optional handling again and just ignore them as Maven does.
It would be nice if you could also leave out the version for optional dependencies in the resulting POM. Leaving it out in the Gradle script might not work, as you then can get problems resolving your configurations. But as the version of optional dependencies is not taken into account anyway, neither be Gradle nor by Maven, it would be nice if it could also be left out in the resulting pom.