chatwork / sbt-wix-embedded-mysql

sbt-wix-embedded-mysql is sbt-plugin for wix-embedded-mysql

GitHub

sbt-wix-embedded-mysql

Build Status Maven Central Scaladoc Reference Status

sbt-wix-embedded-mysql is sbt-plugin for wix-embedded-mysql

You can start and stop embedded MySQL on sbt task.

Installation

Add this to your project/plugins.sbt file:

project/plugins.sbt

Supported sbt version is 1.x.

resolvers += "Sonatype OSS Release Repository" at "https://oss.sonatype.org/content/repositories/releases/"

addSbtPlugin("com.chatwork" % "sbt-wix-embedded-mysql" % "1.0.11")

Usage

Basic Configuration

If you want default settings, no configuration is necessary. Please refer to here for sbt keys of the plugin.These sbt keys base on the API of wix-embedded-mysql. If you understand how to use wix-embedded-mysql, it is easy to use this plugin.

An example for configuration

build.sbt

wixMySQLVersion := com.wix.mysql.distribution.Version.v5_7_latest

wixMySQLSchemaName := "your schema name"

wixMySQLUserName := Some("my-db-user")

wixMySQLPassword := Some("my-db-passwd")

Task of sbt

You can use sbt tasks that the followings.

// start mysqld
> wixMySQLStart

// stop mysqld
> wixMySQLStop

How to use for testing

build.sbt

testOptions in Test ++= Seq(
  Tests.Setup { () =>
    wixMySQLStart.value
    // If you want to use the flywayMigrate together, please join the two tasks using `Def.sequential` as follows.
    // Def.sequential(wixMySQLStart, flywayMigrate).value
  },
  Tests.Cleanup { () =>
    wixMySQLStop.value
  }
)

How to use on Travis

.travis.yml

# -- snip

before_install:
 - sudo apt-get update -qq && sudo apt-get install -y libaio1
 - sudo hostname "$(hostname | cut -c1-63)"
 
os: linux
dist: trusty
sudo: required

# -- snip

Seting up download cache on Travis

build.sbt

wixMySQLDownloadPath := Some(sys.env("HOME") + "/.wixMySQL/downloads"),

.travis.yml

# -- snip

cache:
  directories:
    - $HOME/.wixMySQL
    
# -- snip