As a result of examining each of the following, it seems that managing the target with the property outside + array is transparent and easy to maintain. I referred to various open source projects and the opinions of other engineers.
--Solid writing --Variable --Outside the property -** Manage the target with an array while going out to the property **
build.gradle
dependencies {
// JUnit
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.2.0'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.2.0'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.2.0'
}
build.gradle
def junitVersion = '5.2.0'
dependencies {
// JUnit
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: junitVersion
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: junitVersion
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: junitVersion
}
For homemade properties, I decided to manage the keys in uppercase snake cases, as Gradle may actually suffer from property names that are already in use. Other than that, it's about half and half to manage lowercase letters separated by dots. I thought that if I put it in a capital snake case, it wouldn't wear anything inside Gradle at least, so I did this.
gradle.properties
LIBRARY_VERSION_JUNIT=5.2.0
build.gradle
def junitVersion = (String) project.LIBRARY_VERSION_JUNIT
dependencies {
// JUnit
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: junitVersion
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: junitVersion
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: junitVersion
}
gradle.properties
LIBRARY_VERSION_JUNIT=5.2.0
build.gradle
def libraryVersions = [
junit: (String) project.LIBRARY_VERSION_JUNIT,
]
dependencies {
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: libraryVersions.junit
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: libraryVersions.junit
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: libraryVersions.junit
}
The advantage is that the source can be stored in libraryVersions.