-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
65 lines (56 loc) · 2.35 KB
/
build.gradle
File metadata and controls
65 lines (56 loc) · 2.35 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
apply plugin: 'java'
apply plugin: 'idea'
import groovy.sql.Sql
import org.h2.tools.Server
import java.sql.Connection
import java.sql.DriverManager
import org.h2.Driver
repositories {
mavenCentral()
}
configurations { driver }
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'com.h2database', name: 'h2', version:h2_version
}
}
dependencies{
driver group: 'com.h2database', name: 'h2', version: h2_version
compile group: 'com.h2database', name: 'h2', version: h2_version
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: spring_boot_version
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: spring_boot_version
compile group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version: spring_boot_version
compile group: 'org.springframework.boot', name: 'spring-boot-starter-freemarker', version: spring_boot_version
//compile group: 'org.freemarker', name: 'freemarker',version:freemaker_version
compile group: 'org.hibernate',name: 'hibernate-core' ,version: hibernate_version
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
}
task setupH2<<{
URLClassLoader loader = GroovyObject.class.classLoader as URLClassLoader
configurations.driver.each {
File file -> loader.addURL(file.toURI().toURL())
}
Class driverClass = loader.loadClass('org.h2.Driver')
java.sql.Driver driverInstance = driverClass.newInstance()
java.sql.DriverManager.registerDriver(driverInstance)
String sqlBaseFilePath = "$rootDir/DBScripts/H2/"
String bytewheelsSQL = new File(sqlBaseFilePath+'bytewheels.h2.sql').text
startDataBase()
def sqlGlobal = Sql.newInstance('jdbc:h2:tcp://localhost/mem:bytewheels;MVCC=TRUE', 'sa', '', 'org.h2.Driver')
sqlGlobal.execute(bytewheelsSQL)
sleep(1000000000)
}
private void startDataBase(){
Server server = null
try {
server = Server.createTcpServer("-tcpAllowOthers").start()
Connection conn = DriverManager.getConnection("jdbc:h2:tcp://localhost/mem:bytewheels;MVCC=TRUE", "sa", "")
System.out.println("Connection Established: "
+ conn.getMetaData().getDatabaseProductName() + "/" + conn.getCatalog())
} catch (Exception e) {
e.printStackTrace()
}
}