activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From foco...@apache.org
Subject svn commit: r428654 - in /incubator/activemq/trunk/tooling: maven-bundle-plugin/ maven-bundle-plugin/src/ maven-bundle-plugin/src/main/ maven-bundle-plugin/src/main/java/ maven-bundle-plugin/src/main/java/org/ maven-bundle-plugin/src/main/java/org/apac...
Date Fri, 04 Aug 2006 07:32:47 GMT
Author: foconer
Date: Fri Aug  4 00:32:46 2006
New Revision: 428654

URL: http://svn.apache.org/viewvc?rev=428654&view=rev
Log:
Sorry, wasn't included in the previous checkin. Related to AMQ-858.

Added:
    incubator/activemq/trunk/tooling/maven-bundle-plugin/
    incubator/activemq/trunk/tooling/maven-bundle-plugin/pom.xml
    incubator/activemq/trunk/tooling/maven-bundle-plugin/src/
    incubator/activemq/trunk/tooling/maven-bundle-plugin/src/main/
    incubator/activemq/trunk/tooling/maven-bundle-plugin/src/main/java/
    incubator/activemq/trunk/tooling/maven-bundle-plugin/src/main/java/org/
    incubator/activemq/trunk/tooling/maven-bundle-plugin/src/main/java/org/apache/
    incubator/activemq/trunk/tooling/maven-bundle-plugin/src/main/java/org/apache/activemq/
    incubator/activemq/trunk/tooling/maven-bundle-plugin/src/main/java/org/apache/activemq/maven/
    incubator/activemq/trunk/tooling/maven-bundle-plugin/src/main/java/org/apache/activemq/maven/BundleMojo.java
    incubator/activemq/trunk/tooling/maven-gram-plugin/
    incubator/activemq/trunk/tooling/maven-gram-plugin/pom.xml
    incubator/activemq/trunk/tooling/maven-gram-plugin/src/
    incubator/activemq/trunk/tooling/maven-gram-plugin/src/main/
    incubator/activemq/trunk/tooling/maven-gram-plugin/src/main/java/
    incubator/activemq/trunk/tooling/maven-gram-plugin/src/main/java/org/
    incubator/activemq/trunk/tooling/maven-gram-plugin/src/main/java/org/apache/
    incubator/activemq/trunk/tooling/maven-gram-plugin/src/main/java/org/apache/activemq/
    incubator/activemq/trunk/tooling/maven-gram-plugin/src/main/java/org/apache/activemq/maven/
    incubator/activemq/trunk/tooling/maven-gram-plugin/src/main/java/org/apache/activemq/maven/GramMojo.java

Added: incubator/activemq/trunk/tooling/maven-bundle-plugin/pom.xml
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-bundle-plugin/pom.xml?rev=428654&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-bundle-plugin/pom.xml (added)
+++ incubator/activemq/trunk/tooling/maven-bundle-plugin/pom.xml Fri Aug  4 00:32:46 2006
@@ -0,0 +1,69 @@
+<?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
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns="http://maven.apache.org/POM/4.0.0">
+  
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.activemq</groupId>
+    <artifactId>activemq-parent</artifactId>
+    <version>4.1-incubator-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>maven-bundle-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+  <name>Bundle Plugin</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-archiver</artifactId>
+      <version>1.0-alpha-5</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-archiver</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>1.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-artifact</artifactId>
+      <version>2.0</version>
+    </dependency>
+  </dependencies>
+</project>

