Last active
December 17, 2015 05:49
-
-
Save grimrose/5560409 to your computer and use it in GitHub Desktop.
『JUnit実践入門』写経・実践会 in 横浜 #6 (特別編)
テスト対象となるプロジェクトをGradleでなんとかしてみるbuild.gradle
This file contains hidden or 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
apply { | |
plugin 'java' | |
plugin 'war' | |
plugin 'jetty' | |
} | |
apply plugin: 'maven' | |
apply { | |
plugin 'idea' | |
} | |
group = 'junitbook' | |
version = '0.0.1-SNAPSHOT' | |
description = "Book store" | |
sourceCompatibility = 1.7 | |
targetCompatibility = 1.7 | |
repositories { | |
mavenCentral() | |
maven { | |
url 'http://download.eclipse.org/rt/eclipselink/maven.repo' | |
} | |
} | |
dependencies { | |
compile group: 'org.slf4j', name: 'slf4j-jdk14', version: '1.7.5' | |
compile group: 'org.tuckey', name: 'urlrewritefilter', version: '4.0.4' | |
compile group: 'org.eclipse.persistence', name: 'eclipselink', version: '2.4.1' | |
compile group: 'org.springframework', name: 'spring-webmvc', version: '3.2.2.RELEASE' | |
compile group: 'org.springframework', name: 'spring-tx', version: '3.2.2.RELEASE' | |
compile group: 'org.springframework', name: 'spring-orm', version: '3.2.2.RELEASE' | |
compile group: 'aopalliance', name: 'aopalliance', version: '1.0' | |
compile group: 'cglib', name: 'cglib', version: '2.2' | |
compile group: 'org.aspectj', name: 'aspectjweaver', version: '1.6.10' | |
compile group: 'org.hibernate', name: 'hibernate-validator', version: '5.0.0.Final' | |
compile group: 'org.thymeleaf', name: 'thymeleaf-spring3', version: '2.0.16' | |
compile group: 'com.h2database', name: 'h2', version: '1.3.171' | |
testCompile group: 'junit', name: 'junit', version: '4.11' | |
testCompile group: 'org.springframework', name: 'spring-test', version: '3.2.2.RELEASE' | |
testCompile group: 'org.dbunit', name: 'dbunit', version: '2.4.9' | |
providedCompile group: 'javax.servlet', name: 'servlet-api', version: '2.5' | |
providedCompile group: 'javax.servlet.jsp', name: 'jsp-api', version: '2.1' | |
testCompile 'org.seleniumhq.selenium:selenium-chrome-driver:2.31.0' | |
testCompile 'info.cukes:cucumber-java:1.1.3' | |
testCompile 'info.cukes:cucumber-junit:1.1.3' | |
} | |
buildscript { | |
ext { | |
h2Version = '1.3.171' | |
} | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath "com.h2database:h2:$h2Version" | |
} | |
} | |
ext { | |
databaseDir = "${projectDir}/h2/database" | |
h2Args = ['-baseDir', "${databaseDir}"] | |
databaseName = 'bookstore' | |
databaseSchemas = ['dev', 'ut'] | |
} | |
task h2Start(type: JavaExec) { | |
classpath = sourceSets.main.runtimeClasspath | |
main = 'org.h2.tools.Server' | |
args = h2Args | |
} | |
[jettyRun, jettyRunWar]*.with { | |
reload = 'automatic' | |
additionalRuntimeJars = sourceSets.main.runtimeClasspath | |
// httpPort = 9000 | |
} | |
def h2TcpServerStart = { args -> | |
org.h2.tools.Server.createTcpServer(args as String[]).start() | |
} | |
def server | |
[jettyRun, jettyRunWar]*.doFirst { server = h2TcpServerStart(h2Args) } | |
[jettyRun, jettyRunWar]*.doLast { server.stop() } | |
task bookstoreInit { | |
doFirst { | |
mkdir databaseDir | |
} | |
server = h2TcpServerStart(h2Args) | |
def runSqlScript = { File script, schema = '' -> | |
def url = "jdbc:h2:${server.URL}/${databaseName};${ schema ? "SCHEMA=${schema}" : '' }" | |
// println url | |
org.h2.tools.RunScript.execute(url, "sa", "", script.path, 'UTF-8', false) | |
} | |
runSqlScript file('db_schema/initdb.sql') | |
databaseSchemas.each { schema -> | |
runSqlScript file('db_schema/setup.sql'), schema | |
} | |
} |
cucumberのdependenciesを追加。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gradle 1.6で動作確認済