ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r688732 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/listener/BigProjectLogger.java
Date Mon, 25 Aug 2008 14:23:24 GMT
Author: bodewig
Date: Mon Aug 25 07:23:23 2008
New Revision: 688732

URL: http://svn.apache.org/viewvc?rev=688732&view=rev
Log:
defer self-generated subBuildStarted event until project instance has been configured and
basedir has been set.  PR 45607.

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/listener/BigProjectLogger.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=688732&r1=688731&r2=688732&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Mon Aug 25 07:23:23 2008
@@ -166,6 +166,11 @@
    contained the character '8'.
    Bugzilla Report 45675.
 
+ * If the buildfile's project element didn't contain any basedir
+   attribute, BigProjectLogger would set the project's basedir to the
+   current working directory.
+   Bugzilla Report 45607.
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/listener/BigProjectLogger.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/listener/BigProjectLogger.java?rev=688732&r1=688731&r2=688732&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/listener/BigProjectLogger.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/listener/BigProjectLogger.java Mon Aug 25
07:23:23 2008
@@ -33,7 +33,11 @@
  * @since Ant1.7.1
  */
 
-public class BigProjectLogger extends NoBannerLogger implements SubBuildListener {
+public class BigProjectLogger extends NoBannerLogger
+    implements SubBuildListener {
+
+    private volatile boolean subBuildStartedRaised = false;
+    private final Object subBuildLock = new Object();
 
     /**
      * Header string for the log.
@@ -69,15 +73,24 @@
         return super.getBuildSuccessfulMessage() + TimestampedLogger.SPACER + getTimestamp();
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * @param event
+     */
+    public void targetStarted(BuildEvent event) {
+        maybeRaiseSubBuildStarted(event);
+        super.targetStarted(event);
+    }
 
     /**
      * {@inheritDoc}
      *
      * @param event
      */
-    public void buildStarted(BuildEvent event) {
-        super.buildStarted(event);
-        subBuildStarted(event);
+    public void taskStarted(BuildEvent event) {
+        maybeRaiseSubBuildStarted(event);
+        super.taskStarted(event);
     }
 
     /**
@@ -86,11 +99,22 @@
      * @param event
      */
     public void buildFinished(BuildEvent event) {
+        maybeRaiseSubBuildStarted(event);
         subBuildFinished(event);
         super.buildFinished(event);
     }
 
     /**
+     * {@inheritDoc}
+     *
+     * @param event
+     */
+    public void messageLogged(BuildEvent event) {
+        maybeRaiseSubBuildStarted(event);
+        super.messageLogged(event);
+    }
+
+    /**
      * Override point, extract the target name
      *
      * @param event the event to work on
@@ -173,4 +197,15 @@
         return FOOTER;
     }
 
+    private void maybeRaiseSubBuildStarted(BuildEvent event) {
+        // double checked locking should be OK since the flag is write-once
+        if (!subBuildStartedRaised) {
+            synchronized (subBuildLock) {
+                if (!subBuildStartedRaised) {
+                    subBuildStartedRaised = true;
+                    subBuildStarted(event);
+                }
+            }
+        }
+    }
 }



Mime
View raw message