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}" 17 18databindingProperties.inReleaseBuild = project.hasProperty('release') && project.ext.release == "true" 19 20databindingProperties.runProguard = (project.hasProperty('runProguard') && project.getProperty('runProguard').equals("true")) 21// load version from gradle build file 22apply from: "$root/../buildSrc/base/version.gradle" 23databindingProperties.androidPluginVersion=ext.buildVersion 24databindingProperties.isIndependent = rootProject.name.equals("data-binding") 25databindingProperties.eapOutDir = "${root}/${databindingProperties.eapOutFolderName}" 26databindingProperties.prebuildFolder = "${root}/${databindingProperties.prebuildFolderName}" + 27 "/${databindingProperties.releaseVersion}" 28 29ext.dataBindingConfig = databindingProperties 30ext.dataBindingConfig.externalPrebuiltsBase = "${root}/../../prebuilts" 31databindingProperties.megaRepoDir = "${databindingProperties.externalPrebuiltsBase}/tools/common/m2/repository" 32 33new File(ext.dataBindingConfig.mavenRepoDir).mkdir() 34new File(ext.dataBindingConfig.prebuildFolder).mkdir() 35 36def addRemoteRepos = project.hasProperty('addRemoteRepos') && project.getProperty('addRemoteRepos').equals("true") 37ext.dataBindingConfig.addRemoteRepos = addRemoteRepos 38ext.dataBindingConfig.sharedSupportRepoDir = "${ext.dataBindingConfig.externalPrebuiltsBase}/maven_repo/android" 39ext.dataBindingConfig.forGradlePlugin = project.hasProperty('forGradlePlugin') && project.getProperty('forGradlePlugin').equals("true") 40def dataBindingConfig = ext.dataBindingConfig 41def localRepositories = ["${dataBindingConfig.internalPrebuiltsRepoDir}", 42 "${dataBindingConfig.megaRepoDir}", 43 "${dataBindingConfig.mavenRepoDir}", 44 "${dataBindingConfig.externalPrebuiltsBase}/tools/common/offline-m2", 45 dataBindingConfig.sharedSupportRepoDir, 46 "${dataBindingConfig.externalPrebuiltsBase}/gradle-plugin", 47 "${dataBindingConfig.externalPrebuiltsBase}/tools/common/m2/repository", 48 "${databindingProperties.androidGradlePluginRepoDir}"] 49ext.dataBindingConfig.localRepositories = localRepositories 50def addRepos(RepositoryHandler handler) { 51 dataBindingConfig.localRepositories.each { repo -> 52 handler.maven { 53 url repo 54 } 55 } 56 if (dataBindingConfig.addRemoteRepos) { 57 handler.jcenter() 58 handler.mavenCentral() 59 } 60} 61ext.addRepos = this.&addRepos 62subprojects { 63 buildscript { 64 addRepos(repositories) 65 } 66 repositories { 67 addRepos(repositories) 68 } 69} 70 71def enablePublishing(p, addJavadoc) { 72 if (!ext.dataBindingConfig.isIndependent) { 73 p.apply from: "$dataBindingRootFolder/../buildSrc/base/publish.gradle" 74 p.apply from: "$dataBindingRootFolder/../buildSrc/base/bintray.gradle" 75 if (addJavadoc) { 76 p.apply from: "$dataBindingRootFolder/../buildSrc/base/javadoc.gradle" 77 } 78 rootProject.project(":base:gradle-core").publishLocal.dependsOn p.publishLocal 79 } 80} 81ext.enablePublishing = this.&enablePublishing