Forum: Building VoltDB Applications

Post: Maven pom.xml for stored procedures project

Maven pom.xml for stored procedures project
fady
Aug 29, 2011
I just got this to work so I thought this might help others:

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
  
    <groupId>com.legsem</groupId>
    <artifactId>voltdb.test.server</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
  
    <name>voltdb.test.server</name>
  
    <dependencies>
        
        <!-- This can be refined. This uber jar bundles everything. -->
        <dependency>
            <groupId>org.voltdb</groupId>
            <artifactId>voltdbfat</artifactId>
            <version>1.3.6.1</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
  
    <build>
 
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <!-- Voltdb mandates JDK 1.6 -->
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
 
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <!-- Compile the voltdb catalog so that it is available for unit testing -->
                    <execution>
                        <phase>compile</phase>
                        <configuration>
                            <target>
                                <java classname="org.voltdb.compiler.VoltCompiler" fork="yes" failonerror="true">
                                    <jvmarg value="-Dlog4j.configuration=file:src/test/resources/log4j.properties"/>
                                    <arg value="project.xml"/>
                                    <arg value="${project.build.directory}/${project.build.finalName}-catalog.jar"/>
                                    <classpath refid="maven.compile.classpath"/>
                                    <assertions>
                                        <disable/>
                                    </assertions>
                                </java>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <!-- Make sure voltdb native libraries are on the path -->
                    <argLine>-Djava.library.path=${env.VOLTDB_HOME}/voltdb</argLine>
                    <systemPropertyVariables>
                        <!-- Provide a log4j configuration -->
                        <log4j.configuration>file:src/test/resources/log4j.properties</log4j.configuration>
                    </systemPropertyVariables>
                    <environmentVariables>
                        <!-- Force voltdb to use maven conventions for generated artifacts location -->
                        <TEST_DIR>target</TEST_DIR>
                    </environmentVariables>
                </configuration>
            </plugin>
        
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <!-- Attach the voltdb catalog so that it gets uploaded to the maven repo -->
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>${project.build.directory}/${project.build.finalName}-catalog.jar</file>
                                    <type>jar</type>
                                    <classifier>catalog</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>

    </build>
  
</project>



The objective is to generate the voltdb catalog archive as part of a maven lifecycle.

Cheers
krishnaprasadas@gmail.com
Oct 3, 2013
Hi fady,
I just tried to create the catalog.jar file from my eclipse using maven and the plugin you suggested, But I got a class not found error (Class Name : org/hsqldb_voltpatches/HSQLInterface).
But the class file was there in my maven dependency lib.
What may be the problem ?
From where you got the dependency for 'voltdbfat' jar, I failed to download it ?(I tried with out this jar)
My voltdb version is 2.8.2.
Please help...