【发布时间】:2010-05-31 17:38:31
【问题描述】:
我有一堆构建耙子的任务。
它们每个都有唯一的输入/输出属性,但我在任务上设置的大多数属性每次都是相同的。目前我正在通过这样的简单重复来做到这一点:
task :buildThisModule => "bin/modules/thisModule.swf"
mxmlc "bin/modules/thisModule.swf" do |t|
t.input = "src/project/modules/ThisModule.as"
t.prop1 = value1
t.prop2 = value2 ... (And many more property=value sets that are the same in each task)
end
task :buildThatModule => "bin/modules/thatModule.swf"
mxmlc "bin/modules/thatModule.swf" do |t|
t.input = "src/project/modules/ThatModule.as"
t.prop1 = value1
t.prop2 = value2 ... (And many more property=value sets that are the same in each task)
end
在我通常的编程空间中,我希望能够将重复任务属性的数量分解为可重用的函数。
这有一个耙类比吗?某种方式我可以有一个单一的功能,在任何任务上设置共享属性?相当于:
task :buildThisModule => "bin/modules/thisModule.swf"
mxmlc "bin/modules/thisModule.swf" do |t|
addCommonTaskParameters(t)
t.input = "src/project/modules/ThisModule.as"
end
task :buildThatModule => "bin/modules/thatModule.swf"
mxmlc "bin/modules/thatModule.swf" do |t|
addCommonTaskParameters(t)
t.input = "src/project/modules/ThatModule.as"
end
谢谢。
======
回复 SR:
谢谢斯蒂芬,
我显然遗漏了一些东西 - 我有:
desc 'Compile run the test harness'
unit :test do |t|
populate_test_task(t)
end
def populate_test_task(t)
t.source_path << "support"
t.prepended_args = '+configname=air -define+=CONFIG::LocalDebug,true'
end
我尝试在任务之后立即定义函数(在此文件中没有命名空间:),并在最后一个任务之后的文件末尾,我得到“未定义的方法 `populate_test_task' for main:对象”——在我看来,它没有找到函数。
我错过了什么?
【问题讨论】: