Defining dependency versions in a property

Defining the version of a set of dependencies like GeoTools or Spring in a property seems useful and convenient. Yet, it is apparently deprecated in Maven and if it appears in POM, Gradle won’t interpret it correctly. Should we be doing this in Gradle?

When you are talking about using a property to define a dependency version, do you mean String interpolation via Groovy GStrings?

ext.myVersion = '1.0'
  dependencies {
    compile "my.company:artifact:$myVersion"
}

If yes, then the String will be evaluated at runtime. Publishing the project artifact(s) doesn’t not use the property for the generated POM.

Yes that is what I meant or the equivalent compile group: ‘my.company’, name: ‘artifact’, version: myVersion

Which of these two is the preferred style (and is there a style guide)?

Both notations mean and behave the same. Gradle gives you both options and is not opinionated about which one should be used. So it boils down to personal preference.

Using the Map notation I believe is easier to understand for beginners to Gradle as it spells out the attributes. However, in practice I see that users rather prefer to use the String notation because it is shorter.

Thanks