gpt4 book ai didi

gradle - 获得两项任务来应用插件gradle

转载 作者:行者123 更新时间:2023-12-03 05:12:16 24 4
gpt4 key购买 nike

有没有办法在gradle中有两个任务并且都在插件中返回正确的值设置参数

我有:

Build.gradle

apply plugin: 'gradle.plugin'

task FirstTask(type: com.nav.Coding){
param.dictFile = file ("${projectDir}/src/main/resources/customized_struct.xml")
param.outputDirectory = file("${buildDir}/generated/"
}

task SecondTask(type: com.nav.Coding){
param.dictFile = file("${projectDir}/src/main/resources/customized_struct_two.xml")
param.outputDirectory = file("${buildDir}/generated/"
}

出于某种原因,在将参数设置为JVM并处理自定义插件时,我的输出仅采用第二个 dictFile,而不采用第一个。

命令输出

$ gradle -q FirstTask SecondTask


:com:nav:Coding:FirstTask
Processing C:\dev\src\main\resources\customized_struct_two.xml
This is my output dictFile C:\dev\src\main\resources\customized_struct_two.xml
This is my output outputDirectory C:\dev\build\generated

:com:nav:Coding:SecondTask
Processing C:\dev\src\main\resources\customized_struct_two.xml
This is my output dictFile C:\dev\src\main\resources\customized_struct_two.xml
This is my output outputDirectiory C:\dev\build\generated

BUILD SUCCESSFUL

Total time: 12.79 secs

最佳答案

我相信您会因为将逻辑置于configuration阶段而不是execution阶段而犯错。我相信你想:

task FirstTask(type: com.nav.Coding){
doFirst {
param.dictFile = file ("${projectDir}/src/main/resources/customized_struct.xml")
param.outputDirectory = file("${buildDir}/generated/"
}
}

task SecondTask(type: com.nav.Coding){
doFirst {
param.dictFile = file("${projectDir}/src/main/resources/customized_struct_two.xml")
param.outputDirectory = file("${buildDir}/generated/"
}
}

我觉得这很奇怪
  • param来自哪里?
  • 为什么dictFile任务上没有outputDirectorycom.nav.Coding属性?
  • 关于gradle - 获得两项任务来应用插件gradle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43473823/

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