slavaz/embedded-postgresql-maven-plugin


Embedded PostgreSQL Maven Plugin

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.slavaz:embedded-postgresql-maven-plugin:embedded-postgresql-maven-plugin-1.2.4'
	}
	dependencies {
		implementation("com.github.slavaz:embedded-postgresql-maven-plugin:embedded-postgresql-maven-plugin-1.2.4")
	}
	<dependency>
	    <groupId>com.github.slavaz</groupId>
	    <artifactId>embedded-postgresql-maven-plugin</artifactId>
	    <version>embedded-postgresql-maven-plugin-1.2.4</version>
	</dependency>

                            
    libraryDependencies += "com.github.slavaz" % "embedded-postgresql-maven-plugin" % "embedded-postgresql-maven-plugin-1.2.4"
        
        

                            
    :dependencies [[com.github.slavaz/embedded-postgresql-maven-plugin "embedded-postgresql-maven-plugin-1.2.4"]]
        
        

Readme


embedded-postgresql-maven-plugin

Build status

Description

Embedded PostgreSQL Maven Plugin provides a platform neutral way for running postgres server in integration tests. This plugin is based on Embedded PostgreSQL Server library

Configuration

pgServerVersion

The plugin currently supports next PostgreSQL versions: 9.5.7, 9.6.5, 10.0

You also may use aliases:

  • 9.5 -> 9.5.7
  • 9.6 -> 9.6.5
  • latest -> 10.0

pgDatabaseDir

Where server files will be plased. Default {project.build.directory}/pgdata

pgHost

Host(IP address) for listening incoming connections.

pgPort

Port for listening incoming connections.

pgLocale

Locale for embedded PostgreSQL server. Leave empty for running the server with system locale. Specify "no" to skip locale & charset definition.

pgCharset

Charset for embedded PostgreSQL server. Leave empty for running the server with system charset. Specify "no" to skip locale & charset definition.

dbName

Database name. Will be created

userName

User name. Will be created

password

User password for newly created user

pgDumpFile

A SQL dump for apply to the DB.

Usage example

Starts PostgreSQL server, creates a database and a user with specified password

...
<build>
    ..
    <plugins>
      <plugin>
        <groupId>com.github.slavaz</groupId>
        <artifactId>embedded-postgresql-maven-plugin</artifactId>
        <configuration>
          <pgServerVersion>9.5</pgServerVersion>
          <pgServerPort>15432</pgServerPort>
          <dbName>testdb</dbName>
          <userName>testuser</userName>
          <password>userpass</password>
        </configuration>
        <executions>
          <execution>
            <id>start-pgsql</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>start</goal>
            </goals>
          </execution>
          <execution>
            <id>stop-pgsql</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
</build>

Goals

  1. start -- start the server
  2. stop -- stop the server