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/08/10 00:42:51 UTC

svn commit: r684373 - in /maven/plugins/trunk/maven-invoker-plugin/src: it/global-vars/ it/global-vars/src/ it/global-vars/src/it/ it/global-vars/src/it/project/ main/java/org/apache/maven/plugin/invoker/ site/apt/ site/apt/examples/

Author: bentmann
Date: Sat Aug  9 15:42:51 2008
New Revision: 684373

URL: http://svn.apache.org/viewvc?rev=684373&view=rev
Log:
[MINVOKER-49] Inject global variable with path to local repo into hook scripts

Added:
    maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/
    maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/pom.xml   (with props)
    maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/
    maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/
    maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/
    maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/pom.xml   (with props)
    maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/setup.bsh   (with props)
    maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/verify.bsh   (with props)
Modified:
    maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
    maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/post-build-script.apt.vm
    maven/plugins/trunk/maven-invoker-plugin/src/site/apt/usage.apt.vm

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/pom.xml?rev=684373&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/pom.xml (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/pom.xml Sat Aug  9 15:42:51 2008
@@ -0,0 +1,64 @@
+<?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>global-vars</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <description>
+    Test to check for existence of supported global script variables.
+  </description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-invoker-plugin</artifactId>
+        <version>@pom.version@</version>
+        <configuration>
+          <projectsDirectory>src/it</projectsDirectory>
+          <pomIncludes>
+            <pomInclude>*/pom.xml</pomInclude>
+          </pomIncludes>
+          <preBuildHookScript>setup.bsh</preBuildHookScript>
+          <postBuildHookScript>verify.bsh</postBuildHookScript>
+          <goals>
+            <goal>validate</goal>
+          </goals>
+        </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/global-vars/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/pom.xml?rev=684373&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/pom.xml (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/pom.xml Sat Aug  9 15:42:51 2008
@@ -0,0 +1,26 @@
+<?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.test</groupId>
+  <artifactId>unit</artifactId>
+  <packaging>pom</packaging>
+  <version>0.1-SNAPSHOT</version>
+</project>
\ No newline at end of file

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/setup.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/setup.bsh?rev=684373&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/setup.bsh (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/setup.bsh Sat Aug  9 15:42:51 2008
@@ -0,0 +1,27 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+
+try
+{
+    System.out.println( basedir );
+    if ( !( basedir instanceof File ) )
+    {
+        System.out.println( "Global script variable not defined: basedir" );
+        return false;
+    }
+
+    System.out.println( localRepositoryPath );
+    if ( !( localRepositoryPath instanceof File ) )
+    {
+        System.out.println( "Global script variable not defined: localRepositoryPath" );
+        return false;
+    }
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/setup.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/setup.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/verify.bsh?rev=684373&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/verify.bsh (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/verify.bsh Sat Aug  9 15:42:51 2008
@@ -0,0 +1,27 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+
+try
+{
+    System.out.println( basedir );
+    if ( !( basedir instanceof File ) )
+    {
+        System.out.println( "Global script variable not defined: basedir" );
+        return false;
+    }
+
+    System.out.println( localRepositoryPath );
+    if ( !( localRepositoryPath instanceof File ) )
+    {
+        System.out.println( "Global script variable not defined: localRepositoryPath" );
+        return false;
+    }
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/global-vars/src/it/project/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java?rev=684373&r1=684372&r2=684373&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java Sat Aug  9 15:42:51 2008
@@ -1077,6 +1077,7 @@
 
             Map globalVariables = new HashMap();
             globalVariables.put( "basedir", basedir );
+            globalVariables.put( "localRepositoryPath", localRepositoryPath );
 
             PrintStream out = ( logger != null ) ? logger.getPrintStream() : null;
 

Modified: maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/post-build-script.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/post-build-script.apt.vm?rev=684373&r1=684372&r2=684373&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/post-build-script.apt.vm (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/post-build-script.apt.vm Sat Aug  9 15:42:51 2008
@@ -68,8 +68,6 @@
   Here is an example post build BeanShell script (<<<verify.bsh>>>) that checks for the existence 
   of a JAR file after the build has run.  If the JAR file does not exist, the
   script returns <<<false>>> which causes the Invoker Plugin to log that the build failed.
-  The global variable <<<basedir>>> of type <<<java.io.File>>> can be used to refer to the
-  base directory of the current integration test.
           
 -------------------
 import java.io.*;
@@ -92,3 +90,17 @@
 return true;
 -------------------
 
+  Complementary to the post build hook script, you can also create a pre build hook script that will be run before
+  the invocation of Maven. This can be used to do some preparations for the build.
+
+  To allow the scripts to locate files from the test project, the following global variables will be defined by the
+  Invoker Plugin before running the script:
+
+*--------------------------+----------------------+-----------------------------------------------------------+--------+
+|| Name                    || Type                || Description                                              || Since |
+*--------------------------+----------------------+-----------------------------------------------------------+--------+
+| basedir                  | java.io.File         | The absolute path to the base directory of the test project. | 1.0   |
+*--------------------------+----------------------+-----------------------------------------------------------+--------+
+| localRepositoryPath      | java.io.File         | The absolute path to the local repository used for the Maven invocation. | 1.3   |
+*--------------------------+----------------------+-----------------------------------------------------------+--------+
+  
\ No newline at end of file

Modified: maven/plugins/trunk/maven-invoker-plugin/src/site/apt/usage.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/site/apt/usage.apt.vm?rev=684373&r1=684372&r2=684373&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/site/apt/usage.apt.vm (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/site/apt/usage.apt.vm Sat Aug  9 15:42:51 2008
@@ -123,6 +123,5 @@
 
   When an integration test has finished, the plugin will invoke an optional post build hook script. In the example,
   this is the case for <<<second-it>>> where <<<verify.bsh>>> will be run. The purpose of this script is usally to
-  check that the build of the integration test did not only succeed but also produced the intended output. To allow the
-  script to locate the IT project's output, the Invoker Plugin will inject the variable <<<basedir>>> into the script.
-  Have a look at the example {{{examples/post-build-script.html}Using a Post Build Script}} for a code snippet.
+  check that the build of the integration test did not only succeed but also produced the intended output. Have a look
+  at the example {{{examples/post-build-script.html}Using a Post Build Script}} for a code snippet.