You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2008/09/30 14:11:19 UTC

svn commit: r700430 - in /maven/plugins/trunk/maven-invoker-plugin/src: it/script-accessibility/ it/script-accessibility/src/ it/script-accessibility/src/it/ it/script-accessibility/src/it/beanshell/ it/script-accessibility/src/it/groovy/ it/script-acc...

Author: bentmann
Date: Tue Sep 30 05:11:18 2008
New Revision: 700430

URL: http://svn.apache.org/viewvc?rev=700430&view=rev
Log:
[MINVOKER-68] Enable accessibility for non-public members from BeanShell scripts

Added:
    maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/
    maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/pom.xml   (with props)
    maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/
    maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/
    maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/beanshell/
    maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/beanshell/pom.xml   (with props)
    maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/beanshell/verify.bsh   (with props)
    maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/groovy/
    maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/groovy/pom.xml   (with props)
    maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/groovy/verify.groovy   (with props)
    maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/main/
    maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/main/java/
    maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/main/java/org/
    maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/main/java/org/MyClass.java   (with props)
Modified:
    maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/BeanShellScriptInterpreter.java
    maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/access-test-classes.apt.vm

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/pom.xml?rev=700430&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/pom.xml (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/pom.xml Tue Sep 30 05:11:18 2008
@@ -0,0 +1,67 @@
+<?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 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.invoker</groupId>
+  <artifactId>script-accessibility</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <description>
+    Test to check for accessibility of non-public fields/methods in hook scripts.
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-invoker-plugin</artifactId>
+        <version>@pom.version@</version>
+        <configuration>
+          <pomIncludes>
+            <pomInclude>*/pom.xml</pomInclude>
+          </pomIncludes>
+          <preBuildHookScript>setup</preBuildHookScript>
+          <postBuildHookScript>verify</postBuildHookScript>
+          <goals>
+            <goal>validate</goal>
+          </goals>
+          <addTestClassPath>true</addTestClassPath>
+        </configuration>
+        <executions>
+          <execution>
+            <id>integration-test</id>
+            <goals>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/beanshell/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/beanshell/pom.xml?rev=700430&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/beanshell/pom.xml (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/beanshell/pom.xml Tue Sep 30 05:11:18 2008
@@ -0,0 +1,32 @@
+<?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 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>test</groupId>
+  <artifactId>beanshell</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+</project>

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/beanshell/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/beanshell/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/beanshell/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/beanshell/verify.bsh?rev=700430&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/beanshell/verify.bsh (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/beanshell/verify.bsh Tue Sep 30 05:11:18 2008
@@ -0,0 +1,8 @@
+import org.MyClass;
+
+System.out.println( MyClass.PUBLIC );
+System.out.println( MyClass.PROTECTED );
+System.out.println( MyClass.PACKAGE );
+System.out.println( MyClass.PRIVATE );
+
+return true;

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/beanshell/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/beanshell/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/groovy/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/groovy/pom.xml?rev=700430&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/groovy/pom.xml (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/groovy/pom.xml Tue Sep 30 05:11:18 2008
@@ -0,0 +1,32 @@
+<?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 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>test</groupId>
+  <artifactId>groovy</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+</project>

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/groovy/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/groovy/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/groovy/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/groovy/verify.groovy?rev=700430&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/groovy/verify.groovy (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/groovy/verify.groovy Tue Sep 30 05:11:18 2008
@@ -0,0 +1,8 @@
+import org.MyClass;
+
+println MyClass.PUBLIC
+println MyClass.PROTECTED
+println MyClass.PACKAGE
+println MyClass.PRIVATE
+
+return true;

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/groovy/verify.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/it/groovy/verify.groovy
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/main/java/org/MyClass.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/main/java/org/MyClass.java?rev=700430&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/main/java/org/MyClass.java (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/main/java/org/MyClass.java Tue Sep 30 05:11:18 2008
@@ -0,0 +1,14 @@
+package org;
+
+public class MyClass
+{
+
+    public static final String PUBLIC = "public";
+
+    protected static final String PROTECTED = "protected";
+
+    static final String PACKAGE = "package";
+
+    private static final String PRIVATE = "private";
+
+}

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/main/java/org/MyClass.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/script-accessibility/src/main/java/org/MyClass.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/BeanShellScriptInterpreter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/BeanShellScriptInterpreter.java?rev=700430&r1=700429&r2=700430&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/BeanShellScriptInterpreter.java (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/BeanShellScriptInterpreter.java Tue Sep 30 05:11:18 2008
@@ -26,6 +26,7 @@
 import java.util.List;
 import java.util.Map;
 
+import bsh.Capabilities;
 import bsh.EvalError;
 import bsh.Interpreter;
 import bsh.TargetError;
@@ -61,6 +62,21 @@
                 engine.setOut( scriptOutput );
             }
 
+            if ( !Capabilities.haveAccessibility() )
+            {
+                try
+                {
+                    Capabilities.setAccessibility( true );
+                }
+                catch ( Exception e )
+                {
+                    if ( scriptOutput != null )
+                    {
+                        e.printStackTrace( scriptOutput );
+                    }
+                }
+            }
+
             if ( classPath != null && !classPath.isEmpty() )
             {
                 for ( Iterator it = classPath.iterator(); it.hasNext(); )

Modified: maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/access-test-classes.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/access-test-classes.apt.vm?rev=700430&r1=700429&r2=700430&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/access-test-classes.apt.vm (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/access-test-classes.apt.vm Tue Sep 30 05:11:18 2008
@@ -55,9 +55,10 @@
 </project>
 +----
 
-  Setting <<<addTestClassPath>>> to <<<true>>> will prepend the directory <<<$\{project.build.testOutputDirectory\}>>>
-  and all dependencies of your project to the class path of the script interpreter. Among others, this allows you to
-  create some utility classes in your test source tree and use this code for the integration tests.
+  Setting <<<addTestClassPath>>> to <<<true>>> will prepend the directories <<<$\{project.build.testOutputDirectory\}>>>,
+  <<<$\{project.build.outputDirectory\}>>> and all dependencies of your project to the class path of the script
+  interpreter. Among others, this allows you to create some utility classes in your test source tree and use this code
+  for the integration tests.
   
   <Note:> Of course, this requires your test classes to be compiled before running the integration tests but this is
   usually the case if you employ the Invoker Plugin during the lifecycle phase <<<integration-test>>>.