MyEclipse创建Gradle项目报错内容如图:
展开Details内容如下:
org.gradle.tooling.GradleConnectionException: Could not run build action using Gradle installation 'D:\Program\gradle-3.3'. at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:55) .... at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)Caused by: org.gradle.api.GradleException: Could not determine the class-path for class org.gradle.tooling.internal.consumer.connection.InternalBuildActionAdapter. at org.gradle.tooling.internal.provider.serialization.ClasspathInferer.find(ClasspathInferer.java:143) .... at java.lang.Thread.run(Thread.java:744)Caused by: org.gradle.internal.UncheckedException: java.net.URISyntaxException: Illegal character in path at index 16: file:/D:/Program Files/MyEclipse 2015/plugins/org.gradle.toolingapi_3.3.0.v20170103170240.jar at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:45) ... 27 moreCaused by: java.net.URISyntaxException: Illegal character in path at index 16: file:/D:/Program Files/MyEclipse 2015/plugins/org.gradle.toolingapi_3.3.0.v20170103170240.jar at java.net.URI$Parser.fail(URI.java:2829) at java.net.URI$Parser.checkChars(URI.java:3002) at java.net.URI$Parser.parseHierarchical(URI.java:3086) at java.net.URI$Parser.parse(URI.java:3034) at java.net.URI.<init>(URI.java:595) at java.net.URL.toURI(URL.java:938) at org.gradle.internal.classloader.ClasspathUtil.getClasspathForClass(ClasspathUtil.java:74) ... 28 more
重点的报错内容已经标注出来:在路径file:/D:/Program Files/MyEclipse 2015/plugins...的第16个下标处有非法字符,而这第下标为16的字符正好是一个空格,说明路径中不能存在空格,为快速验证下载了eclipse j2ee版本,放在无空格的路径上,配置好Gradle插件后,创建Gradle项目成功。
貌似在跟java打交道的过程中碰到过好几次类似因为空格路径产生的问题,另外一次是安装运行JBoss出问题的,找了2天才发现是空格路径导致的。有空得研究下java URL解析为何总是碰到空格报错。