DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=36256>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=36256

           Summary: Project.executeTarget() doesn't update target task
                    arguments on multiple calls from a Script Task
           Product: Ant
           Version: 1.6.5
          Platform: PC
        OS/Version: Windows 2000
            Status: NEW
          Severity: critical
          Priority: P1
         Component: Optional Tasks
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


I'm having problems using Project.executeTarget() method inside Script Tasks, 
for calling multiple times a target task.

Here's a hypothetical script (it tries to compile 2 Java classes from /src 
to /bin) that generates the problem:
"<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="script_test" default="test">

        <property name="XDOCLET_HOME" value="c:\xdoclet-1.2.3"/>
        <property name="WL_HOME" value="C:\bea\weblogic81"/>
        <property name="JAVA_HOME" value="C:\bea\jdk141_05"/>
        <property name="CLASS_NAME" value=""/>

        <target name="test">
        
                <script language="javascript"> <![CDATA[
                        
                        echo = project.createTask("echo");

                        // Create a fileset
                        fs = project.createDataType("fileset");
                        
                        fs.setDir(new java.io.File(project.getBaseDir()
+"/src"));
                                                
                        fs.setIncludes("**/*.java");

                        // Get the files (array) of that fileset
                        ds = fs.getDirectoryScanner(project);
                        srcFiles = ds.getIncludedFiles();
                        
                        // iterate over that array
                        for (i=0; i<srcFiles.length; i++) {
                        var filename = srcFiles[i].toString();
                                var fileSeparator = java.lang.System.getProperty
("file.separator");
                                
                                echo.setMessage("filename="+filename);
                                echo.execute();
                                
                                var className = filename.substring
(filename.lastIndexOf(fileSeparator)+1,filename.lastIndexOf(".java"));

                                echo.setMessage("className="+className);
                        echo.execute();

                                project.setProperty("CLASS_NAME",className);

                                project.executeTarget("test_target");
                                
                        }
      
                ]]></script>
        
        </target>
        
        <target name="test_target">

                <script language="javascript"> <![CDATA[
                        
                        echo = project.createTask("echo");

                        echo.setMessage("className2="+project.getProperty
("CLASS_NAME"));
                    echo.execute();

                ]]></script>

                <javac srcdir="./src" includes="**/${CLASS_NAME}.java" 
includejavaruntime="false" destdir="./bin" classpath="${WL_HOME}
\server\lib\weblogic.jar;${JAVA_HOME}/jre/lib/rt.jar;${JAVA_HOME}/lib/tools.jar"
/>

        </target>
        
</project>"

I have two Java classes ("test.Test1" and "test.Test2") in the /src dir, but 
the script only compiles the first one.

Here's the script console output:
"Buildfile: build.xml

test:
     [echo] filename=test\Test1.java
     [echo] className=Test1

test_target:
     [echo] className2=Test1
     [echo] ---------------------------------
     [echo] filename=test\Test2.java
     [echo] className=Test2

test_target:
     [echo] className2=Test2
     [echo] ---------------------------------"

As you may see in the console output, the javac task is called twice with the 
same includes value ("**/Test1.java"), because it only compiles the Test1 
class. So the second call, to compile the Test2 class, uses the same value from 
the first call, instead of the second ("**/Test2.java").

The problem may be related to a bind problem in the includes argument from 
javac task, because the script from inside "test_target" task getts the 
correct "CLASS_NAME" property value (className2).

Thanks,
       Andre Kovacs

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to