activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r690372 - in /activemq/sandbox/activemq-protobuf: activemq-protobuf-test/ activemq-protobuf-test/pom.xml activemq-protobuf/pom.xml activemq-protobuf/src/main/java/org/apache/activemq/protobuf/compiler/ProtoMojo.java pom.xml
Date Fri, 29 Aug 2008 19:25:33 GMT
Author: chirino
Date: Fri Aug 29 12:25:33 2008
New Revision: 690372

URL: http://svn.apache.org/viewvc?rev=690372&view=rev
Log:
Made a maven mojo.. setting up a test module 

Added:
    activemq/sandbox/activemq-protobuf/activemq-protobuf-test/
    activemq/sandbox/activemq-protobuf/activemq-protobuf-test/pom.xml
    activemq/sandbox/activemq-protobuf/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/compiler/ProtoMojo.java
    activemq/sandbox/activemq-protobuf/pom.xml
Modified:
    activemq/sandbox/activemq-protobuf/activemq-protobuf/pom.xml

Added: activemq/sandbox/activemq-protobuf/activemq-protobuf-test/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-protobuf/activemq-protobuf-test/pom.xml?rev=690372&view=auto
==============================================================================
--- activemq/sandbox/activemq-protobuf/activemq-protobuf-test/pom.xml (added)
+++ activemq/sandbox/activemq-protobuf/activemq-protobuf-test/pom.xml Fri Aug 29 12:25:33
2008
@@ -0,0 +1,80 @@
+<?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>
+
+  <parent>
+    <groupId>org.apache.activemq.protobuf</groupId>
+    <artifactId>activemq-protobuf-pom</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.activemq.protobuf</groupId>
+  <artifactId>activemq-protobuf-test</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  
+  <packaging>jar</packaging>
+  <name>ActiveMQ Protocol Buffers Tests</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.4</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq.protobuf</groupId>
+      <artifactId>activemq-protobuf</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <includes>
+            <include>**/*Test.java</include>
+          </includes>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.activemq.protobuf</groupId>
+        <artifactId>activemq-protobuf</artifactId>
+        <version>1.0-SNAPSHOT</version>
+         <executions>
+          <execution>
+            <goals>
+              <goal>compile</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  
+</project>

Modified: activemq/sandbox/activemq-protobuf/activemq-protobuf/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-protobuf/activemq-protobuf/pom.xml?rev=690372&r1=690371&r2=690372&view=diff
==============================================================================
--- activemq/sandbox/activemq-protobuf/activemq-protobuf/pom.xml (original)
+++ activemq/sandbox/activemq-protobuf/activemq-protobuf/pom.xml Fri Aug 29 12:25:33 2008
@@ -18,29 +18,49 @@
 <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>
-  
+  <parent>
+    <groupId>org.apache.activemq.protobuf</groupId>
+    <artifactId>activemq-protobuf-pom</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
   <groupId>org.apache.activemq.protobuf</groupId>
   <artifactId>activemq-protobuf</artifactId>
   <version>1.0-SNAPSHOT</version>
-  <packaging>jar</packaging>
-  <name>A Simple Protocol Buffer Java API</name>
+  <packaging>maven-plugin</packaging>
+  
+  <name>ActiveMQ Protocol Buffers Implementation and Compiler</name>
 
   <description>
-    A Simpler Protocol Buffer Java API.  Comes with a built in proto file compiler and Java
source code generator.
+    A Simpler Protocol Buffer Java API.  Includes a Proto to Java compiler.
   </description>
 
   <dependencies>
     <dependency>
+      <groupId>com.google.protobuf</groupId>
+      <artifactId>protobuf-java</artifactId>
+      <version>2.0.1rc1</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0</version>
+      <optional>true</optional>
+    </dependency>
+    
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>4.4</version>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>com.google.protobuf</groupId>
-      <artifactId>protobuf-java</artifactId>
-      <version>2.0.1rc1</version>
-    </dependency>
   </dependencies>
 
   <build>

Added: activemq/sandbox/activemq-protobuf/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/compiler/ProtoMojo.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-protobuf/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/compiler/ProtoMojo.java?rev=690372&view=auto
==============================================================================
--- activemq/sandbox/activemq-protobuf/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/compiler/ProtoMojo.java
(added)
+++ activemq/sandbox/activemq-protobuf/activemq-protobuf/src/main/java/org/apache/activemq/protobuf/compiler/ProtoMojo.java
Fri Aug 29 12:25:33 2008
@@ -0,0 +1,95 @@
+/**
+ * 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.protobuf.compiler;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.activemq.protobuf.compiler.JavaGenerator.CompilerException;
+import org.apache.activemq.protobuf.compiler.parser.ParseException;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * A Maven Mojo so that the Proto compiler can be used with maven.
+ * 
+ * @goal compile
+ * @phase process-sources
+ */
+public class ProtoMojo extends AbstractMojo {
+
+    /**
+     * The maven project.
+     * 
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    protected MavenProject project;
+
+    /**
+     * The directory where the proto files (<code>*.proto</code>) are
+     * located.
+     * 
+     * @parameter expression="${sourceDirectory}" default-value="${basedir}/src/main/proto"
+     */
+    private File sourceDirectory;
+
+    /**
+     * The directory where the output files will be located.
+     * 
+     * @parameter expression="${outputDirectory}" default-value="${project.build.directory}/generated-sources/proto"
+     */
+    private File outputDirectory;
+
+    public void execute() throws MojoExecutionException {
+
+        File[] files = sourceDirectory.listFiles(new FileFilter() {
+            public boolean accept(File pathname) {
+                return pathname.getName().endsWith(".proto");
+            }
+        });
+        
+        if (files==null || files.length==0) {
+            getLog().warn("No proto files found in directory: " + sourceDirectory.getPath());
+            return;
+        }
+        
+        List<File> recFiles = Arrays.asList(files);
+        for (File file : recFiles) {
+            try {
+                JavaGenerator generator = new JavaGenerator();
+                generator.setOutputDirectory(outputDirectory);
+                generator.compile(file);
+            } catch (ParseException e) {
+                throw new MojoExecutionException("Parse failed: " + e.getMessage(), e);
+            } catch (CompilerException e) {
+                throw new MojoExecutionException("Compile failed", e);
+            } catch (IOException e) {
+                throw new MojoExecutionException("IO Error occured: " + e.getMessage(), e);
+            }
+        }
+
+        this.project.addCompileSourceRoot(outputDirectory.getAbsolutePath());
+    }
+
+}

Added: activemq/sandbox/activemq-protobuf/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-protobuf/pom.xml?rev=690372&view=auto
==============================================================================
--- activemq/sandbox/activemq-protobuf/pom.xml (added)
+++ activemq/sandbox/activemq-protobuf/pom.xml Fri Aug 29 12:25:33 2008
@@ -0,0 +1,39 @@
+<?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.activemq.protobuf</groupId>
+  <artifactId>activemq-protobuf-pom</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  
+  <packaging>pom</packaging>
+  <name>ActiveMQ Protocol Buffers POM</name>
+
+  <description>
+    A Simpler Protocol Buffer Java API.  Comes with a built in proto file compiler and Java
source code generator.
+  </description>
+
+  <modules>
+    <module>activemq-protobuf</module>
+    <module>activemq-protobuf-test</module>
+  </modules>
+
+  
+</project>



Mime
View raw message