svn commit: r170608 - /maven/components/trunk/maven-core /maven/components/trunk/maven-core-it /maven/components/trunk/maven-core-it/it0020 /maven/components/trunk/maven-core-it/it0020/src /maven/components/trunk/maven-core-it/it0020/src/main /maven/compo

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r170608 - /maven/components/trunk/maven-core /maven/components/trunk/maven-core-it /maven/components/trunk/maven-core-it/it0020 /maven/components/trunk/maven-core-it/it0020/src /maven/components/trunk/maven-core-it/it0020/src/main /maven/compo

brettporter
Administrator
Author: brett
Date: Tue May 17 08:11:41 2005
New Revision: 170608

URL: http://svn.apache.org/viewcvs?rev=170608&view=rev
Log:
PR: MNG-164
Add Beanshell mojo support

Added:
    maven/components/trunk/maven-core-it/it0020/
    maven/components/trunk/maven-core-it/it0020/expected-results.txt   (with props)
    maven/components/trunk/maven-core-it/it0020/goals.txt   (with props)
    maven/components/trunk/maven-core-it/it0020/pom.xml   (with props)
    maven/components/trunk/maven-core-it/it0020/prebuild-hook.txt   (with props)
    maven/components/trunk/maven-core-it/it0020/src/
    maven/components/trunk/maven-core-it/it0020/src/main/
    maven/components/trunk/maven-core-it/it0020/src/main/scripts/
    maven/components/trunk/maven-core-it/it0020/src/main/scripts/org/
    maven/components/trunk/maven-core-it/it0020/src/main/scripts/org/apache/
    maven/components/trunk/maven-core-it/it0020/src/main/scripts/org/apache/maven/
    maven/components/trunk/maven-core-it/it0020/src/main/scripts/org/apache/maven/it0020/
    maven/components/trunk/maven-core-it/it0020/src/main/scripts/org/apache/maven/it0020/it0020.bsh
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/pom.xml   (with props)
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java   (with props)
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/META-INF/
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/META-INF/plexus/
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/META-INF/plexus/components.xml   (with props)
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/extractor.bsh
    maven/components/trunk/maven-script/maven-script-beanshell/
    maven/components/trunk/maven-script/maven-script-beanshell/pom.xml   (with props)
    maven/components/trunk/maven-script/maven-script-beanshell/src/
    maven/components/trunk/maven-script/maven-script-beanshell/src/main/
    maven/components/trunk/maven-script/maven-script-beanshell/src/main/java/
    maven/components/trunk/maven-script/maven-script-beanshell/src/main/java/org/
    maven/components/trunk/maven-script/maven-script-beanshell/src/main/java/org/apache/
    maven/components/trunk/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/
    maven/components/trunk/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/
    maven/components/trunk/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/
    maven/components/trunk/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.java   (with props)
Modified:
    maven/components/trunk/maven-core-it/README.txt
    maven/components/trunk/maven-core-it/integration-tests.txt
    maven/components/trunk/maven-core/pom.xml
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
    maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/plexus.xml
    maven/components/trunk/maven-mboot2/src/main/java/MBoot.java
    maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
    maven/components/trunk/maven-plugin-tools/pom.xml
    maven/components/trunk/maven-plugins/maven-plugin-plugin/pom.xml
    maven/components/trunk/maven-script/pom.xml

Modified: maven/components/trunk/maven-core-it/README.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/README.txt?rev=170608&r1=170607&r2=170608&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/README.txt (original)
+++ maven/components/trunk/maven-core-it/README.txt Tue May 17 08:11:41 2005
@@ -64,6 +64,9 @@
         redownloaded.
 
 it0019: Test that a version is managed by pluginManagement in the super POM
+
+it0020: Test beanshell mojo support.
+
 -------------------------------------------------------------------------------
 
 - generated sources

Modified: maven/components/trunk/maven-core-it/integration-tests.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/integration-tests.txt?rev=170608&r1=170607&r2=170608&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/integration-tests.txt (original)
+++ maven/components/trunk/maven-core-it/integration-tests.txt Tue May 17 08:11:41 2005
@@ -18,3 +18,4 @@
 it0017
 it0018
 it0019
+it0020

