如何为特定任务蚂蚁监听器 [英] how to create ant listener for specific task

查看:146
本文介绍了如何为特定任务蚂蚁监听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经在我们的应用中约80罐。所有正在使用javac任务和jar任务蚂蚁创建的。

We have around 80 jars in our applications. All are created using javac task and jar task in ant.

我想向大家介绍findbug检查。一种选择是建立单一findbug检查蚂蚁的项目。这所有的罐子,在它定义的所有源路径。这工作 - 需要很大的空间。结果分析得不是很直截了当。有数以千计的警告开始。

I would like to introduce findbug checks. One option was to create single findbug check ant project. This has all jars , all source paths defined in it. This works -- require lot of space. Analysis of result too not very straight forward. There are thousands of warnings to start with.

我正在考虑的一个选择是与javac任务蚂蚁,提取源代码和类特殊的位置运行监听器蚂蚁,叫findbug任务与源和类文件的信息。任何其他方式引进findbug到一个大项目。

One option I am considering is to run ant with special listener on javac task ant , extract source and class location, call findbug task with source and class file information. Any other way introduce findbug to a large project.

推荐答案

调整taskFinished()...精对我的使用情况。

tweaked taskFinished()... Fine for my usage.

public class JavacListener implements BuildListener 

     public void taskFinished(BuildEvent be) {

            if ( be.getTask() instanceof UnknownElement ) {
                UnknownElement ue= (UnknownElement) be.getTask();
                ue.maybeConfigure();

                if ( ue.getTask() instanceof Javac ) {
                Javac task = (Javac)ue.getTask();
                    final Path sourcepath = task.getSrcdir();
                    FindBugsTask fbtask = new FindBugsTask();
                    System.out.println ("Trying FindBugs");
                    fbtask.setSourcePath(sourcepath);
                    fbtask.setAuxClasspath(task.getClasspath());
                    Path destPath = new Path( task.getProject() );
                    destPath.setPath(task.getDestdir().getAbsolutePath());
                    fbtask.setAuxAnalyzepath(destPath);
                    fbtask.setOutputFile(getFileName(task.getProject()));
                    fbtask.setProject(task.getProject());

                    fbtask.setHome(new File("C:\\apps\\findbugs-1.3.0"));
                    fbtask.execute();
                }

            } else {
                System.out.println(be.getTask().getClass().getName());
                System.out.println(be.getTask().getTaskName());
            }
        }
..

这篇关于如何为特定任务蚂蚁监听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