1/** 2 * Helper build script that reads data binding variables and sets up the projects. 3 */ 4def root = ext.dataBindingRootFolder 5Properties databindingProperties = new Properties() 6databindingProperties.load(new FileInputStream("${root}/databinding.properties")) 7 8// load android gradle plugin's version file 9apply from: "${root}/../buildSrc/base/version.gradle" 10 11databindingProperties.version = ext.buildVersion 12databindingProperties.compileSdkVersion = Integer.parseInt(databindingProperties.compileSdkVersionStr) 13def repoBase = databindingProperties.mavenRepoAbsolutePath == "." ? root : databindingProperties.mavenRepoAbsolutePath 14databindingProperties.androidGradlePluginRepoDir = "${root}/../../${databindingProperties.androidGradlePluginOutRepo}" 15databindingProperties.mavenRepoDir = "${databindingProperties.androidGradlePluginRepoDir}" 16databindingProperties.internalPrebuiltsRepoDir = "${root}/${databindingProperties.internalPrebuiltsRepoName}" 17databindingProperties.runProguard = project.hasProperty('runProguard') && project.getProperty('runProguard').equals("true") 18 19databindingProperties.inReleaseBuild = project.ext.hasProperty('release') && project.ext.release 20// load version from gradle build file 21apply from: "$root/../buildSrc/base/version.gradle" 22databindingProperties.androidPluginVersion=ext.buildVersion 23databindingProperties.isIndependent = rootProject.name.equals("data-binding") 24databindingProperties.eapOutDir = "${root}/${databindingProperties.eapOutFolderName}" 25databindingProperties.prebuildFolder = "${root}/${databindingProperties.prebuildFolderName}" + 26 "/${databindingProperties.releaseVersion}" 27 28ext.dataBindingConfig = databindingProperties 29ext.dataBindingConfig.externalPrebuiltsBase = "${root}/../../prebuilts" 30databindingProperties.megaRepoDir = "${databindingProperties.externalPrebuiltsBase}/tools/common/m2/repository" 31 32new File(ext.dataBindingConfig.mavenRepoDir).mkdir() 33new File(ext.dataBindingConfig.prebuildFolder).mkdir() 34 35def addRemoteRepos = project.hasProperty('addRemoteRepos') && project.getProperty('addRemoteRepos').equals("true") 36ext.dataBindingConfig.addRemoteRepos = addRemoteRepos 37ext.dataBindingConfig.sharedSupportRepoDir = "${ext.dataBindingConfig.externalPrebuiltsBase}/maven_repo/android" 38ext.dataBindingConfig.forGradlePlugin = project.hasProperty('forGradlePlugin') && project.getProperty('forGradlePlugin').equals("true") 39def dataBindingConfig = ext.dataBindingConfig 40def localRepositories = ["${dataBindingConfig.internalPrebuiltsRepoDir}", 41 "${dataBindingConfig.megaRepoDir}", 42 "${dataBindingConfig.mavenRepoDir}", 43 "${dataBindingConfig.externalPrebuiltsBase}/tools/common/offline-m2", 44 dataBindingConfig.sharedSupportRepoDir, 45 "${dataBindingConfig.externalPrebuiltsBase}/gradle-plugin", 46 "${dataBindingConfig.externalPrebuiltsBase}/tools/common/m2/repository", 47 "${databindingProperties.androidGradlePluginRepoDir}"] 48ext.dataBindingConfig.localRepositories = localRepositories 49def addRepos(RepositoryHandler handler) { 50 dataBindingConfig.localRepositories.each { repo -> 51 handler.maven { 52 url repo 53 } 54 } 55 if (dataBindingConfig.addRemoteRepos) { 56 handler.jcenter() 57 handler.mavenCentral() 58 } 59} 60ext.addRepos = this.&addRepos 61subprojects { 62 buildscript { 63 addRepos(repositories) 64 } 65 repositories { 66 addRepos(repositories) 67 } 68} 69 70def enablePublishing(p, addJavadoc) { 71 if (!ext.dataBindingConfig.isIndependent) { 72 p.apply from: "$dataBindingRootFolder/../buildSrc/base/publish.gradle" 73 p.apply from: "$dataBindingRootFolder/../buildSrc/base/bintray.gradle" 74 if (addJavadoc) { 75 p.apply from: "$dataBindingRootFolder/../buildSrc/base/javadoc.gradle" 76 } 77 rootProject.project(":base:gradle-core").publishLocal.dependsOn p.publishLocal 78 } 79} 80ext.enablePublishing = this.&enablePublishing