0

I have large jar task in my ant build file. But I don't want to execute it immediately. I want to add some filesets to the task and only than execute it. I don't want to define the jar task completely in the script. How to do that?

I've tried following approach from the script:

project.addBuildListener(new BuildListener() {  
    ...
    void    taskStarted(BuildEvent event){
        Jar j1 = (Jar)event.getTask();      
        ...//adjustments here                   
    }
});

But it gives: "java.lang.ClassCastException: Cannot cast org.apache.tools.ant.UnknownElement to org.apache.tools.ant.taskdefs.Jar"

alehro
  • 2,198
  • 2
  • 25
  • 41
  • Check the includes and includesFile attribute of jar task to see if you can use beanshell script to generate a property or a file that specifies the files you want the jar task to include. Also the fileset task can have nested "include" task as well as an "includes" attribute. – Dante WWWW Oct 28 '11 at 03:08
  • @coolcfan Jar task here is for example. It could be any other task as well. – alehro Oct 28 '11 at 14:09
  • Could MacroDef task meet your requirement? Or you want to add nested elements to the tasks from the commandline? – Dante WWWW Nov 01 '11 at 06:40

0 Answers0