1 /** 2 * Helper build script that reads data binding variables and sets up the projects. 3 */ 4 def root = ext.dataBindingRootFolder 5 Properties databindingProperties = new Properties() 6 databindingProperties.load(new FileInputStream("${root}/databinding.properties")) 7 8 // load android gradle plugin's version file 9 apply from: "${root}/../buildSrc/base/version.gradle" 10 11 databindingProperties.version = ext.buildVersion 12 databindingProperties.compileSdkVersion = Integer.parseInt(databindingProperties.compileSdkVersionStr) 13 def repoBase = databindingProperties.mavenRepoAbsolutePath == "." ? root : databindingProperties.mavenRepoAbsolutePath 14 databindingProperties.androidGradlePluginRepoDir = "${root}/../../${databindingProperties.androidGradlePluginOutRepo}" 15 databindingProperties.mavenRepoDir = "${databindingProperties.androidGradlePluginRepoDir}" 16 databindingProperties.internalPrebuiltsRepoDir = "${root}/${databindingProperties.internalPrebuiltsRepoName}" 17 18 databindingProperties.inReleaseBuild = project.hasProperty('release') && project.ext.release == "true" 19 20 databindingProperties.runProguard = (project.hasProperty('runProguard') && project.getProperty('runProguard').equals("true")) 21 // load version from gradle build file 22 apply from: "$root/../buildSrc/base/version.gradle" 23 databindingProperties.androidPluginVersion=ext.buildVersion 24 databindingProperties.isIndependent = rootProject.name.equals("data-binding") 25 databindingProperties.eapOutDir = "${root}/${databindingProperties.eapOutFolderName}" 26 databindingProperties.prebuildFolder = "${root}/${databindingProperties.prebuildFolderName}" + 27 "/${databindingProperties.releaseVersion}" 28 29 ext.dataBindingConfig = databindingProperties 30 ext.dataBindingConfig.externalPrebuiltsBase = "${root}/../../prebuilts" 31 databindingProperties.megaRepoDir = "${databindingProperties.externalPrebuiltsBase}/tools/common/m2/repository" 32 33 new File(ext.dataBindingConfig.mavenRepoDir).mkdir() 34 new File(ext.dataBindingConfig.prebuildFolder).mkdir() 35 36 def addRemoteRepos = project.hasProperty('addRemoteRepos') && project.getProperty('addRemoteRepos').equals("true") 37 ext.dataBindingConfig.addRemoteRepos = addRemoteRepos 38 ext.dataBindingConfig.sharedSupportRepoDir = "${ext.dataBindingConfig.externalPrebuiltsBase}/maven_repo/android" 39 ext.dataBindingConfig.forGradlePlugin = project.hasProperty('forGradlePlugin') && project.getProperty('forGradlePlugin').equals("true") 40 def dataBindingConfig = ext.dataBindingConfig 41 def 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}"] 49 ext.dataBindingConfig.localRepositories = localRepositories 50 def 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 } 61 ext.addRepos = this.&addRepos 62 subprojects { 63 buildscript { 64 addRepos(repositories) 65 } 66 repositories { 67 addRepos(repositories) 68 } 69 } 70 71 def 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 } 81 ext.enablePublishing = this.&enablePublishing