gradle 构建过程出现 ssl 错误

To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/2.10/userguide/gradle_daemon.html.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'tiancaiP2P_Android'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve com.neenbedankt.gradle.plugins:android-apt:1.4+.
     Required by:
         :tiancaiP2P_Android:unspecified
      > Could not resolve com.neenbedankt.gradle.plugins:android-apt:1.4+.
         > Failed to list versions for com.neenbedankt.gradle.plugins:android-apt.
            > Unable to load Maven meta-data from https://jcenter.bintray.com/com/neenbedankt/gradle/plugins/android-apt/maven-metadata.xml.
               > Failure initializing default system SSL context

* Try:
Run with —stacktrace option to get the stack trace. Run with —info or —debug option to get more log output.

BUILD FAILED

Total time: 3.71 secs

遇到这样的问题,分析错误信息推测是 https 的证书验证失败,导致无法访问 https 资源。由于 gradle 是基于 groovy 开发的工具,groovy本身是在 jvm 的基础上开发出来的。所以最终原因是 java 对 https 的证书验证出现了问题。

原来,java 会保存一个 ca 数据库,在osx 系统上可以通过 /usr/libexec/java_home 来查询当前 java 安装路劲,找到 jre/lib/security 目录,验证其中的 cacerts 文件是否有问题。