Gradle 链接后复制任务

Gradle 链接后复制任务,gradle,build.gradle,Gradle,Build.gradle,在为本机可执行文件执行链接之后,我正在尝试执行构建工件的副本。附件是我的build.gradle components { all { binaries.withType(SharedLibraryBinarySpec) { buildable = false } binaries.withType(NativeExecutableBinarySpec) {

在为本机可执行文件执行链接之后,我正在尝试执行构建工件的副本。附件是我的
build.gradle

    components {
        all {
            binaries.withType(SharedLibraryBinarySpec) {
                buildable = false 
            }
            binaries.withType(NativeExecutableBinarySpec) {
                tasks.withType(LinkExecutable) {        
                    doFirst {
                        outputFile = file("$buildDir/exe/${baseName}/${baseName}.o")
                    }
                    doLast {
                        copy {
                            from (file("$buildDir/exe/${baseName}/"))
                            into "./objs_exe/exe/"
                            include "*.o"
                        }
                    }
                }
            }
        }
    }
我想重命名链接的可执行文件,然后将其复制到其他位置。然而,我得到的错误如下

尝试修改给定给rule model.components的“ComponentSpecContainer”类型的模型元素“components”的关闭视图

这是一个多项目构建,上面的代码是根项目的
build.gradle
的一部分。
doFirst
闭包没有任何问题。此外,我还应用了
c插件