incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlosv...@apache.org
Subject svn commit: r956073 - in /incubator/bval/sandbox/jsr303-impl-bench: pom.xml src/main/java/org/apache/bval/bench/Config.java src/main/java/org/apache/bval/bench/Generator.java
Date Fri, 18 Jun 2010 18:07:05 GMT
Author: carlosvara
Date: Fri Jun 18 18:07:04 2010
New Revision: 956073

URL: http://svn.apache.org/viewvc?rev=956073&view=rev
Log:
Integrated beangraph generation into maven lifecycle and Config reads system properties

Modified:
    incubator/bval/sandbox/jsr303-impl-bench/pom.xml
    incubator/bval/sandbox/jsr303-impl-bench/src/main/java/org/apache/bval/bench/Config.java
    incubator/bval/sandbox/jsr303-impl-bench/src/main/java/org/apache/bval/bench/Generator.java

Modified: incubator/bval/sandbox/jsr303-impl-bench/pom.xml
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/jsr303-impl-bench/pom.xml?rev=956073&r1=956072&r2=956073&view=diff
==============================================================================
--- incubator/bval/sandbox/jsr303-impl-bench/pom.xml (original)
+++ incubator/bval/sandbox/jsr303-impl-bench/pom.xml Fri Jun 18 18:07:04 2010
@@ -98,7 +98,7 @@
                         <id>add-source</id>
                         <phase>generate-sources</phase>
                         <goals>
-                            <goal>add-source</goal>
+                            <goal>add-test-source</goal>
                         </goals>
                         <configuration>
                             <sources>
@@ -108,6 +108,23 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <version>1.1</version>
+                <executions>
+                    <execution>
+                        <id>create-beangraph</id>
+                        <phase>generate-test-sources</phase>
+                        <goals>
+                            <goal>java</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <mainClass>org.apache.bval.bench.Generator</mainClass>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 

Modified: incubator/bval/sandbox/jsr303-impl-bench/src/main/java/org/apache/bval/bench/Config.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/jsr303-impl-bench/src/main/java/org/apache/bval/bench/Config.java?rev=956073&r1=956072&r2=956073&view=diff
==============================================================================
--- incubator/bval/sandbox/jsr303-impl-bench/src/main/java/org/apache/bval/bench/Config.java
(original)
+++ incubator/bval/sandbox/jsr303-impl-bench/src/main/java/org/apache/bval/bench/Config.java
Fri Jun 18 18:07:04 2010
@@ -55,6 +55,9 @@ public enum Config {
         r = new Random(new Long(p.getProperty("generator.rnd.seed")));
     }
 
+    /**
+     * @return A unique sequence number.
+     */
     public int nextUniqueNum() {
         return uniqueSeq++;
     }
@@ -182,6 +185,13 @@ public enum Config {
     public boolean shouldInherit() {
         return r.nextDouble() < new Double(p.getProperty("generator.inheritanceratio"));
     }
+    
+    /**
+     * Prints in {@link System.out} the generator properties.
+     */
+    public void printProperties() {
+        p.list(System.out);
+    }
 
 
     /**
@@ -195,6 +205,7 @@ public enum Config {
         }
         Properties tmp = loadDefaultProperties(cl);
         tmp = overrideDefaultProperties(cl, tmp);
+        tmp = overrideWithSystemProperties(tmp);
         return tmp;
     }
 
@@ -246,4 +257,21 @@ public enum Config {
         return userProperties;
     }
 
+    /**
+     * Overrides the read properties with the system set properties.
+     * 
+     * @param prop
+     *            A properties object holding the read properties.
+     * @return A properties object with the system set properties overriden.
+     */
+    private Properties overrideWithSystemProperties(Properties prop) {
+        Properties ret = new Properties(prop);
+        for ( String key : prop.stringPropertyNames() ) {
+            if ( System.getProperty(key) != null ) {
+                ret.setProperty(key, System.getProperty(key));
+            }
+        }
+        return ret;
+    }
+
 }

Modified: incubator/bval/sandbox/jsr303-impl-bench/src/main/java/org/apache/bval/bench/Generator.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/jsr303-impl-bench/src/main/java/org/apache/bval/bench/Generator.java?rev=956073&r1=956072&r2=956073&view=diff
==============================================================================
--- incubator/bval/sandbox/jsr303-impl-bench/src/main/java/org/apache/bval/bench/Generator.java
(original)
+++ incubator/bval/sandbox/jsr303-impl-bench/src/main/java/org/apache/bval/bench/Generator.java
Fri Jun 18 18:07:04 2010
@@ -20,6 +20,7 @@ package org.apache.bval.bench;
 
 import java.io.File;
 import java.io.IOException;
+import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.List;
 import org.apache.bval.bench.jsr303.Jsr303Annotator;
@@ -95,7 +96,7 @@ public class Generator {
         // Create the .java files
         File file = new File(Config.CFG.getOutputDir());
         file.mkdirs();
-        cm.build(file);
+        cm.build(file, (PrintStream)null);
 
     }
 
@@ -151,9 +152,10 @@ public class Generator {
 
 
     public static void main(String[] args) throws IOException, JClassAlreadyExistsException
{
-        System.out.println("Starting generation...");
+        System.out.println("Starting bean graph generation...");
+        Config.CFG.printProperties();
         generateBeans();
-        System.out.println("Beans generated!");
+        System.out.println("Generated " + Config.CFG.getNumBeans() + " beans.");
     }
 
 }



Mime
View raw message