Gradle plugin to run embedded PostgreSQL server, based on the postgresql-embedded project.
Build script snippet for use in all Gradle versions:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.github.honourednihilist:gradle-postgresql-embedded:0.4.0"
}
}
apply plugin: "com.github.honourednihilist.gradle-postgresql-embedded"
Build script snippet for new, incubating, plugin mechanism introduced in Gradle 2.1:
plugins {
id "com.github.honourednihilist.gradle-postgresql-embedded" version "0.4.0"
}
The gradle-postgresql-embedded plugin adds only one task - startPostgres. This task runs an embedded PostgreSQL server and stops it when the build is finished (by default). You can make your tasks dependent on it. Here is an example of how the plugin is used in a 'real-world' project - gradle-postgresql-embedded-example.
These are all possible configuration options and its default values:
postgresEmbedded {
version = "V10"
host = "localhost"
port = 0 // zero value means a random port
dbName = "embedded"
username = "username"
password = "password"
artifactStorePath = "~/.embedpostgresql" // where PostgreSQL distributions are stored after downloading, inside home directory by default
stopWhenBuildFinished = true
timeoutMillisBeforeStop = 0
}
You can specify any supported version from postgresql-embedded, and a custom version of PostgreSQL as well.
For example, you can use versions from PostgreSQL Binaries if you need a newer (or older) version of PostgreSQL which is not supported by this plugin at the moment.
postgresEmbedded {
version = "9.3.22-1"
}
postgresEmbedded {
version = "10.3-1"
}