how to create ant listener for specific task

后端 未结 1 1994
梦毁少年i
梦毁少年i 2021-01-24 10:40

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

I would like to introduce findbug checks. One option was to create sin

相关标签:
1条回答
  • 2021-01-24 11:05

    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());
                }
            }
    ..
    
    0 讨论(0)
提交回复
热议问题