-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
136 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
299: plugin.EmbeddedPostgresqlPlugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package plugin; | ||
|
||
import java.io.IOException; | ||
|
||
import de.flapdoodle.embed.process.distribution.GenericVersion; | ||
import de.flapdoodle.embed.process.distribution.IVersion; | ||
import play.Logger; | ||
import play.Play; | ||
import play.PlayPlugin; | ||
import ru.yandex.qatools.embed.postgresql.EmbeddedPostgres; | ||
|
||
public class EmbeddedPostgresqlPlugin extends PlayPlugin { | ||
|
||
private final IVersion PG_VERSION = new GenericVersion("9.3.20-1"); | ||
private final EmbeddedPostgres postgres = new EmbeddedPostgres(this.PG_VERSION); | ||
private String url; | ||
|
||
@Override | ||
public void onLoad() { | ||
Logger.info("onLoad: %s", getClass()); | ||
if (Play.runingInTestMode()) { | ||
try { | ||
this.url = this.postgres.start("localhost", 9876, "test", "test", "test"); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} else { | ||
Logger.info("EmbeddedPostgresqlPlugin is disabled"); | ||
Play.pluginCollection.disablePlugin(this); | ||
} | ||
} | ||
|
||
@Override | ||
public void onConfigurationRead() { | ||
Logger.info("onConfigurationRead: %s", getClass()); | ||
if (Play.runingInTestMode()) { | ||
Play.configuration.setProperty("db", ""); | ||
Play.configuration.setProperty("db.url", this.url); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project name="pep" default="build" basedir="."> | ||
|
||
<target name="check" unless="play.path"> | ||
<fail message="Please specify Play framework path using -Dplay.path=/path/to/framework/home" /> | ||
</target> | ||
|
||
<path id="project.classpath"> | ||
<pathelement path="${play.path}/framework/classes"/> | ||
<fileset dir="${play.path}/framework/lib"> | ||
<include name="*.jar"/> | ||
</fileset> | ||
<fileset dir="${play.path}/framework"> | ||
<include name="*.jar"/> | ||
</fileset> | ||
<fileset dir="lib"> | ||
<include name="*.jar"/> | ||
</fileset> | ||
</path> | ||
|
||
<target name="build" depends="compile"> | ||
<mkdir dir="lib" /> | ||
<copy todir="tmp/classes"> | ||
<fileset dir="src"> | ||
<include name="**/*.properties"/> | ||
<include name="**/*.xml"/> | ||
<include name="**/play.plugins"/> | ||
<include name="**/play.static"/> | ||
</fileset> | ||
</copy> | ||
<jar destfile="lib/play-pep.jar" basedir="tmp/classes"> | ||
<manifest> | ||
<section name="Play-module"> | ||
<attribute name="Specification-Title" value="pep"/> | ||
</section> | ||
</manifest> | ||
</jar> | ||
<delete dir="tmp" /> | ||
</target> | ||
|
||
<target name="compile" depends="check"> | ||
<mkdir dir="tmp/classes" /> | ||
<javac srcdir="src" destdir="tmp/classes" target="1.5" debug="true"> | ||
<classpath refid="project.classpath" /> | ||
</javac> | ||
</target> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Here you can create play commands that are specific to the module, and extend existing commands | ||
|
||
MODULE = 'play-empedded-postgres' | ||
|
||
# Commands that are specific to your module | ||
|
||
COMMANDS = ['play-empedded-postgres:hello'] | ||
|
||
def execute(**kargs): | ||
command = kargs.get("command") | ||
app = kargs.get("app") | ||
args = kargs.get("args") | ||
env = kargs.get("env") | ||
|
||
if command == "play-empedded-postgres:hello": | ||
print "~ Hello" | ||
|
||
|
||
# This will be executed before any command (new, run...) | ||
def before(**kargs): | ||
command = kargs.get("command") | ||
app = kargs.get("app") | ||
args = kargs.get("args") | ||
env = kargs.get("env") | ||
|
||
|
||
# This will be executed after any command (new, run...) | ||
def after(**kargs): | ||
command = kargs.get("command") | ||
app = kargs.get("app") | ||
args = kargs.get("args") | ||
env = kargs.get("env") | ||
|
||
if command == "new": | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
self: com.github.aleksandy -> play-embedded-postgres 1.5 | ||
|
||
require: | ||
- play | ||
- ru.yandex.qatools.embed -> postgresql-embedded 2.6 |