You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2006/10/11 22:29:33 UTC

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

Author: jdillon
Date: Wed Oct 11 13:29:32 2006
New Revision: 462932

URL: http://svn.apache.org/viewvc?view=rev&rev=462932
Log:
Update the site docs for new features and examples of existing ones

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=462932&r1=462931&r2=462932
==============================================================================
--- 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 Wed Oct 11 13:29:32 2006
@@ -37,8 +37,8 @@
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.DependencyResolutionRequiredException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.project.MavenProject;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
 
 import org.apache.geronimo.genesis.MojoSupport;
 import org.apache.geronimo.genesis.util.ArtifactItem;
@@ -265,6 +265,8 @@
     }
     
     private Properties resolveProperties(final Properties source) {
+        assert source != null;
+
         Properties props = new Properties(System.getProperties());
         
         // Setup the variables which should be used for resolution

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=462932&r1=462931&r2=462932
==============================================================================
--- 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 Wed Oct 11 13:29:32 2006
@@ -119,4 +119,81 @@
         </execution>
     </executions>
 </plugin>
++----------+
+
+* Using Java Classes
+
+ Scripts can use Java classes.  To include custom classes to be available to the script define
+ a <<<classpath>>> which contains additional artifacts to included in the scripts classloader.
+
+ This is the prefered mechanism to extend a scripts classpath instead of adding dependencies to
+ the plugin, which may cause problems if the classpath needs to be different on more than
+ one plugin execution or when it differs between usage in more than one module in a multi-module
+ build.
+
+ Artifact definitions will pick up missing details from the pom's <<<dependencyManagement>>> section.
+
++----------+
+<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>
+                <classpath>
+                    <element>
+                        <groupId>commons-lang</groupId>
+                        <artifactId>commons-lang</groupId>
+                    </element>
+                </classpath>
+                <source>
+                    <body>
+                        import org.apache.commons.lang.SystemUtils
+                        def crappyOS = SystemUtils.IS_OS_WINDOWS
+                        if (crappyOS) {
+                            println("Go buy a Mac!")
+                        }
+                    </body>
+                </source>
+            </configuration>
+        </execution>
+    </executions>
+</plugin>
++----------+
+
+* Using Groovy Classes
+
+ 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:
+
++----------+
+<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>
+                <scriptpath>
+                    <element>${pom.basedir}/src/main/script</element>
+                </scriptpath>
+                <source>
+                    <body>
+                        import Helper
+                        Helper.callSomeStatic()
+                    </body>
+                </source>
+            </configuration>
+        </execution>
+    </executions>
+</plugin>
 +----------+