Hi Valerio,

Thank you for taking on the task of updating this task!

Several important changes I would make to this task are as follows:

1. Change line 456 from "break;" to "continue;" to fix the fact that the task 
will skip out of scanning the rest of the directory if a non-jsp file is found. 
 This is a logged bug.

2. Remove the requirement to set a package; it's default value is 
"jsp_servlet", so if it isn't set, use that.

3. If the build fails, throw a BuildException in line 320.  That will trigger 
the target/project to display a proper "build failed" message.

4. The biggest change I would make would be to not use the args array and 
instead use the newer createArg command.  The reasons for this are the 
space-delimited list approach is deprecated, and the createArg method properly 
handles files with spaces in the path.

Here's a block of code that goes in execute to demonstrate:

        helperTask.setClassname("weblogic.jspc");
        helperTask.setTaskName(getTaskName());

        scanDir(files);
        log("Compiling " + filesToDo.size() + " JSP files");
        boolean buildFailed = false;
        
        Iterator fi = filesToDo.iterator();
        while (fi.hasNext())
        {
            File file = new File(sourceDirectory, (String) fi.next());
            helperTask.clearArgs();
            
            helperTask.setClasspath(compileClasspath);
            
            helperTask.createArg().setValue("-d");
            helperTask.createArg().setFile(destinationDirectory);

            helperTask.createArg().setValue("-docroot");
            helperTask.createArg().setFile(sourceDirectory);

//            helperTask.createArg().setValue("-compileAll");

            helperTask.createArg().setValue("-webapp");
            helperTask.createArg().setFile(sourceDirectory);
        
//            helperTask.createArg().setValue("-keepgenerated");
        
//            helperTask.createArg().setValue("-verbose");

//            helperTask.createArg().setValue("-skipJavac");

//            helperTask.createArg().setValue("-verboseJavac");

            helperTask.createArg().setValue("-compilerclass");
            helperTask.createArg().setValue("com.sun.tools.javac.Main");
        
//            helperTask.createArg().setValue("-classpath");
//            helperTask.createArg().setPath(compileClasspath);
        
            helperTask.createArg().setFile(file);
            
                if (helperTask.executeJava() != 0)
            {
                log("jspc failed to compile", Project.MSG_ERR);
                buildFailed = true;
            }
        }

        if (buildFailed)
            throw new BuildException("Build failed");

Good luck, and if I can help in any way (besides submitting :) ) let me know!

____________________________________________

Matt Bishop
bea Systems
999 North Northlake Way
Seattle, WA  98103

206.926.2924 - phone

http://www.bea.com


-----Original Message-----
From: Valerio Gentile [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 09, 2002 9:50 AM
To: [EMAIL PROTECTED]
Subject: wljspc contribution


Hello everyone.
 
I had to modify a little the wljspc task (under 
org\apache\tools\ant\taskdefs\optional\jsp). I added three optional parameters: 
docroot, compiler and compilerclass, and I tested succesfully with wl 5.1
 
I attach the class code to this msg. I'd like to know other members' opinion 
about the code I modified... maybe my code will be appreciated.. :-D so much to 
be included in future Ant releases.
 
Thanks' a lot
Valerio Gentile
 
 

Reply via email to