You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2006/10/20 05:34:40 UTC

svn commit: r465964 - in /maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/maven/plugin/ src/...

Author: jvanzyl
Date: Thu Oct 19 20:34:39 2006
New Revision: 465964

URL: http://svn.apache.org/viewvc?view=rev&rev=465964
Log:
decomposing another IT

Added:
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/pom.xml   (with props)
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/CatchMojo.java   (with props)
    maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/ThrowMojo.java   (with props)

Added: maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/pom.xml?view=auto&rev=465964
==============================================================================
--- maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/pom.xml (added)
+++ maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/pom.xml Thu Oct 19 20:34:39 2006
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Copyright 2005-2006 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.
+  -->
+
+<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">
+  <parent>
+    <artifactId>maven-plugins</artifactId>
+    <groupId>org.apache.maven.plugins</groupId>
+    <version>2-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>maven-core-it-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+  <name>Maven Core Integration Test Plugin</name>
+  <version>1.1-SNAPSHOT</version>
+  <inceptionYear>2001</inceptionYear>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-artifact</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-archiver</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>jline</groupId>
+      <artifactId>jline</artifactId>
+      <version>0.9.1</version>
+    </dependency>
+    <dependency>
+      <groupId>bsh</groupId>
+      <artifactId>bsh</artifactId>
+      <version>1.3.0</version>
+    </dependency>
+  </dependencies>
+</project>

Propchange: maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/CatchMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/CatchMojo.java?view=auto&rev=465964
==============================================================================
--- maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/CatchMojo.java (added)
+++ maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/CatchMojo.java Thu Oct 19 20:34:39 2006
@@ -0,0 +1,78 @@
+package org.apache.maven.plugin.coreit;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * "Catch" a parameter "thrown" by the ThrowMojo through the plugin context, and
+ * write a file based on it's value to the build output directory.
+ * 
+ * @goal catch
+ */
+public class CatchMojo
+    extends AbstractMojo
+{
+
+    /**
+     * @parameter expression="${project.build.directory}"
+     * @required
+     * @readonly
+     */
+    private File outDir;
+    
+    public File getOutDir()
+    {
+        return outDir;
+    }
+    
+    public void setOutDir( File outDir )
+    {
+        this.outDir = outDir;
+    }
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        String value = (String) getPluginContext().get( ThrowMojo.THROWN_PARAMETER );
+
+        if ( !outDir.exists() )
+        {
+            outDir.mkdirs();
+        }
+        
+        File outfile = new File( outDir, value );
+
+        Writer writer = null;
+        try
+        {
+            writer = new FileWriter( outfile );
+            
+            writer.write( value );
+            
+            writer.flush();
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Cannot write output file: " + outfile, e );
+        }
+        finally
+        {
+            if ( writer != null )
+            {
+                try
+                {
+                    writer.close();
+                }
+                catch ( IOException e )
+                {
+                }
+            }
+        }
+    }
+
+}

Propchange: maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/CatchMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/CatchMojo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/ThrowMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/ThrowMojo.java?view=auto&rev=465964
==============================================================================
--- maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/ThrowMojo.java (added)
+++ maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/ThrowMojo.java Thu Oct 19 20:34:39 2006
@@ -0,0 +1,39 @@
+package org.apache.maven.plugin.coreit;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * "Throw" a parameter into the plugin context, for the "catch" mojo to 
+ * pickup and process.
+ * 
+ * @goal throw
+ */
+public class ThrowMojo
+    extends AbstractMojo
+{
+    
+    public static final String THROWN_PARAMETER = "throw-parameter";
+
+    /**
+     * @parameter expression="${value}" default-value="thrown"
+     */
+    private String value;
+    
+    public void setValue( String value )
+    {
+        this.value = value;
+    }
+    
+    public String getValue()
+    {
+        return value;
+    }
+    
+    public void execute()
+        throws MojoExecutionException
+    {
+        getPluginContext().put( THROWN_PARAMETER, value );
+    }
+
+}

Propchange: maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/ThrowMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/maven-it/maven-it-plugins/maven-it-plugin-context-passing/src/main/java/org/apache/maven/plugin/coreit/ThrowMojo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"