Skip to content

Instantly share code, notes, and snippets.

@cjmamo
Created July 1, 2015 13:18
Show Gist options
  • Save cjmamo/a0993e6cbedfe6b60737 to your computer and use it in GitHub Desktop.
Save cjmamo/a0993e6cbedfe6b60737 to your computer and use it in GitHub Desktop.
Adding PostgreSQL to a Self-Contained Maven Build
<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">
...
<build>
...
<plugins>
...
<plugin>
<groupId>com.github.adrianboimvaser</groupId>
<artifactId>postgresql-maven-plugin</artifactId>
<version>0.2</version>
<configuration>
<pgsqlHome>${project.build.directory}/pgsql</pgsqlHome>
<dataDir>${project.build.directory}/data</dataDir>
<skip>${skipITs}</skip>
<username>postgres</username>
<databaseName>foo</databaseName>
<encoding>UTF8</encoding>
<locale>en_US</locale>
</configuration>
<executions>
<execution>
<id>version-check</id>
<phase>pre-integration-test</phase>
<goals>
<goal>version</goal>
</goals>
</execution>
<execution>
<id>init-db</id>
<phase>pre-integration-test</phase>
<goals>
<goal>initdb</goal>
</goals>
</execution>
<execution>
<id>start-postgresql</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>create-db</id>
<phase>pre-integration-test</phase>
<goals>
<goal>createdb</goal>
</goals>
</execution>
<execution>
<id>drop-db</id>
<phase>post-integration-test</phase>
<goals>
<goal>dropdb</goal>
</goals>
</execution>
<execution>
<id>stop-postgresql</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment