[EMAIL PROTECTED] wrote:
> The answer here is either add an extra constructor or try splitting the
> javac steps up into more separate compiles.  That's why the compile target
> has so many separate <javac ... > tasks, for JDK 1.1.8.  If this is truly a
> small circular dep. that 1.1.8 can't figure out, we may be stuck though.

I didn't want to change the build.xml file without talking to someone
first.  The fix here would be to use the same build file but add a
'target="1.1"' attribute onto each javac element.  For added
flexibility, the actual target version could also be set by a build
property which defaulted to 1.1.  This attribute is ignored when
compiling under the javac 1.1.x or 1.2.x compilers so it wouldn't hurt
anything.

> 
> >Also, the latest change to NamespaceSupport2 which invokes a method on
> >an anonymous class also seems to confuse the JDK 1.1.8 compiler.
> 
> This was Joe; he was asking me about this.  This could be a more serious
> problem.

Well, as I said, I got it to work with the 1.3 javac using the "-target
1.1" option.
> 
> >My solution was to use the Java 1.3 compiler with the "-target"
> >argument.  However, I noticed that we haven't used that in our
> >build.xml.  So, since I already use an Ant BuildListener to suppress
> >stuff in the CVS directories I just added a call to setTarget in there.
> 
> Rowf? (picture a dog with one ear cocked looking quizzical) I guess I
> haven't played with 1.3 enough yet.  Why do we explicitly need this?

Because the "-target 1.1" option verifies that the build will run on JDK
1.1.  Without it, the compiler assumes you'll be running under the same
JDK as the compiler.

> Also,
> let's make sure that our Ant build file is still compatible with 1.1.8 and
> at least 1.2.

As far as I can tell, adding the target attribute to the javac element
would not injure compatability.  It is simply ignored when Ant is
compiling under a 1.1.x JDK.

> Hey, could you send out how you setup your BuildListener so
> we can play with it?  And doesn't Ant already ignore the CVS directories?
> (sorry, I'm starting to blather since it's too hot at home...)

Back when I started with Xalan, the default Ant exclude was
("**/CVS/*").  This excluded anything in the CVS directory itself but
did -not- exclude (ie included) stuff in a directory below the CVS
directory.  In particular, since I use "cvs edit" to un-write-protect my
files when I'm ready to work on them, this creates a copy of the
original file in ..../CVS/base/xxxx.java.  The default Ant did not
exclude this and it was confusing javac.  I see that Ant has since
changed the default exclude to "**/CVS/**" which is what I was doing in
my build listener.  They have also since added CVS backup files
("**/.#*") which I also had to do.

So, it seems that the original reasons for my BuildListener are now
moot.  However, I didn't know that before today so "thanks".  It did
come in handy for adding the -target attribute though.  If we add that
into build.xml, I can get rid of my BuildListener altogether.

In any event, I've attached the BuildListener as you requested just so
that you can have a look.

Gary
import java.util.EventListener;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.PatternSet;
import org.apache.tools.ant.taskdefs.Javac;

/**
 *  Classes that implement this interface will be notified when
 *  things happend during a build.
 *
 *  @see BuildEvent
 *  @see Project#addBuildListener(BuildListener)
 */

public class GaryListener implements BuildListener {

    /**
     *  Fired before any targets are started.
     */
    public void buildStarted(BuildEvent event) {}

    /**
     *  Fired after the last target has finished. This event
     *  will still be thrown if an error occured during the build.
     *
     *  @see BuildEvent#getException()
     */
    public void buildFinished(BuildEvent event) {}

    /**
     *  Fired when a target is started.
     *
     *  @see BuildEvent#getTarget()
     */
    public void targetStarted(BuildEvent event) {}

    /**
     *  Fired when a target has finished. This event will
     *  still be thrown if an error occured during the build.
     *
     *  @see BuildEvent#getException()
     */
    public void targetFinished(BuildEvent event) {}

    /**
     *  Fired when a task is started.
     *
     *  @see BuildEvent#getTask()
     */
    public void taskStarted(BuildEvent event) {
      Task myTask = event.getTask();
      if ((myTask != null) && myTask.getTaskName().equals("javac")) {
        PatternSet.NameEntry myExclude = ((Javac) myTask).createExclude();
        myExclude.setName("**/CVS/Base/**");
        myExclude = ((Javac) myTask).createExclude();
        myExclude.setName("**/.#*");
        ((Javac) myTask).setTarget("1.1");
        System.err.println("GaryListener suppressed files from CVS/Base directories.");
      }
    }

    /**
     *  Fired when a task has finished. This event will still
     *  be throw if an error occured during the build.
     *
     *  @see BuildEvent#getException()
     */
    public void taskFinished(BuildEvent event) {}

    /**
     *  Fired whenever a message is logged.
     *
     *  @see BuildEvent#getMessage()
     *  @see BuildEvent#getPriority()
     */
    public void messageLogged(BuildEvent event) {}

}

Reply via email to