0

我正在创建一个 Gradle 插件

当我尝试为有空间的 project.dependencies compile 设置 jar 路径时,出现异常

* What went wrong:
A problem occurred evaluating root project 'visage-gradle-sample'.
> No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection) values: [file collection]
Possible solutions: module(java.lang.Object)

我正在尝试在 MyPlugin 应用方法中设置它

    private void configureSetup(project) {


    final javafxHome = System.env["JAVAFX_HOME"]

    def jfxJar =''

    if (javafxHome) {
        jfxJar = "${javafxHome}${File.separator}rt${File.separator}lib${File.separator}jfxrt.jar"
    }
    else{
        final javaHome = System.env["JAVA_HOME"]
        jfxJar = "${javaHome}${File.separator}jre${File.separator}lib${File.separator}jfxrt.jar"
    }

    if(!(new File(jfxJar)).exists())
    throw new StopExecutionException("JAVAFX_HOME is not set or your JDK is not having JAVAFX jar.")

        project.dependencies  {
          compile project.files(jfxJar)
    }

}

我正在尝试设置位于以下路径中的 JavaFX 2 jfxrt.jar

 C:\Program Files\Oracle\JavaFX 2.1 SDK\rt\lib\jfxrt.jar

调试显示

 15:36:31.036 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: groovy.lang.MissingMethodException: No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection) values: [file collection]
 Possible solutions: module(java.lang.Object)
 15:36:31.051 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.methodMissing(DefaultDependencyHandler.groovy:94)
 15:36:31.067 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.invokeMethod(DefaultDependencyHandler.groovy)
 15:36:31.082 [ERROR] [org.gradle.BuildExceptionReporter]        at org.visage.gradle.plugin.VisagePlugin$_configureSetup_closure1.doCall(VisagePlugin.groovy:122)
 15:36:31.098 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:141)
 15:36:31.114 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:90)
 15:36:31.129 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.AbstractProject.dependencies(AbstractProject.java:879)
 15:36:31.129 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.Project$dependencies.call(Unknown Source)
 15:36:31.160 [ERROR] [org.gradle.BuildExceptionReporter]        at org.visage.gradle.plugin.VisagePlugin.configureSetup(VisagePlugin.groovy:121)
 15:36:31.176 [ERROR] [org.gradle.BuildExceptionReporter]        at org.visage.gradle.plugin.VisagePlugin.this$2$configureSetup(VisagePlugin.groovy)
 15:36:31.176 [ERROR] [org.gradle.BuildExceptionReporter]        at org.visage.gradle.plugin.VisagePlugin$this$2$configureSetup.callCurrent(Unknown Source)
 15:36:31.207 [ERROR] [org.gradle.BuildExceptionReporter]        at org.visage.gradle.plugin.VisagePlugin.apply(VisagePlugin.groovy:67)
 15:36:31.207 [ERROR] [org.gradle.BuildExceptionReporter]        at org.visage.gradle.plugin.VisagePlugin.apply(VisagePlugin.groovy)
 15:36:31.223 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.providePlugin(DefaultProjectsPluginContainer.java:107)
 15:36:31.239 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.addPluginInternal(DefaultProjectsPluginContainer.java:71)
 15:36:31.254 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.apply(DefaultProjectsPluginContainer.java:37)
 15:36:31.270 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:101)
 15:36:31.285 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:32)
 15:36:31.301 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:72)
 15:36:31.317 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:114)
 15:36:31.348 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.AbstractProject.apply(AbstractProject.java:840)
 15:36:31.364 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.Project$apply.call(Unknown Source)
 15:36:31.379 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
 15:36:31.395 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.Script$apply.callCurrent(Unknown Source)
 15:36:31.410 [ERROR] [org.gradle.BuildExceptionReporter]        at build_1c4c4h5n90lk41hinuth6in4rk.run(D:\MyWorkBench\jugchennai\visage-gradle-plugin\visage-gradle-sample\build.gradle:8)
 15:36:31.410 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
 15:36:31.426 [ERROR] [org.gradle.BuildExceptionReporter]        ... 29 more
 15:36:31.442 [ERROR] [org.gradle.BuildExceptionReporter]
 15:36:31.457 [LIFECYCLE] [org.gradle.BuildResultLogger]

如何克服路径中的空间?

4

1 回答 1

4

看起来问题与路径中的空格无关。我假设代码不应用java插件,因此没有compile配置。

顺便说一句,File.separator将路径传递给 Gradle 时永远不需要使用。只需使用/,Gradle 就会做正确的事情。

于 2012-06-29T15:29:26.397 回答