Gradle 找不到方法 c()
Gradle could not find method c()
我有以下 build.gradle 文件:
apply plugin: 'c'
model {
sources {
c {
source {
srcDir "src/myapi/c"
include "**/*.c"
}
}
}
platforms {
x86 {
architecture "x86"
}
}
components {
myapi(NativeLibrarySpec) {
targetPlatform "x86"
}
}
}
gradle myapiSharedLibrary
或 gradle tasks
或 gradle components
,所有任务都失败并显示
Exception thrown while executing model rule: sources { ... } @ build.gradle line 5, column 2
Could not find method c() for arguments [build_1nkbkdtma2ngpuhlkja2lnmoa$_run_closure1$_closure2$_closure5@2cefd5e6] on [] of type org.gradle.language.base.internal.DefaultProjectSourceSet.
gradle docs 中的例子对我来说似乎不太适用。
还是我做错了什么?
Gradle版本为
> gradle --version
------------------------------------------------------------
Gradle 4.3.1
------------------------------------------------------------
Build time: 2017-11-08 08:59:45 UTC
Revision: e4f4804807ef7c2829da51877861ff06e07e006d
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_51 (Oracle Corporation 25.51-b03)
OS: Windows 7 6.1 amd64
真正解决问题的方法是将 sources
移动到 components
块中,如下所示:
components {
myapi(NativeLibrarySpec) {
targetPlatform "x86"
sources {
c {
source {
srcDir "src/myapi/c"
include "**/*.c"
}
}
}
}
}
我有以下 build.gradle 文件:
apply plugin: 'c'
model {
sources {
c {
source {
srcDir "src/myapi/c"
include "**/*.c"
}
}
}
platforms {
x86 {
architecture "x86"
}
}
components {
myapi(NativeLibrarySpec) {
targetPlatform "x86"
}
}
}
gradle myapiSharedLibrary
或 gradle tasks
或 gradle components
,所有任务都失败并显示
Exception thrown while executing model rule: sources { ... } @ build.gradle line 5, column 2
Could not find method c() for arguments [build_1nkbkdtma2ngpuhlkja2lnmoa$_run_closure1$_closure2$_closure5@2cefd5e6] on [] of type org.gradle.language.base.internal.DefaultProjectSourceSet.
gradle docs 中的例子对我来说似乎不太适用。
还是我做错了什么?
Gradle版本为
> gradle --version
------------------------------------------------------------
Gradle 4.3.1
------------------------------------------------------------
Build time: 2017-11-08 08:59:45 UTC
Revision: e4f4804807ef7c2829da51877861ff06e07e006d
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_51 (Oracle Corporation 25.51-b03)
OS: Windows 7 6.1 amd64
真正解决问题的方法是将 sources
移动到 components
块中,如下所示:
components {
myapi(NativeLibrarySpec) {
targetPlatform "x86"
sources {
c {
source {
srcDir "src/myapi/c"
include "**/*.c"
}
}
}
}
}