gpt4 book ai didi

gradle - 我如何在执行另一个任务之前执行Gradle插件任务?

转载 作者:行者123 更新时间:2023-12-03 06:21:45 25 4
gpt4 key购买 nike

我正在使用native-artifacts插件,该插件定义了许多任务,这些任务提取在其他位置(并存储在Nexus / Maven中)构建的依赖项的Nar依赖项。我需要确保在构建二进制文件之前调用了这些任务,否则找不到这些Nars包含的 header 。

我的问题是,如何将系统/插件定义的任务定义为其中一项任务的依存关系?

我想要类似的东西:

binaries.all {binary ->
dependencies {
// this next line is now the same as the plugin-defined task I want to have called before
// before the build takes place
compile "extractNarDeps${binary.name.capitalize()}"
}
}

可悲的是,这没有建立。请问我该如何实现?我有一个名为unitTests的组件,它是一个C++组件,用于创建unitTestsExecutable。我想在调用compileUnitTests之前调用extractNarDepsxxx。

最佳答案

首先,您是否有任何名为binaries的列表?如果是,那么您可以在build.gradle文件中尝试以下类似操作,因为依赖项将在定义的任务之前执行:

dependencies {
binaries.each {binary ->
// this next line is now the same as the plugin-defined task I want to have called before
// before the build takes place
compile "extractNarDeps${binary.name.capitalize()}"
}
}

// Your defined task here

关于gradle - 我如何在执行另一个任务之前执行Gradle插件任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24071270/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com