Ant任务依赖图形化工具

简介:

When inheriting an Ant build file to maintain, it is useful to get a feel for the flow and structure. Sketching the dependencies between targets is a useful way to do this. While it is time consuming to do so by hand, there are a number of tools to help.

I tried three different tools to generate the output. All of them generate a .dot file which needs to be run through the Graphviz tool to be converted to a useful format. Graphviz can covert to all image formats among many others. Each tool is described below with an example of how to call it. I've also included two sample images: from our build script to Pick Winners in the weekly book/software promotion and a contrived example designed to show how antCall and forEach work.

  1. Ant2Dot - Ant2Dot is an XSLT file that converts your Ant build file into a .dot file. Each target becomes a rectangle and dependencies between targets are shown. The instructions for using it are a bit old and only apply to Java 1.3 and 1.4. They don't work on Java 5/6 without modification. The website lists a "to do" for adding support for Ant 1.6's import and subant features. Similarly, 1.7 features aren't supported yet. Ant2Dot is good for simple build files, but doesn't scale up to handle use advanced features. Running was as simple as downloading a stylesheet and running the command:
    C:\j2re1.4.2_03\bin\java org.apache.xalan.xslt.Process
    -IN build.xml -XSL ant2dot.xsl -OUT build.dot
    Output of JavaRanch's book promotion pick a winner dependency structure and a contrived sample:
  2. Vizant - Vizant is a Java library that creates a .dot file by using a SAX parser on your Ant build file. Each target becomes an oval and dependencies between targets are shown. Vizant supports antcalls and allows you to drill down to generate only part of the build tree. You can also drill down to show part of your build tree. Vizant was easy to use. I wanted the dependency ordering so continued looking for a library to meet my needs. In order to run Vizant, you need to download a jar containing the source and build it using Ant. They provide the build.xml to do so. Since this is a library for Ant documentation, it is reasonable to assume people know how to run Ant. You also call it through a simple Ant build file:
    <?xml version="1.0"?>
    <project name="Vizant" basedir="." default="vizant">
    <taskdef name="vizant"
    classname="net.sourceforge.vizant.Vizant"
    classpath="build/vizant.jar" />

    <target name="vizant">
    <vizant antfile="build.xml" outfile="build.dot" uniqueref="true" />
    </target>

    </project>
    Output of JavaRanch's book promotion pick a winner dependency structure and a contrived sample:
  3. Grand - Grand is also a Java library that creates a .dot file. It takes a different approach and actually creates the Ant directory structure using Ant's Java libraries. It can support anything in your classpath including ant-contrib and Ant 1.6's import feature. The logic doesn't capture the subtleties of Ant-Contrib like the forEach loop though. The graph is a bit more detailed. The default target is a yellow hexagon. Targets with a description are marked in blue so you can show entry points. The remaining targets are shown as ovals. You can also drill down to show part of your build tree. You can use a Grand UI tool instead of the dot file, but I wasn't able to get the UI. Like Ant2Dot, dependencies are numbered. Grand was as easy to use as Vizant. They provide you with a jar for download. You call it through a simple Ant build file adding any other jars used to the classpath:
    <?xml version="1.0"?>
    <project name="Grand" basedir="." default="grand">

    <typedef resource="net/ggtools/grand/antlib.xml" classpath="grand.jar" />

    <target name="grand">
    <grand output="grand-build.dot" buildfile="build.xml" />
    </target>

    </project>
    Output of JavaRanch's book promotion pick a winner dependency structure and a contrived sample:
Comparison of visualization tools
Tool Shows dependency ordering Flags default target Flags main targets
Ant2Dot Yes Yes No
Vizant No No No
Grand Yes Yes Yes

本文转自博客园zhyiwww 的博客,原文链接:http://www.blogjava.net/zhyiwww/,如需转载请自行联系原博主。

目录
相关文章
|
5月前
|
Python
Python 项目及依赖管理工具技术选型
【8月更文挑战第30天】在进行Python项目及依赖管理时,有多种工具可供选择。虚拟环境工具有`virtualenv`和内置的`venv`,可为项目创建独立环境,避免依赖冲突。依赖管理工具有`pip`、`pipenv`和`poetry`,分别用于安装包、管理依赖并确保版本一致性。选型时需考虑项目需求、团队协作、易用性和社区支持等因素。
111 10
Qt-做一个快速打包插件(一键完成项目软件打包)
Qt-做一个快速打包插件(一键完成项目软件打包)
151 0
CTK框架 - 插件依赖关系 - 给插件加上界面
在第一篇文章中吗,我们提到了MANIFEST.MF中有个字段是依赖关系,这次我们来测试一下这个依赖关系:
220 0
|
前端开发 JavaScript
nrm轻松管理NPM注册表的工具与.npmrc定制化项目的依赖管理
NPM 是前端开发中一个不可或缺的工具,用于管理和安装各种依赖包。但是,有时候我们需要从不同的 NPM 注册表中安装包,例如,从 `npmjs.org`、`淘宝镜像`或`私有注册表`中安装。这时候,一个方便的管理工具就显得非常重要了,而 nrm 就是这样一个工具。
247 0
jira学习案例30-安装和使用ant库2
jira学习案例30-安装和使用ant库2
94 0
jira学习案例30-安装和使用ant库2
jira学习案例29-安装和使用ant库1
jira学习案例29-安装和使用ant库1
103 0
jira学习案例29-安装和使用ant库1
|
数据可视化 NoSQL 关系型数据库
4-TDengine图形化管理工具TDengineGUI与IDEA插件
4-TDengine图形化管理工具TDengineGUI与IDEA插件
3136 0
4-TDengine图形化管理工具TDengineGUI与IDEA插件
|
XML IDE Java
【Groovy】Gradle 构建工具 ( 自动下载并配置构建环境 | 提供 API 扩展与开发工具集成 | 内置 Maven 和 Ivy 依赖管理 | 使用 Groovy 编写构建脚本 )
【Groovy】Gradle 构建工具 ( 自动下载并配置构建环境 | 提供 API 扩展与开发工具集成 | 内置 Maven 和 Ivy 依赖管理 | 使用 Groovy 编写构建脚本 )
309 0
【Groovy】Gradle 构建工具 ( 自动下载并配置构建环境 | 提供 API 扩展与开发工具集成 | 内置 Maven 和 Ivy 依赖管理 | 使用 Groovy 编写构建脚本 )
|
缓存 IDE Java
已经使用ant的项目如何利用maven来管理依赖
已经使用ant的项目如何利用maven来管理依赖