-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
39 lines (32 loc) · 887 Bytes
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import groovy.sql.Sql
allprojects {
apply plugin : 'idea'
apply plugin : 'groovy'
repositories {
mavenCentral()
}
sourceCompatibility = 7;
}
compileJava {
options.compilerArgs = ['-XDignore.symbol.file=true'];
}
configurations {
driver
}
dependencies {
driver group: 'mysql', name: 'mysql-connector-java', version: '5.1.33'
}
URLClassLoader loader = GroovyObject.class.classLoader
configurations.driver.each { File file ->
loader.addURL(file.toURL())
}
task createDB << {
def props = new Properties();
File propFile =
new File('database.properties')
props.load(propFile.newDataInputStream())
def sql = Sql.newInstance(props.get('mysql.url') +'&allowMultiQueries=true', props.get('mysql.username'), props.get('mysql.password'), 'com.mysql.jdbc.Driver');
String sqlFilePath ="schema.sql"
String sqlString = new File(sqlFilePath).text
sql.execute(sqlString);
}