Added: maven/components/trunk/maven-core-it/it0020/expected-results.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0020/expected-results.txt?rev=170608&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0020/expected-results.txt (added)
+++ maven/components/trunk/maven-core-it/it0020/expected-results.txt Tue May 17 08:11:41 2005
@@ -0,0 +1 @@
+target/out.txt

Propchange: maven/components/trunk/maven-core-it/it0020/expected-results.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core-it/it0020/expected-results.txt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-core-it/it0020/goals.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0020/goals.txt?rev=170608&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0020/goals.txt (added)
+++ maven/components/trunk/maven-core-it/it0020/goals.txt Tue May 17 08:11:41 2005
@@ -0,0 +1,2 @@
+install
+it0020:it0020

Propchange: maven/components/trunk/maven-core-it/it0020/goals.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core-it/it0020/goals.txt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-core-it/it0020/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0020/pom.xml?rev=170608&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0020/pom.xml (added)
+++ maven/components/trunk/maven-core-it/it0020/pom.xml Tue May 17 08:11:41 2005
@@ -0,0 +1,24 @@
+<model>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugins</groupId>
+  <artifactId>maven-it0020-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-script-beanshell</artifactId>
+      <version>2.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+  <build>
+    <resources>
+      <resource>
+        <directory>src/main/scripts</directory>
+        <includes>
+          <include>**/*.bsh</include>
+        </includes>
+      </resource>
+    </resources>
+  </build>
+</model>

Propchange: maven/components/trunk/maven-core-it/it0020/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core-it/it0020/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-core-it/it0020/prebuild-hook.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0020/prebuild-hook.txt?rev=170608&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0020/prebuild-hook.txt (added)
+++ maven/components/trunk/maven-core-it/it0020/prebuild-hook.txt Tue May 17 08:11:41 2005
@@ -0,0 +1 @@
+rm target/out.txt

Propchange: maven/components/trunk/maven-core-it/it0020/prebuild-hook.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-core-it/it0020/prebuild-hook.txt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-core-it/it0020/src/main/scripts/org/apache/maven/it0020/it0020.bsh
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0020/src/main/scripts/org/apache/maven/it0020/it0020.bsh?rev=170608&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0020/src/main/scripts/org/apache/maven/it0020/it0020.bsh (added)
+++ maven/components/trunk/maven-core-it/it0020/src/main/scripts/org/apache/maven/it0020/it0020.bsh Tue May 17 08:11:41 2005
@@ -0,0 +1,28 @@
+/**
+ * Beanshell mojo integration test.
+ * @goal it0020
+ */
+
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.script.beanshell.BeanshellMojoAdapter;
+
+execute()
+{
+    logger.info( "Executing it0020..." );
+    print( "info level?" );
+    org.codehaus.plexus.util.FileUtils.fileWrite( outDir.getAbsolutePath() + "/out.txt", "This is a Beanshell test" );
+}
+
+/**
+ * Output directory for files.
+ *
+ * @parameter expression="${project.build.directory}" type="java.io.File"
+ * @required
+ */
+setOutDir( file )
+{
+    outDir = file;
+}
+
+return new BeanshellMojoAdapter( (Mojo) this, this.interpreter );
+

Modified: maven/components/trunk/maven-core/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/pom.xml?rev=170608&r1=170607&r2=170608&view=diff
==============================================================================
--- maven/components/trunk/maven-core/pom.xml (original)
+++ maven/components/trunk/maven-core/pom.xml Tue May 17 08:11:41 2005
@@ -69,6 +69,13 @@
       <artifactId>plexus-i18n</artifactId>
       <version>1.0-beta-3</version>
     </dependency>
+    <!-- TODO: only here for classloader issues. It used to work when the script classes were inside the component factory... -->
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-script-beanshell</artifactId>
+      <version>2.0-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-script-marmalade</artifactId>

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=170608&r1=170607&r2=170608&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Tue May 17 08:11:41 2005
@@ -536,6 +536,7 @@
         {
             String configuratorId = mojoDescriptor.getComponentConfigurator();
 
+            // TODO: should this be known to the component factory instead? And if so, should configuration be part of lookup?
             if ( StringUtils.isNotEmpty( configuratorId ) )
             {
                 configurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE, configuratorId );
@@ -670,7 +671,7 @@
                                " for parameter: \'" + key + "\'" );
 
             // TODO: remove. If there is a default value, required should have been removed by the descriptor generator
