This repository has been archived by the owner on May 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Cache Service
Adrián Rivero edited this page May 3, 2017
·
2 revisions
Important! This is an incubating feature
Cache Service will speed up the generation of the classes in the project. After the first build, all the classes are cached, and are used to make a differential build (only including the file that changed), this reduces the overall time to make a build.
To enable the service it should be activated though the parameter "cacheFiles" to the annotation processor in the application "build.gradle", ex:
...
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.yourapp.package"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
//This is what should be added
javaCompileOptions {
annotationProcessorOptions {
arguments = ["cacheFiles": "true"]
}
}
}
}
...
Then you should add the following script to the same gradle file:
task declexCache {
doFirst {
def timeout = 60000;
def timeoutDec = timeout
while (file("../.declex/cache/generate.lock").exists() && timeoutDec > 0) {
sleep(100)
timeoutDec -= 100
}
if (timeoutDec <= 0) {
throw new GradleException("Error Generating Cache Files")
} else {
println "Cache Files Generated, waiting: " + (timeout - timeoutDec) + "ms"
}
file("../.declex/cache/compiler.done").createNewFile();
}
}
project.afterEvaluate {
compileDebugSources.doLast {
declexCache.execute()
}
if (tasks.findByPath("compileReleaseSources") != null) {
compileReleaseSources.doLast {
declexCache.execute()
}
}
}
And the "cached" classes jar should be added as well, as a provided dependency:
dependencies {
provided files('../.declex/cache/declex_cache.jar')
}
Sponsored by DSpot Sp. z o.o. Contact us at info@dspot.com.pl