forked from apache/fineract
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
337 lines (292 loc) · 10.4 KB
/
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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
description = 'Fineract Provider'
apply plugin: 'org.zeroturnaround.gradle.jrebel'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'com.gorylenko.gradle-git-properties'
apply plugin: 'io.swagger.core.v3.swagger-gradle-plugin'
apply plugin: 'com.google.cloud.tools.jib'
compileJava.doLast {
def mainSS = sourceSets.main
def source = mainSS.java.classesDirectory.get()
copy {
from "src/main/resources/"
into source
}
javaexec {
description = 'Performs EclipseLink static weaving of entity classes'
def target = source
main 'org.eclipse.persistence.tools.weaving.jpa.StaticWeave'
args '-persistenceinfo', source, '-classpath', configurations.runtimeClasspath, source, target
classpath configurations.runtimeClasspath
}
}
// Configuration for Swagger documentation generation task
// https://github.com/swagger-api/swagger-core/tree/master/modules/swagger-gradle-plugin
import org.apache.tools.ant.filters.ReplaceTokens
task prepareInputYaml {
outputs.file('config/swagger/fineract-input.yaml')
doLast {
copy {
from file('config/swagger/fineract-input.yaml.template')
into file('config/swagger')
rename { String filename -> return 'fineract-input.yaml' }
filter(ReplaceTokens, tokens: [VERSION: "${project.version}".toString()])
}
}
}
rat.dependsOn prepareInputYaml
resolve {
logging.captureStandardOutput LogLevel.INFO
outputFileName = 'fineract'
outputFormat = 'YAML'
prettyPrint = 'TRUE'
classpath = sourceSets.main.runtimeClasspath
outputDir = file("${buildDir}/generated/swagger-ui")
openApiFile = file("config/swagger/fineract-input.yaml")
}
resolve.dependsOn prepareInputYaml
configurations {
providedRuntime // needed for Spring Boot executable WAR
providedCompile
compile() {
exclude module: 'hibernate-entitymanager'
exclude module: 'hibernate-validator'
exclude module: 'activation'
exclude module: 'bcmail-jdk14'
exclude module: 'bcprov-jdk14'
exclude module: 'bctsp-jdk14'
exclude module: 'c3p0'
exclude module: 'stax-api'
exclude module: 'jaxb-api'
exclude module: 'jaxb-impl'
exclude module: 'jboss-logging'
exclude module: 'itext-rtf'
exclude module: 'classworlds'
}
runtime
}
apply from: 'dependencies.gradle'
// Configuration for the modernizer plugin
// https://github.com/andygoossens/gradle-modernizer-plugin
modernizer {
ignoreClassNamePatterns = [
'.*AbstractPersistableCustom',
'.*EntityTables',
'.*domain.*'
]
}
compileJava {
dependsOn rat
finalizedBy resolve
}
// If we are running Gradle within Eclipse to enhance classes with OpenJPA,
// set the classes directory to point to Eclipse's default build directory
if (project.hasProperty('env') && project.getProperty('env') == 'eclipse')
{
sourceSets.main.java.outputDir = new File(rootProject.projectDir, "fineract-provider/bin/main")
}
eclipse
{
project {
buildCommand([ LaunchConfigHandle: "<project>/.externalToolBuilders/OpenJPA Enhance Builder.launch" ], 'org.eclipse.ui.externaltools.ExternalToolBuilder')
}
}
/* http://stackoverflow.com/questions/19653311/jpa-repository-works-in-idea-and-production-but-not-in-gradle */
sourceSets.main.output.resourcesDir = sourceSets.main.java.outputDir
sourceSets.test.output.resourcesDir = sourceSets.test.java.outputDir
if (!(project.hasProperty('env') && project.getProperty('env') == 'dev')) {
sourceSets {
test {
java {
exclude '**/core/boot/tests/**'
}
}
}
}
// Configuration for SQL tasks
// https://docs.groovy-lang.org/latest/html/api/groovy/sql/Sql.html
import groovy.sql.Sql
project.ext.mysqlUser='root'
project.ext.mysqlPassword='mysql'
project.ext.pgUser='root'
project.ext.pgPassword='postgres'
configurations {
driver
}
dependencies {
driver 'org.mariadb.jdbc:mariadb-java-client:3.0.3'
driver 'org.postgresql:postgresql:42.3.3'
}
URLClassLoader loader = GroovyObject.class.classLoader
configurations.driver.each {File file ->
loader.addURL(file.toURL())
}
task createDB {
description= "Creates the MySQL Database. Needs database name to be passed (like: -PdbName=someDBname)"
doLast {
def sql = Sql.newInstance( 'jdbc:mariadb://localhost:3306/', mysqlUser, mysqlPassword, 'org.mariadb.jdbc.Driver' )
sql.execute( 'create database '+"`$dbName`" )
}
}
task dropDB {
description= "Drops the specified MySQL database. The database name has to be passed (like: -PdbName=someDBname)"
doLast {
def sql = Sql.newInstance( 'jdbc:mariadb://localhost:3306/', mysqlUser, mysqlPassword, 'org.mariadb.jdbc.Driver' )
sql.execute( 'DROP DATABASE '+"`$dbName`")
}
}
task createPGDB {
description= "Creates the PostgreSQL Database. Needs database name to be passed (like: -PdbName=someDBname)"
doLast {
def sql = Sql.newInstance( 'jdbc:postgresql://localhost:5432/', pgUser, pgPassword, 'org.postgresql.Driver' )
sql.execute( 'create database '+"$dbName" )
}
}
task dropPGDB {
description= "Drops the specified PostgreSQL database. The database name has to be passed (like: -PdbName=someDBname)"
doLast {
def sql = Sql.newInstance( 'jdbc:postgresql://localhost:5432/', pgUser, pgPassword, 'org.postgresql.Driver' )
sql.execute( 'DROP DATABASE '+ "$dbName")
}
}
task setBlankPassword {
doLast {
def sql = Sql.newInstance( 'jdbc:mariadb://localhost:3306/', mysqlUser, mysqlPassword, 'org.mariadb.jdbc.Driver' )
sql.execute('USE `fineract_tenants`')
sql.execute('UPDATE fineract_tenants.tenants SET schema_server = \'localhost\', schema_server_port = \'3306\', schema_username = \'mifos\', schema_password = \'mysql\' WHERE id=1;')
}
}
bootRun {
jvmArgs = [
"-Dspring.output.ansi.enabled=ALWAYS"
]
dependencies {
implementation 'org.mariadb.jdbc:mariadb-java-client:2.7.5'
implementation 'org.postgresql:postgresql:42.3.3'
}
classpath += files("build/generated/swagger-ui")
}
springBoot {
mainClass = 'org.apache.fineract.ServerApplication'
}
bootJar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes 'Main-Class': 'org.springframework.boot.loader.PropertiesLauncher', 'Implementation-Title': 'Apache Fineract', 'Implementation-Version': archiveVersion
}
dependsOn resolve
classifier = ''
from('build/generated/swagger-ui') {
into 'BOOT-INF/classes/static/swagger-ui'
}
}
jar {
from('build/generated/swagger-ui') {
include '*'
}
}
jar.dependsOn resolve
jar.dependsOn bootJar
jib {
from {
image = 'azul/zulu-openjdk-alpine:17'
}
to {
image = 'fineract'
tags = [
"${version}",
'latest'
]
}
container {
creationTime = 'USE_CURRENT_TIMESTAMP'
mainClass = 'org.apache.fineract.ServerApplication'
jvmFlags = [
'-Xmx1G',
'-Xms1G',
'-XshowSettings:vm',
'-XX:+UseContainerSupport',
'-XX:+UseStringDeduplication',
'-XX:MinRAMPercentage=25',
'-XX:MaxRAMPercentage=80',
'--add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED',
'--add-opens=java.base/java.lang=ALL-UNNAMED',
'--add-opens=java.base/java.lang.invoke=ALL-UNNAMED',
'--add-opens=java.base/java.io=ALL-UNNAMED',
'--add-opens=java.base/java.security=ALL-UNNAMED',
'--add-opens=java.base/java.util=ALL-UNNAMED',
'--add-opens=java.management/javax.management=ALL-UNNAMED',
'--add-opens=java.naming/javax.naming=ALL-UNNAMED'
]
args = [
'-Duser.home=/tmp',
'-Dfile.encoding=UTF-8',
'-Duser.timezone=UTC',
'-Djava.security.egd=file:/dev/./urandom'
]
ports = ['8080/tcp', '8443/tcp']
labels = [maintainer: 'Aleksandar Vidakovic <aleks@apache.org>']
user = 'nobody:nogroup'
}
allowInsecureRegistries = true
dependencies {
implementation 'org.mariadb.jdbc:mariadb-java-client:2.7.5'
implementation 'org.postgresql:postgresql:42.3.3'
}
extraDirectories {
paths {
path {
from = file('build/generated/swagger-ui')
into = "/app/classes"
}
}
}
pluginExtensions {
pluginExtension {
implementation = 'com.google.cloud.tools.jib.gradle.extension.layerfilter.JibLayerFilterExtension'
configuration {
filters {
filter {
glob = '/app/resources/**'
}
}
}
}
}
}
tasks.jibDockerBuild.dependsOn = ["bootJar"]
// Configuration for git properties gradle plugin
// https://github.com/n0mer/gradle-git-properties
gitProperties {
gitPropertiesResourceDir = file("$buildDir/classes/java/main")
dateFormat = "yyyy-MM-dd'T'HH:mmZ"
dateFormatTimeZone = "GMT"
failOnNoGitDirectory = false
}
// make sure the generateGitProperties task always executes (even when git.properties is not changed)
generateGitProperties.outputs.upToDateWhen { false }
// Gradle 7.x asks for explicit dependencies between tasks
checkstyleMain.dependsOn resolve
checkstyleTest.dependsOn resolve
licenseMain.dependsOn processResources, generateGitProperties
spotbugsTest.dependsOn resolve
test.dependsOn resolve