|
1 |
| -buildscript { |
2 |
| - ext { |
3 |
| - springBootVersion = '2.1.4.RELEASE' |
4 |
| - mongodbVersion = '4.0.1' |
5 |
| - } |
6 |
| - repositories { |
7 |
| - mavenCentral() |
8 |
| - jcenter() |
9 |
| - } |
10 |
| - dependencies { |
11 |
| - classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") |
12 |
| - classpath("de.undercouch:gradle-download-task:3.4.3") |
13 |
| - } |
14 |
| -} |
15 |
| - |
16 |
| -plugins { |
17 |
| - id "net.ltgt.apt" version "0.19" |
18 |
| -} |
19 |
| - |
20 |
| -apply plugin: 'java' |
21 |
| -apply plugin: 'org.springframework.boot' |
22 |
| -apply plugin: 'io.spring.dependency-management' |
23 |
| -apply plugin: 'de.undercouch.download' |
24 |
| - |
25 |
| -group = 'com.emprovise.service' |
26 |
| -version = '0.0.1-SNAPSHOT' |
27 |
| -sourceCompatibility = 1.8 |
28 |
| - |
29 |
| -repositories { |
30 |
| - mavenCentral() |
31 |
| - maven { url "https://repo.spring.io/milestone" } |
32 |
| -} |
33 |
| - |
34 |
| -ext { |
35 |
| - springCloudVersion = 'Finchley.RELEASE' |
36 |
| - mapstructVersion = "1.2.0.Final" |
37 |
| -} |
38 |
| - |
39 |
| -dependencies { |
40 |
| - |
41 |
| - if (isProd) { |
42 |
| - compile('org.springframework.cloud:spring-cloud-starter-kubernetes:1.0.1.RELEASE') |
43 |
| - compile('org.springframework.cloud:spring-cloud-starter-kubernetes-ribbon:1.0.1.RELEASE') |
44 |
| - } else { |
45 |
| - compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client') |
46 |
| - } |
47 |
| - |
48 |
| - compile('org.springframework.boot:spring-boot-starter-actuator') |
49 |
| - compile('org.springframework.boot:spring-boot-starter-data-mongodb-reactive') |
50 |
| - compile('org.springframework.boot:spring-boot-starter-webflux') |
51 |
| - compile('org.springframework.boot:spring-boot-starter-batch') |
52 |
| - compile "org.mapstruct:mapstruct-jdk8:${mapstructVersion}" |
53 |
| - compile('org.slf4j:slf4j-api') |
54 |
| - runtime('net.logstash.logback:logstash-logback-encoder:5.1') |
55 |
| - runtime('com.h2database:h2') |
56 |
| - testCompile('org.springframework.boot:spring-boot-starter-test') |
57 |
| - testCompile('io.projectreactor:reactor-test') |
58 |
| - apt "org.mapstruct:mapstruct-processor:${mapstructVersion}" |
59 |
| -} |
60 |
| - |
61 |
| -dependencyManagement { |
62 |
| - imports { |
63 |
| - mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" |
64 |
| - } |
65 |
| -} |
66 |
| - |
67 |
| -processResources { |
68 |
| - filesMatching("**/application.properties") { |
69 |
| - expand(project.properties) |
70 |
| - } |
71 |
| -} |
72 |
| - |
73 |
| -tasks.withType(JavaCompile) { |
74 |
| - options.compilerArgs = [ |
75 |
| - '-Amapstruct.suppressGeneratorTimestamp=true' |
76 |
| - ] |
77 |
| -} |
78 |
| - |
79 |
| -task runJar(type: JavaExec, dependsOn: jar) { |
80 |
| - main = "-jar" |
81 |
| - args jar.archivePath |
82 |
| -} |
83 |
| - |
84 |
| -def pullCommonDir = new File(buildDir, 'repo') |
85 |
| -pullCommonDir.mkdirs() |
86 |
| -def mongodbHome = new File("${buildDir}/libs/mongodb-win32-x86_64-2008plus-ssl-${mongodbVersion}") |
87 |
| - |
88 |
| -task downloadMongoDB(type: Download) { |
89 |
| - src "http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-${mongodbVersion}.zip" |
90 |
| - dest "${buildDir}/repo" |
91 |
| - overwrite false |
92 |
| -} |
93 |
| - |
94 |
| -task extractMongoDB(dependsOn: downloadMongoDB) { |
95 |
| - doLast { |
96 |
| - if(!file("${mongodbHome}").exists()) { |
97 |
| - copy { |
98 |
| - from zipTree("${pullCommonDir}/mongodb-win32-x86_64-2008plus-ssl-${mongodbVersion}.zip") |
99 |
| - into new File(buildDir, "libs") |
100 |
| - } |
101 |
| - } |
102 |
| - } |
103 |
| -} |
104 |
| - |
105 |
| -task configMongoDB(dependsOn: extractMongoDB) { |
106 |
| - doLast { |
107 |
| - def mongodbBinDir = new File("${mongodbHome}/bin", "mongod.cfg") |
108 |
| - |
109 |
| - if (!mongodbBinDir.exists()) { |
110 |
| - println "setting up mongodb config file..." |
111 |
| - |
112 |
| - def mongodbDataDir = new File("${mongodbHome}", 'data') |
113 |
| - mongodbDataDir.mkdirs() |
114 |
| - |
115 |
| - def mongodbLogDir = new File("${mongodbHome}", 'logs') |
116 |
| - mongodbLogDir.mkdirs() |
117 |
| - def mongodbLogFile = new File("${mongodbLogDir}/mongo.log") |
118 |
| - |
119 |
| - copy { |
120 |
| - from "${projectDir.path}/config/mongod.cfg" |
121 |
| - into "${mongodbHome}/bin" |
122 |
| - filter { line -> line.replaceAll("@logs@", "${mongodbLogFile}".replace("\\", "/") ) } |
123 |
| - filter { line -> line.replaceAll("@data@", "${mongodbDataDir}".replace("\\", "/")) } |
124 |
| - } |
125 |
| - } |
126 |
| - } |
127 |
| -} |
128 |
| - |
129 |
| -task runMongodb(type: Exec, dependsOn: configMongoDB) { |
130 |
| - workingDir "${mongodbHome}/bin" |
131 |
| - commandLine 'cmd', '/c', "mongod --config mongod.cfg" |
132 |
| -} |
| 1 | +buildscript { |
| 2 | + ext { |
| 3 | + springBootVersion = '2.0.4.RELEASE' |
| 4 | + mongodbVersion = '4.0.1' |
| 5 | + } |
| 6 | + repositories { |
| 7 | + mavenCentral() |
| 8 | + jcenter() |
| 9 | + } |
| 10 | + dependencies { |
| 11 | + classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") |
| 12 | + classpath("de.undercouch:gradle-download-task:3.4.3") |
| 13 | + } |
| 14 | +} |
| 15 | + |
| 16 | +plugins { |
| 17 | + id "net.ltgt.apt" version "0.19" |
| 18 | +} |
| 19 | + |
| 20 | +apply plugin: 'java' |
| 21 | +apply plugin: 'org.springframework.boot' |
| 22 | +apply plugin: 'io.spring.dependency-management' |
| 23 | +apply plugin: 'de.undercouch.download' |
| 24 | + |
| 25 | +group = 'com.emprovise.service' |
| 26 | +version = '0.0.1-SNAPSHOT' |
| 27 | +sourceCompatibility = 1.8 |
| 28 | + |
| 29 | +repositories { |
| 30 | + mavenCentral() |
| 31 | + maven { url "https://repo.spring.io/milestone" } |
| 32 | +} |
| 33 | + |
| 34 | +ext { |
| 35 | + springCloudVersion = 'Finchley.RELEASE' |
| 36 | + mapstructVersion = "1.2.0.Final" |
| 37 | +} |
| 38 | + |
| 39 | +dependencies { |
| 40 | + |
| 41 | + if (isProd) { |
| 42 | + compile('org.springframework.cloud:spring-cloud-starter-kubernetes:1.0.1.RELEASE') |
| 43 | + compile('org.springframework.cloud:spring-cloud-starter-kubernetes-ribbon:1.0.1.RELEASE') |
| 44 | + } else { |
| 45 | + compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client') |
| 46 | + } |
| 47 | + |
| 48 | + compile('org.springframework.boot:spring-boot-starter-actuator') |
| 49 | + compile('org.springframework.boot:spring-boot-starter-data-mongodb-reactive') |
| 50 | + compile('org.springframework.boot:spring-boot-starter-webflux') |
| 51 | + compile('org.springframework.boot:spring-boot-starter-batch') |
| 52 | + compile "org.mapstruct:mapstruct-jdk8:${mapstructVersion}" |
| 53 | + compile('org.slf4j:slf4j-api') |
| 54 | + runtime('net.logstash.logback:logstash-logback-encoder:5.1') |
| 55 | + runtime('com.h2database:h2') |
| 56 | + testCompile('org.springframework.boot:spring-boot-starter-test') |
| 57 | + testCompile('io.projectreactor:reactor-test') |
| 58 | + apt "org.mapstruct:mapstruct-processor:${mapstructVersion}" |
| 59 | +} |
| 60 | + |
| 61 | +dependencyManagement { |
| 62 | + imports { |
| 63 | + mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | +processResources { |
| 68 | + filesMatching("**/application.properties") { |
| 69 | + expand(project.properties) |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | +tasks.withType(JavaCompile) { |
| 74 | + options.compilerArgs = [ |
| 75 | + '-Amapstruct.suppressGeneratorTimestamp=true' |
| 76 | + ] |
| 77 | +} |
| 78 | + |
| 79 | +task runJar(type: JavaExec, dependsOn: jar) { |
| 80 | + main = "-jar" |
| 81 | + args jar.archivePath |
| 82 | +} |
| 83 | + |
| 84 | +def pullCommonDir = new File(buildDir, 'repo') |
| 85 | +pullCommonDir.mkdirs() |
| 86 | +def mongodbHome = new File("${buildDir}/libs/mongodb-win32-x86_64-2008plus-ssl-${mongodbVersion}") |
| 87 | + |
| 88 | +task downloadMongoDB(type: Download) { |
| 89 | + src "http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-${mongodbVersion}.zip" |
| 90 | + dest "${buildDir}/repo" |
| 91 | + overwrite false |
| 92 | +} |
| 93 | + |
| 94 | +task extractMongoDB(dependsOn: downloadMongoDB) { |
| 95 | + doLast { |
| 96 | + if(!file("${mongodbHome}").exists()) { |
| 97 | + copy { |
| 98 | + from zipTree("${pullCommonDir}/mongodb-win32-x86_64-2008plus-ssl-${mongodbVersion}.zip") |
| 99 | + into new File(buildDir, "libs") |
| 100 | + } |
| 101 | + } |
| 102 | + } |
| 103 | +} |
| 104 | + |
| 105 | +task configMongoDB(dependsOn: extractMongoDB) { |
| 106 | + doLast { |
| 107 | + def mongodbBinDir = new File("${mongodbHome}/bin", "mongod.cfg") |
| 108 | + |
| 109 | + if (!mongodbBinDir.exists()) { |
| 110 | + println "setting up mongodb config file..." |
| 111 | + |
| 112 | + def mongodbDataDir = new File("${mongodbHome}", 'data') |
| 113 | + mongodbDataDir.mkdirs() |
| 114 | + |
| 115 | + def mongodbLogDir = new File("${mongodbHome}", 'logs') |
| 116 | + mongodbLogDir.mkdirs() |
| 117 | + def mongodbLogFile = new File("${mongodbLogDir}/mongo.log") |
| 118 | + |
| 119 | + copy { |
| 120 | + from "${projectDir.path}/config/mongod.cfg" |
| 121 | + into "${mongodbHome}/bin" |
| 122 | + filter { line -> line.replaceAll("@logs@", "${mongodbLogFile}".replace("\\", "/") ) } |
| 123 | + filter { line -> line.replaceAll("@data@", "${mongodbDataDir}".replace("\\", "/")) } |
| 124 | + } |
| 125 | + } |
| 126 | + } |
| 127 | +} |
| 128 | + |
| 129 | +task runMongodb(type: Exec, dependsOn: configMongoDB) { |
| 130 | + workingDir "${mongodbHome}/bin" |
| 131 | + commandLine 'cmd', '/c', "mongod --config mongod.cfg" |
| 132 | +} |
0 commit comments