Author: jdcasey
Date: Fri May 25 08:14:03 2007
New Revision: 541688

URL: http://svn.apache.org/viewvc?view=rev&rev=541688
Log:
Starting an examples space for sample plugins, etc. showing how to use various 
apis. the first example is using maven-antcall (just added to sandbox/shared) 
to call the Echo task from Ant.

Added:
    maven/sandbox/trunk/examples/
    maven/sandbox/trunk/examples/plugins/
    maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/
    maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/pom.xml   
(with props)
    maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/
    maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/main/
    
maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/main/java/
    
maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/main/java/org/
    
maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/main/java/org/apache/
    
maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/main/java/org/apache/maven/
    
maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/main/java/org/apache/maven/example/
    
maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/main/java/org/apache/maven/example/plugin/
    
maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/main/java/org/apache/maven/example/plugin/antapi/
    
maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/main/java/org/apache/maven/example/plugin/antapi/EchoMojo.java
   (with props)

Added: maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/pom.xml?view=auto&rev=541688
==============================================================================
--- maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/pom.xml 
(added)
+++ maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/pom.xml Fri 
May 25 08:14:03 2007
@@ -0,0 +1,33 @@
+<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.example.plugins</groupId>
+  <artifactId>maven-ant-api-call-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>maven-ant-api-call-plugin Maven Mojo</name>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-antcall</artifactId>
+      <version>1.0-alpha-4-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>ant</groupId>
+      <artifactId>ant</artifactId>
+      <version>1.6.5</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

Propchange: 
maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: 
maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/main/java/org/apache/maven/example/plugin/antapi/EchoMojo.java
URL: 
http://svn.apache.org/viewvc/maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/main/java/org/apache/maven/example/plugin/antapi/EchoMojo.java?view=auto&rev=541688
==============================================================================
--- 
maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/main/java/org/apache/maven/example/plugin/antapi/EchoMojo.java
 (added)
+++ 
maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/main/java/org/apache/maven/example/plugin/antapi/EchoMojo.java
 Fri May 25 08:14:03 2007
@@ -0,0 +1,70 @@
+package org.apache.maven.example.plugin.antapi;
+
+/*
+ * 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.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.tools.ant.taskdefs.Echo;
+import org.codehaus.mojo.tools.antcall.AntCaller;
+import org.codehaus.mojo.tools.antcall.AntExecutionException;
+import org.codehaus.mojo.tools.antcall.MojoLogAdapter;
+
+/**
+ * Echos the specified message parameter out to the build console, using Ant's 
Echo task.
+ * 
+ * @goal echo
+ */
+public class EchoMojo
+    extends AbstractMojo
+{
+    /**
+     * Message to echo.
+     * @parameter expression="${message}"
+     * @required
+     */
+    private String message;
+    
+    /**
+     * Current project being built, used to supply properties and paths to Ant.
+     * @parameter default-value="${project}"
+     * @required
+     * @readonly
+     */
+    private MavenProject project;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        AntCaller caller = new AntCaller( new MojoLogAdapter( getLog() ) );
+        
+        Echo echoTask = new Echo();
+        echoTask.setTaskName( "echo" );
+        echoTask.setMessage( message );
+        
+        caller.addTask( echoTask );
+        
+        try
+        {
+            caller.executeTasks( project );
+        }
+        catch ( AntExecutionException e )
+        {
+            throw new MojoExecutionException( "Failed to echo your message to 
the console. Reason: " + e.getMessage(), e );
+        }
+    }
+}

Propchange: 
maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/main/java/org/apache/maven/example/plugin/antapi/EchoMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/sandbox/trunk/examples/plugins/maven-ant-api-call-plugin/src/main/java/org/apache/maven/example/plugin/antapi/EchoMojo.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"


Reply via email to