We run a mono-repo of composite builds so it scales very well (ie. opening 1 project does not bring in all projects and only brings in the stuff it depends on).
Each project is duplicating code if you read the comment ‘DUPLICATED’
plugins {
id 'java-library'
id 'checkstyle' //DUPLICATED
}
apply from: '../../config/global.gradle' //Brings in common deps across whole repo to prevent jar hell between teams
group 'com.orderlyhealth.util'
repositories {. //DUPLICATED
mavenCentral() //DUPLICATED
maven { url uri('/tmp/myRepo/') } // DUPLICATED
}
dependencies {
implementation deps['slf4j']
}
checkstyle { //DUPICATED
configFile = rootProject.file('../../config/checkstyle.xml') //DUPLICATED
ignoreFailures = false //DUPLICATED
}
QUESTION 1: How can we not duplicate this code?
QUESTION 2: How can we not duplicate this code but allow overriding the global configuration?
Try #2 moving id ‘checkstyle’ into the build.gradle and out of global.gradle is a step in the right direction but I am not sure if the repository section is used but the checkstyle one definitely is being used.