当前位置: 首页 > 知识库问答 >
问题:

Gradle 1.1 vs 2.0:无法确定任务“:CompileAcctJava”的相关性

张承颜
2023-03-14

1.11级给我一个弃用警告:

robert@pferdeapfel:~/prj> gradle --version | grep Gradle
Gradle 1.11

robert@pferdeapfel:~/prj> gradle compileJava
Converting class org.gradle.api.internal.file.DefaultSourceDirectorySet to File using
toString() method has been deprecated and is scheduled to be removed in Gradle 2.0.
Please use java.io.File, java.lang.String, java.net.URL, or java.net.URI instead.
:compileAcctJava
:processAcctResources UP-TO-DATE
:acctClasses
:resources
:acct UP-TO-DATE
:beans UP-TO-DATE
:svninfo UP-TO-DATE
:settings UP-TO-DATE
:compileJava UP-TO-DATE

BUILD SUCCESSFUL
Total time: 10.865 secs

Gradle2.0的构建失败:

robert@pferdeapfel:~/prj> /usr/local/gradle-2.0/bin/gradle --version | grep Gradle
Gradle 2.0

robert@pferdeapfel:~/prj> /usr/local/gradle-2.0/bin/gradle -i compileJava

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':compileAcctJava'.
> Cannot convert the provided notation to a File or URI: acct Java source.
  The following types/formats are supported:
    - A String or CharSequence path, e.g 'src/main/java' or '/usr/include'
    - A String or CharSequence URI, e.g 'file:/usr/include'
    - A File instance.
    - A URI or URL instance.

* 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.676 secs

我已经按照http://www.cradle.org/docs/current/userguide/java_plugin.html#sec%3asource_sets中的描述定义了源集,这样做是因为我的项目没有遵循默认的项目布局。

sourceSets {
    ...
    acct {
        java {
            srcDir "src"
            srcDirs("src") {
                include "my/program/some/package/Acct.java"
            }
        }
    }
    ...
}

我确实定义了一些依赖项,但没有定义acct;这只是一个简单的枚举,用作代码生成的基础。它没有依赖关系。即使我像下面这样添加了一个伪依赖项,我也会得到同样的错误。

dependencies {
    ...
    acctCompile junit
    ...
}

我该如何解决这个问题,或者我该如何找出更多关于到底是什么出了问题的信息?

我觉得Gradle的--debug--stacktrace的输出一点帮助都没有。

共有1个答案

胡越
2023-03-14

没有srcdirs(“src”){include“my/program/some/package/acct.java”}这样的符号。尝试:

sourceSets {
    acct {
        java {
            srcDirs = ["src"] // replaces default rather than adding another dir
            include "my/program/some/package/Acct.java"
        }
    }
}
 类似资料: