Speed up incremental builds

This commit is contained in:
Suphon Thanakornpakapong
2022-05-10 10:38:05 +07:00
parent da56f42031
commit eff2ed7b24
2 changed files with 22 additions and 6 deletions
+1
View File
@@ -39,6 +39,7 @@ android {
}
addFrameworkJar('framework-12l.jar')
replaceFrameworkJar('framework-12l.jar')
}
dependencies {
+21 -6
View File
@@ -33,15 +33,32 @@ allprojects {
maven { url 'https://jitpack.io' }
}
ext.addFrameworkJar = { String path ->
def frameworkJar = new File(rootProject.projectDir, 'prebuilts/libs/' + path)
ext.getFrameworkJar = { String name ->
def frameworkJar = new File(rootProject.projectDir, 'prebuilts/libs/' + name)
if (!frameworkJar.exists()) {
throw new IllegalArgumentException("Framework jar path doesn't exist")
}
return frameworkJar
}
ext.addFrameworkJar = { String name ->
def frameworkJar = getFrameworkJar(name)
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.bootstrapClasspath = files([frameworkJar] + (options.bootstrapClasspath.files as Iterable<File>))
}
tasks.withType(org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask) {
it.classpath.from(files([frameworkJar]))
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
it.classpath.from(files([frameworkJar]))
}
}
}
ext.replaceFrameworkJar = { String name ->
def frameworkJar = getFrameworkJar(name)
gradle.projectsEvaluated {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
def originalFiles = [] + it.classpath.files
def newFiles = []
@@ -52,10 +69,8 @@ allprojects {
newFiles.add(file)
}
}
it.classpath.setFrom(files(newFiles))
}
tasks.withType(org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask) {
it.classpath.from(files([frameworkJar] + (it.classpath.files as Iterable<File>)))
it.classpath.setFrom(files([]))
it.classpath.from(files(newFiles))
}
}
}