2011-10-03 95 views
8

IS有一段軟件(或Eclipse插件),其Ant目標依賴關係樹觀察者

給定的目標,將允許我查看目標依賴性爲樹?

該樹不需要是圖形化的,可以是基於文本的 - 只是一個工具,它可以幫助我遍歷某人的螞蟻文件網格來調試它們。

不需要成爲Eclipse插件。然而,單擊節點會將該目標的來源放到編輯器上會很好。

回答

4

與問題ant debugging in Eclipse類似。

根據Apache's ANT manual,您可以從-projecthelp選項開始。這之後可能會更加困難,因爲各種目標可能具有交叉依賴性,因此無法將分層結構完全表示爲樹。

您可以修改build.xml以檢測環境變量,例如,在每個項目目標中測試的NO_PRINT,如果找到,只打印出項目名稱而沒有其他內容。該項目的依賴將保持不變,並允許ANT走樹併產生將被觸摸的不同目標的打印輸出。

+1

是公平的,圓形的依賴關係可以用方法一樣進行處理perl的數據轉儲器處理循環引用,只是指向第一個命名事件。這實際上應該是一個簡單的任務,並建立在螞蟻。 –

4

我想同樣的事情,但是,像大衛,我最終只是寫一些代碼(蟒蛇):

from xml.etree import ElementTree 

build_file_path = r'/path/to/build.xml' 
root = ElementTree.parse(build_file_path) 

# target name to list of names of dependencies 
target_deps = {} 

for t in root.iter('target'): 
    if 'depends' in t.attrib: 
    deps = [d.strip() for d in t.attrib['depends'].split(',')] 
    else: 
    deps = [] 
    name = t.attrib['name'] 
    target_deps[name] = deps 

def print_target(target, depth=0): 
    indent = ' ' * depth 
    print indent + target 
    for dep in target_deps[target]: 
    print_target(dep, depth+1) 

for t in target_deps: 
    print 
    print_target(t) 
+0

我的build.xml包含另一個,所以我添加了一個檢查:if target in target_deps:to print_target – TimP