-            if ( value == null && !"map-oriented".equals( goal.getComponentConfigurator() ) )
+            if ( value == null && goal.getComponentConfigurator() == null )
             {
                 Object defaultValue;
                 try
@@ -791,6 +792,7 @@
                                                               "maven-reporting-api", "doxia-core",
                                                               "wagon-provider-api", "classworlds", "maven-plugin",
                                                               "plexus-marmalade-factory", "maven-script-marmalade",
+                                                              "maven-script-beanshell", "plexus-bsh-factory", "bsh",
                                                               "marmalade-core"} );
     }
 

Modified: maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/plexus.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/plexus.xml?rev=170608&r1=170607&r2=170608&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/plexus.xml (original)
+++ maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/plexus.xml Tue May 17 08:11:41 2005
@@ -9,13 +9,6 @@
       <component-discoverer implementation="org.apache.maven.plugin.MavenPluginDiscoverer"/>
     </component-discoverers>
   </component-discoverer-manager>
-  <!-- component-factory-manager implementation="org.codehaus.plexus.component.factory.DefaultComponentFactoryManager">
-    <component-factories>
-      <component-factory implementation="org.codehaus.plexus.component.factory.marmalade.MarmaladeClasspathComponentFactory">
-        <id>marmalade</id>
-      </component-factory>
-    </component-factories>
-  </component-factory-manager -->
   <components>
     <component>
       <role>org.apache.maven.plugin.PluginManager</role>

