blob: 825e868b14f2260fa8dfa52a6be6cd2a2426da58 [file] [log] [blame]
Yigit Boyarb1356332015-05-21 15:49:58 -07001
Yigit Boyar24bec1c2015-07-09 10:51:54 -07002buildscript {
3 ext.rootFolder = project.projectDir
4 apply from: 'propLoader.gradle'
5 ext.addRepos(repositories)
6 if (ext.config.addRemoteRepos) {
7 dependencies {
8 classpath "com.android.databinding:localizemaven:${config.extraPluginsVersion}"
9 }
10 }
George Mount69cbd9e2015-08-26 10:46:58 -070011 dependencies {
12 classpath 'net.sf.proguard:proguard-gradle:5.2.1'
13 }
Yigit Boyar24bec1c2015-07-09 10:51:54 -070014}
Yigit Boyar840f0ce2014-12-12 16:45:00 -080015subprojects {
Yigit Boyarf9e51c02015-03-12 14:30:29 -070016 apply plugin: 'maven'
Yigit Boyar24bec1c2015-07-09 10:51:54 -070017 if (config.addRemoteRepos) {
18 apply plugin: 'com.android.databinding.localizemaven'
Yigit Boyar63d47892015-07-10 09:03:05 -070019 }
20
Yigit Boyar24bec1c2015-07-09 10:51:54 -070021 group = config.group
22 version = config.version
Yigit Boyarf9e51c02015-03-12 14:30:29 -070023 uploadArchives {
24 repositories {
25 mavenDeployer {
Yigit Boyare421e292015-03-13 12:57:48 -070026 repository(url: "file://${config.mavenRepoDir}")
Yigit Boyarf9e51c02015-03-12 14:30:29 -070027 }
28 }
29 }
Yigit Boyar24bec1c2015-07-09 10:51:54 -070030 buildscript {
31 addRepos(repositories)
32 dependencies {
33 classpath "com.android.databinding:bintray:${config.extraPluginsVersion}"
34 }
35 }
36}
37
38if (config.addRemoteRepos) {
39 localizeMaven {
40 localRepoDir = file(config.megaRepoDir)
41 otherRepoDirs = config.localRepositories
42 }
Yigit Boyarf9e51c02015-03-12 14:30:29 -070043}
44
45task deleteRepo(type: Delete) {
Yigit Boyarb1356332015-05-21 15:49:58 -070046 delete "${config.mavenRepoDir}/${config.group.replace('.', '/')}"
Yigit Boyarf9e51c02015-03-12 14:30:29 -070047}
48
Yigit Boyaree758672015-04-16 15:12:02 -070049task deletePrebuildFolder(type: Delete) {
50 delete "${config.prebuildFolder}"
51}
52
Yigit Boyarc64ae352015-04-21 14:05:41 -070053task deleteEap(type: Delete) {
54 delete "${config.eapOutDir}"
55}
56
57
Yigit Boyara6e45832015-03-13 15:58:53 -070058def buildExtensionsTask = project.tasks.create "buildExtensionsTask", Exec
59buildExtensionsTask.workingDir file('extensions').getAbsolutePath()
Yigit Boyara6e45832015-03-13 15:58:53 -070060buildExtensionsTask.commandLine './gradlew'
61buildExtensionsTask.args 'clean', 'uploadArchives', '--info', '--stacktrace'
62buildExtensionsTask.dependsOn subprojects.uploadArchives
63
Yigit Boyaree758672015-04-16 15:12:02 -070064def prepareExtensionPrebuilds = project.tasks.create "prepareExtensionPrebuilds", Exec
65prepareExtensionPrebuilds.workingDir file('extensions').getAbsolutePath()
66prepareExtensionPrebuilds.commandLine './gradlew'
67prepareExtensionPrebuilds.args 'clean', 'preparePrebuilds', '--info', '--stacktrace'
68prepareExtensionPrebuilds.dependsOn subprojects.uploadArchives
69
Yigit Boyarf9e51c02015-03-12 14:30:29 -070070file('integration-tests').listFiles().findAll { it.isDirectory() }.each {
Yigit Boyara6e45832015-03-13 15:58:53 -070071 println("Creating run test task for ${it.getAbsolutePath()}.")
Yigit Boyarf9e51c02015-03-12 14:30:29 -070072 def testTask = project.tasks.create "runTestsOf${it.getName().capitalize()}", Exec
Yigit Boyara6e45832015-03-13 15:58:53 -070073 testTask.workingDir it.getAbsolutePath()
Yigit Boyarf9e51c02015-03-12 14:30:29 -070074 //on linux
75 testTask.commandLine './gradlew'
Yigit Boyara6e45832015-03-13 15:58:53 -070076 testTask.args 'clean', 'connectedCheck', '--info', '--stacktrace'
Yigit Boyarf9e51c02015-03-12 14:30:29 -070077 testTask.dependsOn subprojects.uploadArchives
Yigit Boyara6e45832015-03-13 15:58:53 -070078 testTask.dependsOn buildExtensionsTask
Yigit Boyarf9e51c02015-03-12 14:30:29 -070079}
80
81task runIntegrationTests {
82 dependsOn tasks.findAll { task -> task.name.startsWith('runTestsOf') }
83}
84
85task runAllTests {
86 dependsOn runIntegrationTests
87}
88
Yigit Boyaree758672015-04-16 15:12:02 -070089task preparePrebuilds() {
90 dependsOn deletePrebuildFolder
91 dependsOn prepareExtensionPrebuilds
92}
93
Yigit Boyarf9e51c02015-03-12 14:30:29 -070094allprojects {
95 afterEvaluate { project ->
96 runAllTests.dependsOn project.tasks.findAll {task -> task.name.equals('test')}
Yigit Boyara6e45832015-03-13 15:58:53 -070097 runAllTests.dependsOn project.tasks.findAll {task -> task.name.equals('connectedCheck')}
Yigit Boyaree758672015-04-16 15:12:02 -070098 preparePrebuilds.dependsOn project.tasks.findAll {task -> task.name.startsWith('prebuild')}
Yigit Boyarf9e51c02015-03-12 14:30:29 -070099 }
100}
101
Yigit Boyara6e45832015-03-13 15:58:53 -0700102subprojects.uploadArchives.each { it.shouldRunAfter deleteRepo }
Yigit Boyarae161282015-04-21 11:02:58 -0700103subprojects.uploadArchives.each { it.shouldRunAfter deletePrebuildFolder }
Yigit Boyara6e45832015-03-13 15:58:53 -0700104buildExtensionsTask.shouldRunAfter deleteRepo
Yigit Boyar99a3d312015-03-25 12:46:05 -0700105tasks['runTestsOfMultiModuleTestApp'].dependsOn tasks['runTestsOfIndependentLibrary']
Yigit Boyara6e45832015-03-13 15:58:53 -0700106
Yigit Boyarf9e51c02015-03-12 14:30:29 -0700107
108task rebuildRepo() {
109 dependsOn deleteRepo
110 dependsOn subprojects.uploadArchives
Yigit Boyara6e45832015-03-13 15:58:53 -0700111 dependsOn buildExtensionsTask
Yigit Boyaree758672015-04-16 15:12:02 -0700112}
113
Yigit Boyarc64ae352015-04-21 14:05:41 -0700114task copySamplesToEap(type : Copy) {
115 mustRunAfter deleteEap
116 from ("$projectDir/samples") {
117 exclude "**/build"
Yigit Boyar2939c3b2015-04-23 15:03:56 -0700118 exclude "**/local.properties"
Yigit Boyarc64ae352015-04-21 14:05:41 -0700119 }
120 into "${config.eapOutDir}/samples"
121}
122
123
124task copyMavenRepoToEap(type : Copy) {
125 mustRunAfter deleteEap
126 dependsOn rebuildRepo
127 from(config.mavenRepoDir)
128 into "${config.eapOutDir}/${config.mavenRepoName}"
129}
130
131tasks.create(name : 'createEapConfigFile') << {
132 def propsFile = new File("${config.eapOutDir}/databinding.properties")
133 Properties props = new Properties()
Yigit Boyar9399cb42015-05-16 15:42:45 -0700134 props.setProperty('version', config.version)
Yigit Boyarc64ae352015-04-21 14:05:41 -0700135 props.setProperty('mavenRepoName', config.mavenRepoName)
136 props.store(propsFile.newWriter(), null)
137}
138
139
140task batchEAP() {
141 dependsOn deleteEap
142 dependsOn copyMavenRepoToEap
143 dependsOn copySamplesToEap
144 dependsOn createEapConfigFile
Yigit Boyar24bec1c2015-07-09 10:51:54 -0700145}
George Mount69cbd9e2015-08-26 10:46:58 -0700146
147def fullJar(project) {
148 def localizeTask = project.parent.tasks.findByName('localizeDependencies')
149 if (localizeTask != null) {
150 localizeTask.dependsOn project.tasks.findByName('buildLicenseNotice')
151 }
152
153 if (config.version.endsWith('SNAPSHOT')) {
154 return
155 }
156 def jarName = project.uploadArchives.repositories.mavenDeployer.pom.artifactId
157 def workingDir = "${project.buildDir}/intermediates/fullJar"
158 def fatJar = "${workingDir}/${jarName}-fat.jar"
159 def proguardJar = "${workingDir}/${jarName}-proguard.jar"
160 def jarJar = project.jar.archivePath
161
162 project.configurations {
163 jarJarArchives
164 }
165
166 project.tasks.create(name: 'fatJar', type: Jar) {
167 baseName = jarName + '-fat'
168 doFirst {
169 file(workingDir).mkdirs()
170 }
171 def deps = new HashSet<ResolvedDependency>()
172 project.configurations.compile.resolvedConfiguration.firstLevelModuleDependencies.each {
173 if (!it.moduleGroup.startsWith('com.android.tools')) {
174 deps.addAll(it.allModuleArtifacts)
175 }
176 }
177 from { deps.findAll { !it.name.contains('baseLibrary')}.collect {
178 it.file.isDirectory() ? it.file : project.zipTree(it.file)
179 } } {
180 exclude "META-INF/maven/**"
181 exclude "META-INF/MANIFEST.MF"
182 exclude "META-INF/LICENSE.txt"
183 exclude "META-INF/NOTICE.txt"
184 exclude "META-INF/services/javax.annotation.processing.Processor"
185 exclude "**/*.stg"
186 }
187 archiveName "${baseName}.jar"
188 destinationDir = new File(workingDir)
189 with project.jar
190 }
191 project.tasks.create(name: 'proguard', type: proguard.gradle.ProGuardTask) {
192 dependsOn 'fatJar'
193
194 injars fatJar
195 outjars proguardJar
196
197 configuration '../proguard.cfg'
198 }
199
200 project.tasks.create(name: 'jarJarFile') {
201 dependsOn 'proguard'
202 dependsOn project.jar
203 def inputLibrary = proguardJar
204 def outputLibrary = jarJar
205 inputs.file(inputLibrary)
206 outputs.file(outputLibrary)
207
208 doLast {
209 def jarJarLibrary = new File(config.externalPrebuiltsBase,
210 'tools/common/m2/repository/com/googlecode/jarjar/jarjar/1.3/jarjar-1.3.jar').
211 getCanonicalPath()
212 // in Ant
213 ant.taskdef(name: "jarjarIt",
214 classname: 'com.tonicsystems.jarjar.JarJarTask',
215 classpath: jarJarLibrary)
216 // start jarjar task
217 ant.jarjarIt(jarfile: outputLibrary) {
218 // input is our inputLibrary
219 zipfileset(src: inputLibrary)
220 // rule to repackage antlr to new package
221 rule pattern: 'org.antlr.**', result: 'com.google.repacked.antlr.@1'
222 rule pattern: 'com.tunnelvisionlabs.**', result: 'com.google.repacked.tunnelvision.@1'
223 // rule to repackage commons
224 rule pattern: 'org.apache.**', result: 'com.google.repacked.apache.@1'
225 rule pattern: 'kotlin.**', result: 'com.google.repacked.kotlin.@1'
226 }
227 }
228 }
229
230 project.uploadArchives {
231 dependsOn 'jarJarFile'
232 repositories {
233 mavenDeployer {
234 pom.whenConfigured { pom ->
235 pom.dependencies.removeAll { dep ->
236 def isBaseLibrary = dep.groupId == 'com.android.databinding' &&
237 dep.artifactId == 'baseLibrary'
238 def isGradle = dep.groupId == 'com.android.tools.build' &&
239 dep.artifactId == 'gradle'
240 return !isBaseLibrary && !isGradle
241 }
242 }
243 }
244 }
245 }
246}