creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1361683 - in /creadur/whisker/trunk: apache-whisker-plugin4maven/src/it/minimal/ apache-whisker-velocity/src/main/java/org/apache/creadur/whisker/out/velocity/ apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/
Date Sun, 15 Jul 2012 10:47:14 GMT
Author: rdonkin
Date: Sun Jul 15 10:47:14 2012
New Revision: 1361683

URL: http://svn.apache.org/viewvc?rev=1361683&view=rev
Log:
Only generate NOTICE when required.

Modified:
    creadur/whisker/trunk/apache-whisker-plugin4maven/src/it/minimal/verify.bsh
    creadur/whisker/trunk/apache-whisker-velocity/src/main/java/org/apache/creadur/whisker/out/velocity/VelocityReports.java
    creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestNoticeGeneration.java

Modified: creadur/whisker/trunk/apache-whisker-plugin4maven/src/it/minimal/verify.bsh
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-plugin4maven/src/it/minimal/verify.bsh?rev=1361683&r1=1361682&r2=1361683&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-plugin4maven/src/it/minimal/verify.bsh (original)
+++ creadur/whisker/trunk/apache-whisker-plugin4maven/src/it/minimal/verify.bsh Sun Jul 15
10:47:14 2012
@@ -23,7 +23,7 @@ try {
     File license = new File(basedir, "target/LICENSE");
     File notice = new File(basedir, "target/NOTICE");
     
-    return license.exists() && notice.exists();    
+    return license.exists() && !notice.exists();    
 
 } catch (Throwable t) {
     t.printStackTrace();

Modified: creadur/whisker/trunk/apache-whisker-velocity/src/main/java/org/apache/creadur/whisker/out/velocity/VelocityReports.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-velocity/src/main/java/org/apache/creadur/whisker/out/velocity/VelocityReports.java?rev=1361683&r1=1361682&r2=1361683&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-velocity/src/main/java/org/apache/creadur/whisker/out/velocity/VelocityReports.java
(original)
+++ creadur/whisker/trunk/apache-whisker-velocity/src/main/java/org/apache/creadur/whisker/out/velocity/VelocityReports.java
Sun Jul 15 10:47:14 2012
@@ -19,7 +19,9 @@
 package org.apache.creadur.whisker.out.velocity;
 
 import java.io.Writer;
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
@@ -168,7 +170,21 @@ public class VelocityReports implements 
      * @throws Exception when generation fails
      */
     public final void generate(final Descriptor work) throws Exception {
-        merge(PRODUCTS_THAT_GENERATE_LICENSING_MATERIALS, context(work));
+        final List<Product> products = new ArrayList<Product>();
+        for (Product product: PRODUCTS_THAT_GENERATE_LICENSING_MATERIALS) {
+            switch (product) {
+                case NOTICE:
+                    if (!work.isNoticeRequired()) {
+                        break;
+                    }
+                default:
+                    products.add(product);
+            }
+                
+                
+        }
+        final Product[] pruductArray = new Product[products.size()]; 
+        merge(products.toArray(pruductArray), context(work));
     }
 
     /**

Modified: creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestNoticeGeneration.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestNoticeGeneration.java?rev=1361683&r1=1361682&r2=1361683&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestNoticeGeneration.java
(original)
+++ creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestNoticeGeneration.java
Sun Jul 15 10:47:14 2012
@@ -68,15 +68,14 @@ public class TestNoticeGeneration extend
         assertEquals("When no third party notices, expect that only the primary notice is
output", primaryNotice, writerFactory.firstOutputFor(Result.NOTICE).trim());
     }
     
-    public void testThatOutputIsEmptyWhenThereAreNoNotices() throws Exception {
+    public void testThatNoticeOutputIsSkippedWhenThereAreNoNotices() throws Exception {
         Descriptor work = 
                 new Descriptor(primaryLicense, primaryOrg,  "", 
                         licenses, notices, organisations, contents);
         
         subject.generate(work, writerFactory);
         
-        assertEquals("Only one request for NOTICE writer", 1, writerFactory.requestsFor(Result.NOTICE));
-        assertEquals("When no notices, expect that output is empty", "", writerFactory.firstOutputFor(Result.NOTICE));
+        assertEquals("No requests for NOTICE writer", 0, writerFactory.requestsFor(Result.NOTICE));
     }
 
 }



Mime
View raw message