Author: olamy
Date: Mon May 14 16:54:01 2012
New Revision: 1338290

URL: http://svn.apache.org/viewvc?rev=1338290&view=rev
Log:
add a simple it for beanshell mojo

Added:
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/invoker.properties
   (with props)
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/pom.xml   
(with props)
    maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/src/
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/src/main/
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/src/main/scripts/
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/src/main/scripts/touch.bsh
   (with props)
    
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/verify.groovy
   (with props)
Modified:
    
maven/plugin-tools/trunk/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java

Added: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/invoker.properties
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/invoker.properties?rev=1338290&view=auto
==============================================================================
--- 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/invoker.properties
 (added)
+++ 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/invoker.properties
 Mon May 14 16:54:01 2012
@@ -0,0 +1,3 @@
+invoker.goals.1 = clean install -DskipTests
+invoker.goals.2 = 
org.apache.maven.beanshell.it:maven-beanshell-it-basic:1.0-SNAPSHOT:touch 
-Dname=touch.txt
+

Propchange: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/pom.xml?rev=1338290&view=auto
==============================================================================
--- 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/pom.xml 
(added)
+++ 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/pom.xml 
Mon May 14 16:54:01 2012
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
../../../../maven-site/target/site/maven-v4_0_0.xsd ">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.beanshell.it</groupId>
+  <artifactId>maven-beanshell-it-basic</artifactId>
+  <name>Basic Beanshell-Mojo Integration Test</name>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>maven-plugin</packaging>
+
+  <properties>
+    <pluginPluginVersion>@project.version@</pluginPluginVersion><!--  -->
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>bsh</groupId>
+      <artifactId>bsh</artifactId>
+      <version>1.3.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-script-beanshell</artifactId>
+      <version>2.2.1</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <version>${pluginPluginVersion}</version>
+        <configuration>
+          <prefix>beanshellBasic</prefix>
+        </configuration>
+        <dependencies>
+          <dependency>
+            <groupId>org.apache.maven.plugin-tools</groupId>
+            <artifactId>maven-plugin-tools-beanshell</artifactId>
+            <version>${pluginPluginVersion}</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+    </plugins>
+  </build>
+</project>

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

Propchange: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/src/main/scripts/touch.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/src/main/scripts/touch.bsh?rev=1338290&view=auto
==============================================================================
--- 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/src/main/scripts/touch.bsh
 (added)
+++ 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/src/main/scripts/touch.bsh
 Mon May 14 16:54:01 2012
@@ -0,0 +1,44 @@
+/**
+ * Touches a test file.
+ *
+ * @goal touch
+ * @requiresDependencyResolution=test
+ * @deprecated Don't use!
+ * @since 1.2
+ */
+
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.script.beanshell.BeanshellMojoAdapter;
+import org.codehaus.plexus.util.FileUtils;
+
+
+
+execute()
+{
+    logger.info( "Executing beanshell mojo..." );
+    FileUtils.fileWrite( outDir + "/" + name, "This is a Beanshell test" );
+}
+
+/**
+ * Output directory for files.
+ *
+ * @parameter expression="${project.build.directory}"
+ * @required
+ */
+setOutDir( file )
+{
+    outDir = file;
+}
+
+/**
+ *
+ *
+ * @parameter expression="${name}"
+ * @required
+ */
+setName( name )
+{
+    name = name;
+}
+
+return new BeanshellMojoAdapter( (Mojo) this, this.interpreter );
\ No newline at end of file

Propchange: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/src/main/scripts/touch.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/src/main/scripts/touch.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/verify.groovy
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/verify.groovy?rev=1338290&view=auto
==============================================================================
--- 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/verify.groovy
 (added)
+++ 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/verify.groovy
 Mon May 14 16:54:01 2012
@@ -0,0 +1,8 @@
+File touchFile = new File( basedir, "target/touch.txt" )
+assert touchFile.exists()
+assert touchFile.isFile()
+content = touchFile.text
+assert content.contains('This is a Beanshell test');
+
+
+return true;

Propchange: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/verify.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugin-tools/trunk/maven-plugin-plugin/src/it/beanshell-simple/verify.groovy
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
maven/plugin-tools/trunk/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
URL: 
http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java?rev=1338290&r1=1338289&r2=1338290&view=diff
==============================================================================
--- 
maven/plugin-tools/trunk/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
 (original)
+++ 
maven/plugin-tools/trunk/maven-plugin-tools-beanshell/src/main/java/org/apache/maven/tools/plugin/extractor/beanshell/BeanshellMojoDescriptorExtractor.java
 Mon May 14 16:54:01 2012
@@ -19,47 +19,51 @@ package org.apache.maven.tools.plugin.ex
  * under the License.
  */
 
-import java.io.File;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import bsh.EvalError;
+import bsh.Interpreter;
 import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
 import org.apache.maven.plugin.descriptor.MojoDescriptor;
 import org.apache.maven.tools.plugin.PluginToolsRequest;
 import 
org.apache.maven.tools.plugin.extractor.AbstractScriptedMojoDescriptorExtractor;
 import org.apache.maven.tools.plugin.extractor.ExtractionException;
-
-import bsh.EvalError;
-import bsh.Interpreter;
 import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor;
 import org.codehaus.plexus.component.annotations.Component;
 
+import java.io.File;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * Extracts Mojo descriptors from <a 
href="http://www.beanshell.org/";>BeanShell</a> sources.
  *
+ * @version $Id$
  * @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.
- * @version $Id$
  */
-@Component( role = MojoDescriptorExtractor.class, hint = "bsh")
+@Component( role = MojoDescriptorExtractor.class, hint = "bsh" )
 public class BeanshellMojoDescriptorExtractor
     extends AbstractScriptedMojoDescriptorExtractor
     implements MojoDescriptorExtractor
 {
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     protected String getScriptFileExtension( PluginToolsRequest request )
     {
         return ".bsh";
     }
 
-    /** {@inheritDoc} */
-    protected List<MojoDescriptor> extractMojoDescriptors( Map<String, 
Set<File>> scriptFilesKeyedByBasedir, PluginToolsRequest request )
+    /**
+     * {@inheritDoc}
+     */
+    protected List<MojoDescriptor> extractMojoDescriptors( Map<String, 
Set<File>> scriptFilesKeyedByBasedir,
+                                                           PluginToolsRequest 
request )
         throws ExtractionException, InvalidPluginDescriptorException
     {
         List<MojoDescriptor> descriptors = new ArrayList<MojoDescriptor>();
@@ -91,11 +95,12 @@ public class BeanshellMojoDescriptorExtr
     }
 
     /**
-     * @param basedir not null
+     * @param basedir  not null
      * @param resource not null
-     * @param request not null
+     * @param request  not null
      * @return a new Mojo descriptor instance
-     * @throws InvalidPluginDescriptorException if any
+     * @throws InvalidPluginDescriptorException
+     *          if any
      */
     private MojoDescriptor createMojoDescriptor( String basedir, String 
resource, PluginToolsRequest request )
         throws InvalidPluginDescriptorException
@@ -116,6 +121,8 @@ public class BeanshellMojoDescriptorExtr
 
             interpreter.set( "mojoDescriptor", mojoDescriptor );
 
+            interpreter.set( "encoding", "UTF-8" );
+
             interpreter.eval( new InputStreamReader( 
getClass().getResourceAsStream( "/extractor.bsh" ), "UTF-8" ) );
         }
         catch ( EvalError evalError )


Reply via email to