Added: incubator/activemq/trunk/tooling/maven-bundle-plugin/src/main/java/org/apache/activemq/maven/BundleMojo.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-bundle-plugin/src/main/java/org/apache/activemq/maven/BundleMojo.java?rev=428654&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-bundle-plugin/src/main/java/org/apache/activemq/maven/BundleMojo.java
(added)
+++ incubator/activemq/trunk/tooling/maven-bundle-plugin/src/main/java/org/apache/activemq/maven/BundleMojo.java
Fri Aug  4 00:32:46 2006
@@ -0,0 +1,132 @@
+package org.apache.activemq.maven;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.UnArchiver;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * @goal createbundle
+ * @description Creates an xfire bundle
+ */
+public class BundleMojo extends AbstractMojo 
+{
+    /**
+     * The output directory of the assembled distribution file.
+     *
+     * @parameter expression="${project.build.outputDirectory}"
+     * @required
+     */
+    protected File outputDirectory;
+    
+    /**
+     * Inclusion list
+     *
+     * @parameter
+     */
+    String includes = "";
+    
+    /**
+     * The Maven Project.
+     *
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    MavenProject project;
+    
+    /**
+     * To look up Archiver/UnArchiver implementations
+     *
+     * @parameter expression="${component.org.codehaus.plexus.archiver.manager.ArchiverManager}"
+     * @required
+     */
+    protected ArchiverManager archiverManager;
+    
+    public void execute() throws MojoExecutionException 
+    {
+        String[] include = includes.split(",");
+        List includeList = Arrays.asList(include);
+        getLog().info("Inclusions: " + includeList);
+        getLog().info("OutputDirectory: " + outputDirectory);
+        outputDirectory.mkdirs();
+        
+        for (Iterator itr = project.getArtifacts().iterator(); itr.hasNext();)
+        {
+            Artifact a = (Artifact) itr.next();
+
+            if (includeList.contains(a.getArtifactId()) && "jar".equals(a.getType())
)
+            {
+                getLog().info("Found " + a.getArtifactId());
+                
+                try 
+                {
+                    unpack( a.getFile(), outputDirectory );
+                } 
+                catch (MojoExecutionException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                } 
+                catch (NoSuchArchiverException e) {
+                    // TODO Auto-generated catch block
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+    
+    protected void unpack( File file, File location )
+        throws MojoExecutionException, NoSuchArchiverException
+    {
+        String archiveExt = FileUtils.getExtension( file.getAbsolutePath() ).toLowerCase();
+    
+        try
+        {
+        	getLog().info("Extracting: "+file+": to "+location);
+            UnArchiver unArchiver = this.archiverManager.getUnArchiver( archiveExt );
+            unArchiver.setSourceFile( file );
+            unArchiver.setDestDirectory( location );
+            unArchiver.extract();
+            
+            File metaDir = new File(location, "META-INF");
+            File jarMetaDir = new File(metaDir, file.getName());            
+            FileUtils.mkdir(jarMetaDir.getAbsolutePath());
+            
+            File[] files = metaDir.listFiles();
+            for (int i = 0; i < files.length; i++) {
+				String name = files[i].getName();
+				if( 
+					name.toUpperCase().startsWith("MANIFEST.MF") || 
+					name.toUpperCase().startsWith("COPYRIGHT") || 
+					name.toUpperCase().startsWith("LICENSE") || 
+					name.toUpperCase().startsWith("NOTICE") || 
+					name.toUpperCase().startsWith("DISCLAIMER") 
+				) {
+					
+		            FileUtils.copyFileToDirectory(files[i], jarMetaDir);
+		            files[i].delete();
+				}
+			}
+            
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Error unpacking file: " + file + "to: " +
location, e );
+        }
+        catch ( ArchiverException e )
+        {
+            throw new MojoExecutionException( "Error unpacking file: " + file + "to: " +
location, e );
+        }
+    }
+}

Added: incubator/activemq/trunk/tooling/maven-gram-plugin/pom.xml
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-gram-plugin/pom.xml?rev=428654&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-gram-plugin/pom.xml (added)
+++ incubator/activemq/trunk/tooling/maven-gram-plugin/pom.xml Fri Aug  4 00:32:46 2006
@@ -0,0 +1,104 @@
+<?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
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns="http://maven.apache.org/POM/4.0.0">
+  
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.activemq</groupId>
+    <artifactId>activemq-parent</artifactId>
+    <version>4.1-incubator-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+
+  <artifactId>maven-gram-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+  <name>Gram Plugin</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-archiver</artifactId>
+      <version>1.0-alpha-5</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-archiver</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>1.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-artifact</artifactId>
+      <version>2.0</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>groovy</groupId>
+      <artifactId>groovy-all</artifactId>
+      <version>1.0-jsr-03</version>
+    </dependency>
+    <dependency>
+      <groupId>annogen</groupId>
+      <artifactId>annogen</artifactId>
+      <version>0.1.0</version>
+    </dependency>
+    
+  </dependencies>
+  
+  <profiles>
+    <profile>
+      <id>default-tools.jar</id>
+      <activation>
+        <property>
+          <name>java.vendor</name>
+          <value>Sun Microsystems Inc.</value>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>com.sun</groupId>
+          <artifactId>tools</artifactId>
+          <version>1.4.2</version>
+          <scope>system</scope>
+          <systemPath>${java.home}/../lib/tools.jar</systemPath>
+        </dependency>
+      </dependencies>
+    </profile>
+  </profiles>
+ 
+</project>

Added: incubator/activemq/trunk/tooling/maven-gram-plugin/src/main/java/org/apache/activemq/maven/GramMojo.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-gram-plugin/src/main/java/org/apache/activemq/maven/GramMojo.java?rev=428654&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-gram-plugin/src/main/java/org/apache/activemq/maven/GramMojo.java
(added)
+++ incubator/activemq/trunk/tooling/maven-gram-plugin/src/main/java/org/apache/activemq/maven/GramMojo.java
Fri Aug  4 00:32:46 2006
@@ -0,0 +1,146 @@
+/**
+ *
+ * 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.
+ */
+package org.apache.activemq.maven;
+
+import groovy.lang.GroovyShell;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.groovy.control.CompilationFailedException;
+import org.codehaus.jam.JamService;
+import org.codehaus.jam.JamServiceFactory;
+import org.codehaus.jam.JamServiceParams;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+
+/**
+ * Greates a Mojo for Gram.
+ * 
+ * This module is largly based on the Gram class here:
+ * http://cvs.groovy.codehaus.org/browse/groovy/groovy/modules/gram/src/main/org/codehaus/gram/Gram.java?r=1.4
+ * 
+ * We need to get this moved over the groovy project eventually.. Putting in ActiveMQ for
now so we can keep going.
+ * 
+ * @goal gram
+ * @description Runs the Gram code generator
+ */
+public class GramMojo extends AbstractMojo 
+{
+    /**
+     * Source directories of the project.
+     *
+     * @parameter expression="${project.compileSourceRoots}"
+     * @required
+     * @readonly
+     */
+    private List sourceDirs;
+
+
+    /**
+     * @parameter
+     * @required
+     */
+    String scripts = "";
+    
+    /**
+     * @parameter
+     */
+    Map groovyProperties = Collections.EMPTY_MAP;
+    
+    /**
+     * To look up Archiver/UnArchiver implementations
+     *
+     * @parameter expression="${component.org.codehaus.plexus.archiver.manager.ArchiverManager}"
+     * @required
+     */
+    protected ArchiverManager archiverManager;
+    
+    public void execute() throws MojoExecutionException 
+    {
+
+        try {
+        	
+            System.out.println("Parsing source files in: " + sourceDirs);
+
+            JamServiceFactory jamServiceFactory = JamServiceFactory.getInstance();
+            JamServiceParams params = jamServiceFactory.createServiceParams();
+            
+            File[] dirs = new File[sourceDirs.size()];
+            {
+	            int i=0;
+	            for (Iterator iter = sourceDirs.iterator(); iter.hasNext();) {
+					dirs[i++] = new File((String) iter.next());
+				}
+            }
+            
+            params.includeSourcePattern(dirs, "**/*.java");
+            JamService jam = jamServiceFactory.createService(params);
+
+            String[] scriptsArray = scripts.split(":");
+            for (int i = 1; i < scriptsArray.length; i++) {
+                String script = scriptsArray[i].trim();
+                if(script.length() > 0 ) {
+	                getLog().info("Evaluating Groovy script: " + script);
+	                execute(jam, script);
+                }
+            }
+        }
+        catch (Exception e) {
+        	getLog().error("Caught: " + e, e);
+        }
+    }
+    
+    public void execute(JamService jam, String script) throws CompilationFailedException,
IOException {
+        File file = new File(script);
+        if (file.isFile()) {
+            GroovyShell shell = createShell(jam);
+            shell.evaluate(file);
+        }
+        else {
+            // lets try load the script on the classpath
+            InputStream in = getClass().getClassLoader().getResourceAsStream(script);
+            if (in == null) {
+                in = Thread.currentThread().getContextClassLoader().getResourceAsStream(script);
+                if (in == null) {
+                    throw new IOException("No script called: " + script + " could be found
on the classpath or the file system");
+                }
+            }
+            GroovyShell shell = createShell(jam);
+            shell.evaluate(in, script);
+        }
+    }
+
+    protected GroovyShell createShell(JamService jam) {
+        GroovyShell answer = new GroovyShell();
+        for (Iterator iter = groovyProperties.entrySet().iterator(); iter.hasNext();) {
+			Map.Entry entry = (Map.Entry) iter.next();
+	        answer.setProperty((String) entry.getKey(), entry.getValue());
+		}
+        answer.setProperty("jam", jam);
+        answer.setProperty("classes", jam.getAllClasses());
+        return answer;
+    }
+    
+}



Mime
View raw message