我有以下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
,所有任务均以
执行模型规则时抛出异常:sources {...} @ build.gradle第5行,第2列
找不到类型为org.gradle.language.base.internal.DefaultProjectSourceSet的[]上的参数[build_1nkbkdtma2ngpuhlkja2lnmoa $ _run_closure1 $ _closure2 $ _closure5 @ 2cefd5e6]的方法c()。
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
答案 0 :(得分:0)
实际上解决了这个问题的方法是将sources
移动到components
块中,如下所示:
components {
myapi(NativeLibrarySpec) {
targetPlatform "x86"
sources {
c {
source {
srcDir "src/myapi/c"
include "**/*.c"
}
}
}
}
}