Yigit Boyar | b135633 | 2015-05-21 15:49:58 -0700 | [diff] [blame] | 1 | |
Yigit Boyar | 24bec1c | 2015-07-09 10:51:54 -0700 | [diff] [blame] | 2 | buildscript { |
| 3 | ext.rootFolder = project.projectDir |
| 4 | apply from: 'propLoader.gradle' |
Yigit Boyar | d6ddc64 | 2015-09-11 12:59:40 -0700 | [diff] [blame] | 5 | apply from: 'supportBundle.gradle' |
Yigit Boyar | 24bec1c | 2015-07-09 10:51:54 -0700 | [diff] [blame] | 6 | ext.addRepos(repositories) |
| 7 | if (ext.config.addRemoteRepos) { |
| 8 | dependencies { |
| 9 | classpath "com.android.databinding:localizemaven:${config.extraPluginsVersion}" |
| 10 | } |
| 11 | } |
George Mount | 69cbd9e | 2015-08-26 10:46:58 -0700 | [diff] [blame] | 12 | dependencies { |
| 13 | classpath 'net.sf.proguard:proguard-gradle:5.2.1' |
| 14 | } |
Yigit Boyar | 24bec1c | 2015-07-09 10:51:54 -0700 | [diff] [blame] | 15 | } |
Yigit Boyar | 840f0ce | 2014-12-12 16:45:00 -0800 | [diff] [blame] | 16 | subprojects { |
Yigit Boyar | f9e51c0 | 2015-03-12 14:30:29 -0700 | [diff] [blame] | 17 | apply plugin: 'maven' |
Yigit Boyar | 24bec1c | 2015-07-09 10:51:54 -0700 | [diff] [blame] | 18 | if (config.addRemoteRepos) { |
| 19 | apply plugin: 'com.android.databinding.localizemaven' |
Yigit Boyar | 63d4789 | 2015-07-10 09:03:05 -0700 | [diff] [blame] | 20 | } |
| 21 | |
Yigit Boyar | 24bec1c | 2015-07-09 10:51:54 -0700 | [diff] [blame] | 22 | group = config.group |
| 23 | version = config.version |
Yigit Boyar | d6ddc64 | 2015-09-11 12:59:40 -0700 | [diff] [blame] | 24 | def url = (config.inReleaseBuild && it.name == "library") ? "file://${config.sharedSupportRepoDir}" : "file://${config.mavenRepoDir}" |
Yigit Boyar | f9e51c0 | 2015-03-12 14:30:29 -0700 | [diff] [blame] | 25 | uploadArchives { |
| 26 | repositories { |
| 27 | mavenDeployer { |
Yigit Boyar | d6ddc64 | 2015-09-11 12:59:40 -0700 | [diff] [blame] | 28 | repository(url: url) |
Yigit Boyar | f9e51c0 | 2015-03-12 14:30:29 -0700 | [diff] [blame] | 29 | } |
| 30 | } |
| 31 | } |
Yigit Boyar | 24bec1c | 2015-07-09 10:51:54 -0700 | [diff] [blame] | 32 | buildscript { |
| 33 | addRepos(repositories) |
| 34 | dependencies { |
| 35 | classpath "com.android.databinding:bintray:${config.extraPluginsVersion}" |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | if (config.addRemoteRepos) { |
| 41 | localizeMaven { |
| 42 | localRepoDir = file(config.megaRepoDir) |
| 43 | otherRepoDirs = config.localRepositories |
| 44 | } |
Yigit Boyar | f9e51c0 | 2015-03-12 14:30:29 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | task deleteRepo(type: Delete) { |
Yigit Boyar | b135633 | 2015-05-21 15:49:58 -0700 | [diff] [blame] | 48 | delete "${config.mavenRepoDir}/${config.group.replace('.', '/')}" |
Yigit Boyar | f9e51c0 | 2015-03-12 14:30:29 -0700 | [diff] [blame] | 49 | } |
| 50 | |
Yigit Boyar | ee75867 | 2015-04-16 15:12:02 -0700 | [diff] [blame] | 51 | task deletePrebuildFolder(type: Delete) { |
| 52 | delete "${config.prebuildFolder}" |
| 53 | } |
| 54 | |
Yigit Boyar | c64ae35 | 2015-04-21 14:05:41 -0700 | [diff] [blame] | 55 | task deleteEap(type: Delete) { |
| 56 | delete "${config.eapOutDir}" |
| 57 | } |
| 58 | |
| 59 | |
Yigit Boyar | a6e4583 | 2015-03-13 15:58:53 -0700 | [diff] [blame] | 60 | def buildExtensionsTask = project.tasks.create "buildExtensionsTask", Exec |
| 61 | buildExtensionsTask.workingDir file('extensions').getAbsolutePath() |
Yigit Boyar | a6e4583 | 2015-03-13 15:58:53 -0700 | [diff] [blame] | 62 | buildExtensionsTask.commandLine './gradlew' |
Yigit Boyar | b90752c | 2015-09-28 16:42:16 -0700 | [diff] [blame^] | 63 | buildExtensionsTask.args 'clean', 'uploadArchives', '--info', '--stacktrace', |
| 64 | "-PuseReleaseVersion=${config.inReleaseBuild ? 'true' : 'false'}", |
| 65 | "-PaddRemoteRepos=${config.addRemoteRepos ? 'true' : 'false'}" |
Yigit Boyar | a6e4583 | 2015-03-13 15:58:53 -0700 | [diff] [blame] | 66 | buildExtensionsTask.dependsOn subprojects.uploadArchives |
| 67 | |
Yigit Boyar | d6ddc64 | 2015-09-11 12:59:40 -0700 | [diff] [blame] | 68 | tasks['bundleSupportLib'].dependsOn buildExtensionsTask |
| 69 | |
Yigit Boyar | ee75867 | 2015-04-16 15:12:02 -0700 | [diff] [blame] | 70 | def prepareExtensionPrebuilds = project.tasks.create "prepareExtensionPrebuilds", Exec |
| 71 | prepareExtensionPrebuilds.workingDir file('extensions').getAbsolutePath() |
| 72 | prepareExtensionPrebuilds.commandLine './gradlew' |
Yigit Boyar | b90752c | 2015-09-28 16:42:16 -0700 | [diff] [blame^] | 73 | prepareExtensionPrebuilds.args 'clean', 'preparePrebuilds', '--info', '--stacktrace', |
| 74 | "-PuseReleaseVersion=${config.inReleaseBuild ? 'true' : 'false'}", |
| 75 | "-PaddRemoteRepos=${config.addRemoteRepos ? 'true' : 'false'}" |
Yigit Boyar | ee75867 | 2015-04-16 15:12:02 -0700 | [diff] [blame] | 76 | prepareExtensionPrebuilds.dependsOn subprojects.uploadArchives |
| 77 | |
Yigit Boyar | f9e51c0 | 2015-03-12 14:30:29 -0700 | [diff] [blame] | 78 | file('integration-tests').listFiles().findAll { it.isDirectory() }.each { |
Yigit Boyar | a6e4583 | 2015-03-13 15:58:53 -0700 | [diff] [blame] | 79 | println("Creating run test task for ${it.getAbsolutePath()}.") |
Yigit Boyar | f9e51c0 | 2015-03-12 14:30:29 -0700 | [diff] [blame] | 80 | def testTask = project.tasks.create "runTestsOf${it.getName().capitalize()}", Exec |
Yigit Boyar | a6e4583 | 2015-03-13 15:58:53 -0700 | [diff] [blame] | 81 | testTask.workingDir it.getAbsolutePath() |
Yigit Boyar | f9e51c0 | 2015-03-12 14:30:29 -0700 | [diff] [blame] | 82 | //on linux |
| 83 | testTask.commandLine './gradlew' |
Yigit Boyar | b90752c | 2015-09-28 16:42:16 -0700 | [diff] [blame^] | 84 | testTask.args 'clean', 'connectedCheck', '--info', '--stacktrace', |
| 85 | "-PuseReleaseVersion=${config.inReleaseBuild ? 'true' : 'false'}", |
| 86 | "-PaddRemoteRepos=${config.addRemoteRepos ? 'true' : 'false'}" |
Yigit Boyar | f9e51c0 | 2015-03-12 14:30:29 -0700 | [diff] [blame] | 87 | testTask.dependsOn subprojects.uploadArchives |
Yigit Boyar | a6e4583 | 2015-03-13 15:58:53 -0700 | [diff] [blame] | 88 | testTask.dependsOn buildExtensionsTask |
Yigit Boyar | f9e51c0 | 2015-03-12 14:30:29 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | task runIntegrationTests { |
| 92 | dependsOn tasks.findAll { task -> task.name.startsWith('runTestsOf') } |
| 93 | } |
| 94 | |
| 95 | task runAllTests { |
| 96 | dependsOn runIntegrationTests |
| 97 | } |
| 98 | |
Yigit Boyar | ee75867 | 2015-04-16 15:12:02 -0700 | [diff] [blame] | 99 | task preparePrebuilds() { |
| 100 | dependsOn deletePrebuildFolder |
| 101 | dependsOn prepareExtensionPrebuilds |
| 102 | } |
| 103 | |
Yigit Boyar | f9e51c0 | 2015-03-12 14:30:29 -0700 | [diff] [blame] | 104 | allprojects { |
| 105 | afterEvaluate { project -> |
| 106 | runAllTests.dependsOn project.tasks.findAll {task -> task.name.equals('test')} |
Yigit Boyar | a6e4583 | 2015-03-13 15:58:53 -0700 | [diff] [blame] | 107 | runAllTests.dependsOn project.tasks.findAll {task -> task.name.equals('connectedCheck')} |
Yigit Boyar | ee75867 | 2015-04-16 15:12:02 -0700 | [diff] [blame] | 108 | preparePrebuilds.dependsOn project.tasks.findAll {task -> task.name.startsWith('prebuild')} |
Yigit Boyar | f9e51c0 | 2015-03-12 14:30:29 -0700 | [diff] [blame] | 109 | } |
| 110 | } |
| 111 | |
Yigit Boyar | a6e4583 | 2015-03-13 15:58:53 -0700 | [diff] [blame] | 112 | subprojects.uploadArchives.each { it.shouldRunAfter deleteRepo } |
Yigit Boyar | ae16128 | 2015-04-21 11:02:58 -0700 | [diff] [blame] | 113 | subprojects.uploadArchives.each { it.shouldRunAfter deletePrebuildFolder } |
Yigit Boyar | a6e4583 | 2015-03-13 15:58:53 -0700 | [diff] [blame] | 114 | buildExtensionsTask.shouldRunAfter deleteRepo |
Yigit Boyar | 99a3d31 | 2015-03-25 12:46:05 -0700 | [diff] [blame] | 115 | tasks['runTestsOfMultiModuleTestApp'].dependsOn tasks['runTestsOfIndependentLibrary'] |
Yigit Boyar | a6e4583 | 2015-03-13 15:58:53 -0700 | [diff] [blame] | 116 | |
Yigit Boyar | f9e51c0 | 2015-03-12 14:30:29 -0700 | [diff] [blame] | 117 | |
| 118 | task rebuildRepo() { |
| 119 | dependsOn deleteRepo |
| 120 | dependsOn subprojects.uploadArchives |
Yigit Boyar | a6e4583 | 2015-03-13 15:58:53 -0700 | [diff] [blame] | 121 | dependsOn buildExtensionsTask |
Yigit Boyar | ee75867 | 2015-04-16 15:12:02 -0700 | [diff] [blame] | 122 | } |
| 123 | |
Yigit Boyar | c64ae35 | 2015-04-21 14:05:41 -0700 | [diff] [blame] | 124 | task copySamplesToEap(type : Copy) { |
| 125 | mustRunAfter deleteEap |
| 126 | from ("$projectDir/samples") { |
| 127 | exclude "**/build" |
Yigit Boyar | 2939c3b | 2015-04-23 15:03:56 -0700 | [diff] [blame] | 128 | exclude "**/local.properties" |
Yigit Boyar | c64ae35 | 2015-04-21 14:05:41 -0700 | [diff] [blame] | 129 | } |
| 130 | into "${config.eapOutDir}/samples" |
| 131 | } |
| 132 | |
| 133 | |
| 134 | task copyMavenRepoToEap(type : Copy) { |
| 135 | mustRunAfter deleteEap |
| 136 | dependsOn rebuildRepo |
| 137 | from(config.mavenRepoDir) |
| 138 | into "${config.eapOutDir}/${config.mavenRepoName}" |
| 139 | } |
| 140 | |
| 141 | tasks.create(name : 'createEapConfigFile') << { |
| 142 | def propsFile = new File("${config.eapOutDir}/databinding.properties") |
| 143 | Properties props = new Properties() |
Yigit Boyar | 9399cb4 | 2015-05-16 15:42:45 -0700 | [diff] [blame] | 144 | props.setProperty('version', config.version) |
Yigit Boyar | c64ae35 | 2015-04-21 14:05:41 -0700 | [diff] [blame] | 145 | props.setProperty('mavenRepoName', config.mavenRepoName) |
| 146 | props.store(propsFile.newWriter(), null) |
| 147 | } |
| 148 | |
| 149 | |
| 150 | task batchEAP() { |
| 151 | dependsOn deleteEap |
| 152 | dependsOn copyMavenRepoToEap |
| 153 | dependsOn copySamplesToEap |
| 154 | dependsOn createEapConfigFile |
Yigit Boyar | 24bec1c | 2015-07-09 10:51:54 -0700 | [diff] [blame] | 155 | } |
George Mount | 69cbd9e | 2015-08-26 10:46:58 -0700 | [diff] [blame] | 156 | |
| 157 | def fullJar(project) { |
| 158 | def localizeTask = project.parent.tasks.findByName('localizeDependencies') |
| 159 | if (localizeTask != null) { |
| 160 | localizeTask.dependsOn project.tasks.findByName('buildLicenseNotice') |
| 161 | } |
| 162 | |
Yigit Boyar | d6ddc64 | 2015-09-11 12:59:40 -0700 | [diff] [blame] | 163 | if (!config.inReleaseBuild) { |
George Mount | 69cbd9e | 2015-08-26 10:46:58 -0700 | [diff] [blame] | 164 | return |
| 165 | } |
| 166 | def jarName = project.uploadArchives.repositories.mavenDeployer.pom.artifactId |
| 167 | def workingDir = "${project.buildDir}/intermediates/fullJar" |
| 168 | def fatJar = "${workingDir}/${jarName}-fat.jar" |
| 169 | def proguardJar = "${workingDir}/${jarName}-proguard.jar" |
| 170 | def jarJar = project.jar.archivePath |
| 171 | |
| 172 | project.configurations { |
| 173 | jarJarArchives |
| 174 | } |
| 175 | |
| 176 | project.tasks.create(name: 'fatJar', type: Jar) { |
| 177 | baseName = jarName + '-fat' |
| 178 | doFirst { |
| 179 | file(workingDir).mkdirs() |
| 180 | } |
| 181 | def deps = new HashSet<ResolvedDependency>() |
| 182 | project.configurations.compile.resolvedConfiguration.firstLevelModuleDependencies.each { |
| 183 | if (!it.moduleGroup.startsWith('com.android.tools')) { |
| 184 | deps.addAll(it.allModuleArtifacts) |
| 185 | } |
| 186 | } |
| 187 | from { deps.findAll { !it.name.contains('baseLibrary')}.collect { |
| 188 | it.file.isDirectory() ? it.file : project.zipTree(it.file) |
| 189 | } } { |
| 190 | exclude "META-INF/maven/**" |
| 191 | exclude "META-INF/MANIFEST.MF" |
| 192 | exclude "META-INF/LICENSE.txt" |
| 193 | exclude "META-INF/NOTICE.txt" |
| 194 | exclude "META-INF/services/javax.annotation.processing.Processor" |
| 195 | exclude "**/*.stg" |
| 196 | } |
| 197 | archiveName "${baseName}.jar" |
| 198 | destinationDir = new File(workingDir) |
| 199 | with project.jar |
| 200 | } |
| 201 | project.tasks.create(name: 'proguard', type: proguard.gradle.ProGuardTask) { |
| 202 | dependsOn 'fatJar' |
| 203 | |
| 204 | injars fatJar |
| 205 | outjars proguardJar |
| 206 | |
| 207 | configuration '../proguard.cfg' |
| 208 | } |
| 209 | |
| 210 | project.tasks.create(name: 'jarJarFile') { |
| 211 | dependsOn 'proguard' |
| 212 | dependsOn project.jar |
| 213 | def inputLibrary = proguardJar |
| 214 | def outputLibrary = jarJar |
| 215 | inputs.file(inputLibrary) |
| 216 | outputs.file(outputLibrary) |
| 217 | |
| 218 | doLast { |
| 219 | def jarJarLibrary = new File(config.externalPrebuiltsBase, |
| 220 | 'tools/common/m2/repository/com/googlecode/jarjar/jarjar/1.3/jarjar-1.3.jar'). |
| 221 | getCanonicalPath() |
| 222 | // in Ant |
| 223 | ant.taskdef(name: "jarjarIt", |
| 224 | classname: 'com.tonicsystems.jarjar.JarJarTask', |
| 225 | classpath: jarJarLibrary) |
| 226 | // start jarjar task |
| 227 | ant.jarjarIt(jarfile: outputLibrary) { |
| 228 | // input is our inputLibrary |
| 229 | zipfileset(src: inputLibrary) |
| 230 | // rule to repackage antlr to new package |
| 231 | rule pattern: 'org.antlr.**', result: 'com.google.repacked.antlr.@1' |
| 232 | rule pattern: 'com.tunnelvisionlabs.**', result: 'com.google.repacked.tunnelvision.@1' |
| 233 | // rule to repackage commons |
| 234 | rule pattern: 'org.apache.**', result: 'com.google.repacked.apache.@1' |
| 235 | rule pattern: 'kotlin.**', result: 'com.google.repacked.kotlin.@1' |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | project.uploadArchives { |
| 241 | dependsOn 'jarJarFile' |
| 242 | repositories { |
| 243 | mavenDeployer { |
| 244 | pom.whenConfigured { pom -> |
| 245 | pom.dependencies.removeAll { dep -> |
| 246 | def isBaseLibrary = dep.groupId == 'com.android.databinding' && |
| 247 | dep.artifactId == 'baseLibrary' |
| 248 | def isGradle = dep.groupId == 'com.android.tools.build' && |
| 249 | dep.artifactId == 'gradle' |
| 250 | return !isBaseLibrary && !isGradle |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | } |