Ant 目标依赖关系树查看器

发布于 2024-12-07 16:59:10 字数 175 浏览 0 评论 0原文

是否有一个软件(或 Eclipse 插件)

在给定目标的情况下允许我将目标依赖项视为树?

该树不需要是图形的,可以是基于文本的——只是一个可以帮助我遍历某人的 ant 文件网格来调试它们的工具。

不需要是 Eclipse 插件。然而,当单击一个节点时,将该目标的源代码扔到编辑器上会很好。

IS there a piece of software (or an eclipse plug-in) which,

given a target, would allow me to view the target dependency as a tree?

The tree does not need to be graphical, could be text based - just a tool that would help me traverse thro someone's mesh of ant files to debug them.

Does not need to be an Eclipse plug-in. However, would be nice when a node is clicked would throw the source of that target onto an editor.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

疯狂的代价 2024-12-14 16:59:10

我想要同样的东西,但是,像 David 一样,我最终只写了一些代码(Python):

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)

I wanted the same thing, but, like David, I ended up just writing a bit of code (Python):

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)
醉梦枕江山 2024-12-14 16:59:10

类似于问题 Eclipse 中的 ant 调试

根据Apache的ANT手册,您可以从-projecthelp开始代码>选项。之后可能会更加困难,因为各个目标可能具有交叉依赖性,因此根本不可能将层次结构表示为树。

您可以修改build.xml来检测环境变量,例如NO_PRINT,它在每个项目目标中进行测试,如果找到,则仅打印出项目名称而不打印其他内容。该项目的依赖关系将保留并允许 ANT 遍历树并生成将触及的不同目标的打印输出。

Similar to question ant debugging in Eclipse.

Based on Apache's ANT manual, you can start with the -projecthelp option. It might be more difficult after that because the various targets may have cross-dependencies and thus be impossible to represent the hierarchy as a tree at all.

You could modify the build.xml to detect an environment variable, e.g. NO_PRINT which is tested in each project target and if found, only print out the project name and nothing else. The depencies for the project would remain and allow ANT to walk the tree and produce a printout of the different targets that would get touched.

寒江雪… 2024-12-14 16:59:10

我创建了一个 java 命令行工具,可以分析 ant 构建脚本和目标之间的依赖关系。
我正在分析一个调用其他构建脚本的 ant 脚本,它们总共有超过 1000 个 ant 目标。工具是摆脱困境的唯一方法。它可以打印 ant 目标依赖树并标记未使用的目标。
https://github.com/kunterbunt2/antanalyzer
也许这就是您正在寻找的东西。
如果自述文件不够好,请随时提出问题。
还有一些单元测试来展示该工具。

I created a java command line tool that can analyze ant build scrips and the dependencies between the targets.
I am analyzing an ant script that calls other build scripts adn in total they have over 1000 ant targets. A tool was the only way to get through that mess. It can print ant target dependency trees and mark unused targets.
https://github.com/kunterbunt2/antanalyzer
Maybe this is what you where looking for.
Feel free to ask questions in case the readme is nto good enough.
There are also some unit test to showcase the tool.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文