chore: improve usage of Gradle build cache

1.	Use local build cache on non-CI environment
2.	Add option to allow push to remote cache from some machines
diff --git a/gradle/build-cache.gradle b/gradle/build-cache.gradle
index a51f488..f822516 100644
--- a/gradle/build-cache.gradle
+++ b/gradle/build-cache.gradle
@@ -17,20 +17,24 @@
  * implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
+/*
+ * WORKAROUND:
+ * Jenkins doesn't set CI environment variable
+ * https://issues.jenkins-ci.org/browse/JENKINS-36707
+ * <grv87 2018-06-27>
+ */
+ext.pushToRemoteCache = System.getenv().with { containsKey('CI') || containsKey('JENKINS_URL') } || hasProperty('gradle.cache.push') && getProperty('gradle.cache.push')
 buildCache {
-  local.enabled = false
+  local {
+    enabled = !pushToRemoteCache
+    removeUnusedEntriesAfterDays = 30
+  }
   remote(HttpBuildCache) {
     url = 'https://fidata.jfrog.io/fidata/local.gradle.cache/'
     credentials {
       username = settings.ext.artifactoryUser
       password = settings.ext.artifactoryPassword
     }
-    /*
-     * WORKAROUND:
-     * Jenkins doesn't set CI environment variable
-     * https://issues.jenkins-ci.org/browse/JENKINS-36707
-     * <grv87 2018-06-27>
-     */
-    push = System.getenv().with { containsKey('CI') || containsKey('JENKINS_URL') }
+    push = pushToRemoteCache
   }
 }