Modified: maven/components/trunk/maven-mboot2/src/main/java/MBoot.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-mboot2/src/main/java/MBoot.java?rev=170608&r1=170607&r2=170608&view=diff
==============================================================================
--- maven/components/trunk/maven-mboot2/src/main/java/MBoot.java (original)
+++ maven/components/trunk/maven-mboot2/src/main/java/MBoot.java Tue May 17 08:11:41 2005
@@ -37,9 +37,11 @@
 {
     String[] builds = new String[]{"maven-model", "maven-settings", "maven-monitor", "maven-plugin-api",
                                    "maven-plugin-descriptor", "maven-artifact", "maven-script/maven-script-marmalade",
-                                   "maven-project", "maven-reporting/maven-reporting-api", "maven-core",
-                                   "maven-archiver", "maven-plugin-tools/maven-plugin-tools-api",
+                                   "maven-script/maven-script-beanshell", "maven-project",
+                                   "maven-reporting/maven-reporting-api", "maven-core", "maven-archiver",
+                                   "maven-plugin-tools/maven-plugin-tools-api",
                                    "maven-plugin-tools/maven-plugin-tools-java",
+                                   "maven-plugin-tools/maven-plugin-tools-beanshell",
                                    "maven-plugin-tools/maven-plugin-tools-pluggy",
                                    "maven-plugin-tools/maven-plugin-tools-marmalade", "maven-core-it-verifier"};
 

Added: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/pom.xml?rev=170608&view=auto
==============================================================================
--- maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/pom.xml (added)
+++ maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/pom.xml Tue May 17 08:11:41 2005
@@ -0,0 +1,27 @@
+<model>
+  <parent>
+    <artifactId>maven-plugin-tools</artifactId>
+    <groupId>org.apache.maven</groupId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>maven-plugin-tools-beanshell</artifactId>
+  <name>Maven Plugin Tools for Beanshell</name>
+  <dependencies>
+    <dependency>
+      <groupId>bsh</groupId>
+      <artifactId>bsh</artifactId>
+      <version>1.3.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-descriptor</artifactId>
+      <version>2.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-tools-api</artifactId>
+      <version>2.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+</model>

Propchange: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java?rev=170608&view=auto
==============================================================================
--- maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java (added)
+++ maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java Tue May 17 08:11:41 2005
@@ -0,0 +1,109 @@
+package org.apache.maven.tools.plugin.extractor.beanshell;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import bsh.EvalError;
+import bsh.Interpreter;
+import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+
+/**
+ * @todo share constants
+ * @todo add example usage tag that can be shown in the doco
+ * @todo need to add validation directives so that systems embedding maven2 can
+ * get validation directives to help users in IDEs.
+ */
+public class BeanshellMojoDescriptorExtractor
+    extends AbstractLogEnabled
+    implements MojoDescriptorExtractor
+{
+    private MojoDescriptor createMojoDescriptor( File basedir, String resource, PluginDescriptor pluginDescriptor )
+        throws InvalidPluginDescriptorException
+    {
+        MojoDescriptor mojoDescriptor = new MojoDescriptor();
+        mojoDescriptor.setPluginDescriptor( pluginDescriptor );
+
+        mojoDescriptor.setLanguage( "bsh" );
+        mojoDescriptor.setComponentConfigurator( "bsh" );
+
+        mojoDescriptor.setImplementation( resource );
+
+        Interpreter interpreter = new Interpreter();
+
+        try
+        {
+            interpreter.set( "file", new File( basedir, resource ) );
+
+            interpreter.set( "mojoDescriptor", mojoDescriptor );
+
+            interpreter.eval( new InputStreamReader( getClass().getResourceAsStream( "/extractor.bsh" ) ) );
+        }
+        catch ( EvalError evalError )
+        {
+            throw new InvalidPluginDescriptorException( "Error scanning beanshell script", evalError );
+        }
+
+        return mojoDescriptor;
+    }
+
+    public List execute( MavenProject project, PluginDescriptor pluginDescriptor )
+        throws InvalidPluginDescriptorException
+    {
+        List descriptors = new ArrayList();
+
+        for ( Iterator i = project.getScriptSourceRoots().iterator(); i.hasNext(); )
+        {
+            try
+            {
+                File basedir = new File( (String) i.next() );
+
+                if ( basedir.exists() )
+                {
+                    List files = FileUtils.getFiles( basedir, "**/*.bsh", null, false );
+
+                    for ( Iterator j = files.iterator(); j.hasNext(); )
+                    {
+                        File resource = (File) j.next();
+                        String resourcePath = "/" + resource.getPath().replace( '\\', '/' );
+                        MojoDescriptor mojoDescriptor = createMojoDescriptor( basedir, resourcePath, pluginDescriptor );
+                        descriptors.add( mojoDescriptor );
+                    }
+                }
+            }
+            catch ( IOException e )
+            {
+                throw new InvalidPluginDescriptorException( "Unable to locate files to process", e );
+            }
+        }
+
+        return descriptors;
+    }
+
+}
\ No newline at end of file

Propchange: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/META-INF/plexus/components.xml?rev=170608&view=auto
==============================================================================
--- maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/META-INF/plexus/components.xml (added)
+++ maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/META-INF/plexus/components.xml Tue May 17 08:11:41 2005
@@ -0,0 +1,17 @@
+<component-set>
+  <components>
+
+    <!--
+     |
+     | BeanshellMojoDescriptorExtractor, a MojoDescriptor extractor to read
+     | descriptors from java sources.
+     |
+     -->
+    <component>
+      <role>org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor</role>
+      <role-hint>bsh</role-hint>
+      <implementation>org.apache.maven.tools.plugin.extractor.beanshell.BeanshellMojoDescriptorExtractor</implementation>
+    </component>
+    
+  </components>
+</component-set>
\ No newline at end of file

Propchange: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/extractor.bsh
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/extractor.bsh?rev=170608&view=auto
==============================================================================
--- maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/extractor.bsh (added)
+++ maven/components/trunk/maven-plugin-tools/maven-plugin-tools-beanshell/src/main/resources/extractor.bsh Tue May 17 08:11:41 2005
@@ -0,0 +1,152 @@
+import bsh.*;
+import java.util.regex.Pattern;
+import java.io.FileReader;
+import org.codehaus.plexus.util.StringUtils;
+import org.apache.maven.plugin.descriptor.Parameter;
+
+// only on start of line
+this.tag = "\\r?\\n\\s*\\*?\\s*@(\\w+)";
+// zero width lookahead to next tag or end of comment
+this.tagOrEndComment = "(?=" + tag + "|\\*/)";
+this.commentTextPattern = Pattern.compile( "(?s)/\\*\\*(.*?)" + tagOrEndComment );
+this.tagsPattern = Pattern.compile( "(?s)" + tag + "\\s*(.*?)" + tagOrEndComment );
+this.descriptionPattern = Pattern.compile( "(?s)\\r?\\n\\s*\\*" );
+this.typePattern = Pattern.compile( "type\\s*=\\s*\"(.*?)\"" );
+this.expressionPattern = Pattern.compile( "expression\\s*=\\s*\"(.*?)\"" );
+
+setAccessibility( true );
+
+createParameter( text, method )
+{
+    if ( method.startsWith( "set" ) )
+    {
+        this.name = StringUtils.uncapitalise( method.substring( 3 ) );
+        this.desc = getDescription( text );
+        this.tags = getTags( text );
+
+        this.parameter = new Parameter();
+        parameter.setName( name );
+        parameter.setDescription( desc );
+        parameter.setRequired( tags.containsKey( "required" ) );
+        parameter.setEditable( !tags.containsKey( "readonly" ) );
+        this.deprecation = tags.get( "deprecated" );
+        if ( deprecation != null )
+        {
+            parameter.setDeprecated( deprecation );
+        }
+        this.alias = tags.get( "alias" );
+        if ( alias != null )
+        {
+            parameter.setAlias( alias );
+        }
+        this.value = tags.get( "parameter" );
+        if ( value != null )
+        {
+            m = typePattern.matcher( value );
+            if ( m.find() )
+            {
+                parameter.setType( m.group( 1 ) );
+            }
+            else
+            {
+                parameter.setType( "java.lang.Object" );
+            }
+            m = expressionPattern.matcher( value );
+            if ( m.find() )
+            {
+                parameter.setExpression( m.group( 1 ) );
+            }
+        }
+        return parameter;
+    }
+    return null;
+}
+
+getTags( text )
+{
+    this.matcher = tagsPattern.matcher( text );
+    this.tags = new HashMap();
+    while ( matcher.find() )
+    {
+        this.tagname = matcher.group( 1 );
+        this.tagvalue = matcher.group( 2 );
+        tags.put( tagname, tagvalue.trim() );
+    }
+    return tags;
+}
+
+getDescription( text )
+{
+    this.matcher = commentTextPattern.matcher( text );
+    if ( matcher.find() )
+    {
+        this.input = matcher.group( 1 );
+        return descriptionPattern.matcher( input ).replaceAll( "" ).trim();
+    }
+    else
+    {
+        return "";
+    }
+}
+
+extract( file, mojoDescriptor )
+{
+    this.parser = new Parser( new FileReader( file ) );
+    parser.setRetainComments( true );
+
+    this.lastNode = null;
+    this.firstComment = null;
+    while ( !parser.Line() )
+    {
+        this.node = parser.popNode();
+
+        if ( node instanceof BSHFormalComment && firstComment == null )
+        {
+            firstComment = node;
+        }
+
+        if ( node instanceof BSHMethodDeclaration )
+        {
+            if ( lastNode instanceof BSHFormalComment )
+            {
+                this.text = lastNode.text;
+
+                this.method = node.name;
+
+                this.parameter = createParameter( text, method );
+                if ( parameter != null )
+                {
+                    mojoDescriptor.addParameter( parameter );
+                }
+
+                if ( firstComment == lastNode )
+                {
+                    firstComment = null;
+                }
+            }
+        }
+        lastNode = node;
+    }
+    if ( firstComment != null )
+    {
+        this.text = firstComment.text;
+
+        mojoDescriptor.setDescription( getDescription( text ) );
+        this.tags = getTags( text );
+        mojoDescriptor.setGoal( tags.get( "goal" ) );
+        mojoDescriptor.setPhase( tags.get( "phase" ) );
+        mojoDescriptor.setExecutePhase( tags.get( "executePhase" ) );
+        this.value = tags.get( "requiresDependencyResolution" );
+        // TODO: share with java extractor
+        if ( value == null || value.length() == 0 )
+        {
+            value = "runtime";
+        }
+        mojoDescriptor.setDependencyResolutionRequired( value );
+
+        mojoDescriptor.setProjectRequired( tags.containsKey( "requiresProject" ) );
+        mojoDescriptor.setOnlineRequired( tags.containsKey( "requiresOnline" ) );
+    }
+}
+
+extract( file, mojoDescriptor );

Modified: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java?rev=170608&r1=170607&r2=170608&view=diff
==============================================================================
--- maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java (original)
+++ maven/components/trunk/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java Tue May 17 08:11:41 2005
@@ -273,7 +273,7 @@
 
             String alias = parameter.getNamedParameter( "alias" );
 
-            if ( StringUtils.isEmpty( alias ) )
+            if ( !StringUtils.isEmpty( alias ) )
             {
                 pd.setAlias( alias );
             }

Modified: maven/components/trunk/maven-plugin-tools/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/pom.xml?rev=170608&r1=170607&r2=170608&view=diff
==============================================================================
--- maven/components/trunk/maven-plugin-tools/pom.xml (original)
+++ maven/components/trunk/maven-plugin-tools/pom.xml Tue May 17 08:11:41 2005
@@ -12,6 +12,7 @@
     <module>maven-plugin-tools-api</module>
     <module>maven-plugin-tools-java</module>
     <module>maven-plugin-tools-marmalade</module>
+    <module>maven-plugin-tools-beanshell</module>
     <module>maven-plugin-tools-pluggy</module>
   </modules>
 </project>

Modified: maven/components/trunk/maven-plugins/maven-plugin-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-plugin-plugin/pom.xml?rev=170608&r1=170607&r2=170608&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-plugin-plugin/pom.xml (original)
+++ maven/components/trunk/maven-plugins/maven-plugin-plugin/pom.xml Tue May 17 08:11:41 2005
@@ -18,6 +18,12 @@
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-tools-beanshell</artifactId>
+      <version>2.0-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-tools-java</artifactId>
       <version>2.0-alpha-2</version>
       <scope>runtime</scope>

Added: maven/components/trunk/maven-script/maven-script-beanshell/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-script/maven-script-beanshell/pom.xml?rev=170608&view=auto
==============================================================================
--- maven/components/trunk/maven-script/maven-script-beanshell/pom.xml (added)
+++ maven/components/trunk/maven-script/maven-script-beanshell/pom.xml Tue May 17 08:11:41 2005
@@ -0,0 +1,22 @@
+<model>
+  <parent>
+    <artifactId>maven-script</artifactId>
+    <groupId>org.apache.maven</groupId>
+    <version>2.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>maven-script-beanshell</artifactId>
+  <name>Maven Beanshell Mojo Support</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>plexus</groupId>
+      <artifactId>plexus-bsh-factory</artifactId>
+      <version>1.0-alpha-6-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+</model>

Propchange: maven/components/trunk/maven-script/maven-script-beanshell/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-script/maven-script-beanshell/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/components/trunk/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.java?rev=170608&view=auto
==============================================================================
--- maven/components/trunk/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.java (added)
+++ maven/components/trunk/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.java Tue May 17 08:11:41 2005
@@ -0,0 +1,74 @@
+package org.apache.maven.script.beanshell;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.component.factory.bsh.BshComponent;
+import bsh.Interpreter;
+import bsh.This;
+import bsh.UtilEvalError;
+import bsh.EvalError;
+
+import java.io.PrintStream;
+
+/**
+ * Mojo adapter for a Beanshell Mojo.
+ *
+ * @todo should log be passed in, or rely on getLog() ?
+ *
+ * @author <a href="mailto:[hidden email]">Brett Porter</a>
+ * @version $Id$
+ */
+public class BeanshellMojoAdapter
+    extends AbstractMojo
+    implements BshComponent
+{
+    private Mojo mojo;
+
+    private Interpreter interpreter;
+
+    public BeanshellMojoAdapter( Mojo mojo, Interpreter interpreter )
+    {
+        this.mojo = mojo;
+        this.interpreter = interpreter;
+    }
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        try
+        {
+            interpreter.set( "logger", getLog() );
+
+            // TODO: set out, err to a print stream that will log at info, error respectively
+        }
+        catch ( EvalError evalError )
+        {
+            throw new MojoExecutionException( "Unable to establish mojo", evalError );
+        }
+
+        mojo.execute();
+    }
+
+    public Interpreter getInterpreter()
+    {
+        return interpreter;
+    }
+}

Propchange: maven/components/trunk/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/trunk/maven-script/maven-script-beanshell/src/main/java/org/apache/maven/script/beanshell/BeanshellMojoAdapter.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/components/trunk/maven-script/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-script/pom.xml?rev=170608&r1=170607&r2=170608&view=diff
==============================================================================
--- maven/components/trunk/maven-script/pom.xml (original)
+++ maven/components/trunk/maven-script/pom.xml Tue May 17 08:11:41 2005
@@ -10,5 +10,6 @@
   <name>Maven Script Support Root</name>
   <modules>
     <module>maven-script-marmalade</module>
+    <module>maven-script-beanshell</module>
   </modules>
 </project>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]