geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r463539 - in /geronimo/genesis/trunk/plugins/script-maven-plugin/src: main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java site/apt/usage.apt
Date Fri, 13 Oct 2006 00:58:57 GMT
Author: jdillon
Date: Thu Oct 12 17:58:56 2006
New Revision: 463539

URL: http://svn.apache.org/viewvc?view=rev&rev=463539
Log:
Drop the experimental custom bits
Add defaults and properties configuration

Modified:
    geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java
    geronimo/genesis/trunk/plugins/script-maven-plugin/src/site/apt/usage.apt

Modified: geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java
URL: http://svn.apache.org/viewvc/geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java?view=diff&rev=463539&r1=463538&r2=463539
==============================================================================
--- geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java
(original)
+++ geronimo/genesis/trunk/plugins/script-maven-plugin/src/main/java/org/apache/geronimo/genesis/plugins/script/GroovyMojo.java
Thu Oct 12 17:58:56 2006
@@ -34,8 +34,6 @@
 import groovy.lang.GroovyClassLoader;
 import groovy.lang.GroovyObject;
 import groovy.lang.GroovyResourceLoader;
-import groovy.lang.MetaClass;
-import groovy.lang.MetaMethod;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
@@ -81,14 +79,25 @@
      */
     private File[] scriptpath = null;
 
-    //
-    // TODO: Find a better name for this...
-    //
-    
     /**
+     * A set of default project properties, which the values will be used only if
+     * the project or system does not override.
+     *
+     * @parameter
+     */
+    private Map defaults;
+
+    /**
+     * A set of additional project properties.
+     * 
      * @parameter
      */
-    private DelayedConfiguration custom;
+    private Map properties;
+
+    //
+    // TODO: Find a better name for this... and figure out how to best use it to configure
a custom groovy object
+    //
+    // private DelayedConfiguration custom;
 
     //
     // Maven components
@@ -130,6 +139,7 @@
         Class type = loadGroovyClass(source);
         GroovyObject obj = (GroovyObject)type.newInstance();
 
+        /*
         if (custom != null) {
             log.info("Applying delayed configuration: " + custom);
 
@@ -139,7 +149,8 @@
 
             method.invoke(obj, new Object[] { custom });
         }
-
+        */
+        
         // Expose logging
         obj.setProperty("log", log);
 
@@ -308,14 +319,31 @@
     private Properties resolveProperties(final Properties source) {
         assert source != null;
 
-        Properties props = new Properties(System.getProperties());
-        
+        //
+        // NOTE: Create a chain of defaults
+        //
+
+        Properties dprops = new Properties();
+        if (defaults != null) {
+            dprops.putAll(defaults);
+        }
+
+        Properties sprops = new Properties(dprops);
+        sprops.putAll(System.getProperties());
+
+        Properties props = new Properties(sprops);
+
+        // Put all of the additional project props, which should already be resolved by mvn
+        if (properties != null) {
+            props.putAll(props);
+        }
+
         // Setup the variables which should be used for resolution
         Map vars = new HashMap();
         vars.put("project", project);
 
+        // Resolve all source properties
         ExpressionParser parser = new ExpressionParser(vars);
-
         Iterator iter = source.keySet().iterator();
         while (iter.hasNext()) {
             String name = (String)iter.next();

Modified: geronimo/genesis/trunk/plugins/script-maven-plugin/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/geronimo/genesis/trunk/plugins/script-maven-plugin/src/site/apt/usage.apt?view=diff&rev=463539&r1=463538&r2=463539
==============================================================================
--- geronimo/genesis/trunk/plugins/script-maven-plugin/src/site/apt/usage.apt (original)
+++ geronimo/genesis/trunk/plugins/script-maven-plugin/src/site/apt/usage.apt Thu Oct 12 17:58:56
2006
@@ -171,7 +171,7 @@
  By setting the <<<scriptpath>>> you can load additional Groovy classes.
 
  For example if you have a class named <<<Helper>>> defined in a file named
- <<<${pom.basedir}/src/main/script/Helper.groovy>>> your scripts can use
that class:
+ <<<$\{pom.basedir}/src/main/script/Helper.groovy>>> your scripts can use
that class:
 
 +----------+
 <plugin>
@@ -197,4 +197,67 @@
         </execution>
     </executions>
 </plugin>
-+----------+
\ No newline at end of file
++----------+
+
+* Custom Properties
+
+ By setting <<<properties>>> additional project properties can be added
for an execution.
+
++----------+
+<plugin>
+    <groupId>org.apache.geronimo.genesis.plugins</groupId>
+    <artifactId>script-maven-plugin</artifactId>
+    <executions>
+        <execution>
+            <phase>generate-resources</phase>
+            <goals>
+                <goal>groovy</goal>
+            </goals>
+            <configuration>
+                <properties>
+                    <hello>world</hello>
+                </properties>
+                <source>
+                    <body>
+                        println(project.properties['hello'])
+                    </body>
+                </source>
+            </configuration>
+        </execution>
+    </executions>
+</plugin>
++----------+
+
+ By setting <<<defaults>>> additional project properties can be added for
an execution
+ which will be used only if the project or system does not override.
+
++----------+
+<plugin>
+    <groupId>org.apache.geronimo.genesis.plugins</groupId>
+    <artifactId>script-maven-plugin</artifactId>
+    <executions>
+        <execution>
+            <phase>generate-resources</phase>
+            <goals>
+                <goal>groovy</goal>
+            </goals>
+            <configuration>
+                <defaults>
+                    <hello>world</hello>
+                </defaults>
+                <source>
+                    <body>
+                        println project.properties['hello']
+                    </body>
+                </source>
+            </configuration>
+        </execution>
+    </executions>
+</plugin>
++----------+
+
+ To provide a system override:
+
++----------+
+mvn -Dhello=jason
++----------+



Mime
View raw message