Let's say I have a pom file, which includes a <properties>
section, and a dependency -- let's say SLF4J for example.
Is there any possible property name that I could provide that would set the version of that dependency, without me needing to make a <version>
tag for that dependency in the <dependency>
section?
For context, I use properties to hold my dependency versions, then I reference the property name via the ${some.property.name}
syntax to add it to my <version>
tag on my dependency. I started changing all of my property names to follow the following naming format -- <groupid.artifactid.version>2.0.17</groupid.artifactid.version>
. This is useful, as it makes things unambiguous, and if I order both my properties and dependencies, I have a matching side-by-side list.
But when I saw the name, part of me wondered if the mere existence of the property might set the version of the dependency. I know the mere existence of certain properties have configured things in my build that I didn't know could be configured just by properties. I wasn't sure if it was some plugin, or maven itself that was referencing them, but it made me wonder. After all, maybe the same could happen for dependencies. If not in the same pom, then maybe some combination or permutation of parent pom, aggregator pom, or child pom could cause this to be true. And since I am uprooting a couple of things in my project structure, I wanted to make sure I wasn't creating a problem for myself here.
Again -- I saw something I didn't understand, so this question is more or less rooted in paranoia and ignorance. Feel free to tell me as much if that's all this is. But I figured I'd ask before I run into any difficult-to-trace errors or configuration issues.
No, is the short answer to your question.
As stated in the official documentation,
groupId:artifactId:version are all required fields (although, groupId and version do not need to be explicitly defined if they are inherited from a parent)
Version either needs to be defined explicitly for a dependency or inherited from a parent.
You can find more about inheritance here. Inheritance