-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
227 lines (195 loc) · 6.79 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
/*
* Copyright 2022 Programming Org and other Programming Org contributors
*
*
* Licensed 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.
*/
import groovy.json.JsonSlurper
import nu.studer.gradle.jooq.JooqEdition
buildscript {
dependencies {
classpath 'org.postgresql:postgresql:42.4.2'
}
}
plugins {
id 'java'
id "com.diffplug.spotless" version "6.8.0"
id "application"
id "nu.studer.jooq" version "7.1.1"
}
group 'io.github.org.programming'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
compileJava.options.encoding = "UTF-8"
sourceCompatibility = 17
targetCompatibility = 17
dependencies {
implementation group: 'net.dv8tion', name: 'JDA', version: '5.0.0-alpha.17'
//Logger
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.4.0'
implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.4.0'
//implementation group: 'uk.org.lidalia', name: 'sysout-over-slf4j', version: '1.0.2'
//config
implementation group: 'io.github.realyusufismail', name: 'jconfig', version: '1.0.6'
//database
implementation group: 'com.zaxxer', name: 'HikariCP', version: '5.0.1'
implementation group: 'org.postgresql', name: 'postgresql', version: '42.5.0'
//jooq
implementation group: 'org.jooq', name: 'jooq', version: '3.17.3'
implementation group: 'org.jooq', name: 'jooq-codegen', version: '3.17.3'
implementation group: 'org.jooq', name: 'jooq-meta', version: '3.17.3'
//test
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
//jooq
jooqGenerator 'org.postgresql:postgresql:42.5.0'
}
apply plugin: 'jacoco' // code coverage reports
test {
useJUnitPlatform()
finalizedBy jacocoTestReport // report is always generated after tests run
}
configurations.all {
//noinspection GrUnresolvedAccess
// ez vulnerability fix
exclude group: "org.slf4j", module: "slf4j-log4j12"
}
jacocoTestReport {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
reports {
xml.enabled true
html.enabled true
}
jacocoTestReport.dependsOn test
jacocoTestCoverageVerification.dependsOn jacocoTestReport
}
mainClassName = "io.github.org.programming.Bot"
compileJava {
// Makes spotlessApply task run on every compile/build.
dependsOn 'spotlessApply'
// Nails the Java-Version of every Subproject
sourceCompatibility = rootProject.sourceCompatibility
targetCompatibility = rootProject.targetCompatibility
}
spotless {
java {
// Excludes build folder since it may contain compiled classes
targetExclude("build/**")
//No need to do spotless on generated code
targetExclude("src/main/jooq/**")
eclipse('4.21.0').configFile("${rootProject.rootDir}/meta/formatting/google-style-eclipse.xml")
licenseHeader("""/*
* Copyright 2022 Programming Org and other Programming Org contributors
*
*
* Licensed 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.
*/ """)
}
}
javadoc {
if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xdoclint:none', '-quiet')
logging.captureStandardError LogLevel.INFO
logging.captureStandardOutput LogLevel.INFO
}
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
jar {
archiveVersion.set("")
}
def props = new Hashtable<String,Object>()
//if the file exists, load the properties
if (file("config.json").exists()) {
def jsonFile = file('config.json')
if (jsonFile.exists()) {
def jsonSlurper = new JsonSlurper()
def json = jsonSlurper.parseText(jsonFile.text)
props.putAll(json)
} else {
throw new GradleException("config.json does not exist!")
}
}
//create the build directory so no errors happen with the workflow
task createBuildDir {
doLast {
logger.info("===== Creating build directory =====")
file("build").mkdirs()
logger.info("===== Build directory created ======")
}
mustRunAfter(project.tasks.findByPath('clean'))
}
jooq {
version = '3.17.3'
edition = JooqEdition.OSS
configurations {
main {
generateSchemaSourceOnCompilation = false
generationTool {
logging = org.jooq.meta.jaxb.Logging.WARN
jdbc {
driver = 'org.postgresql.Driver'
url = props.get("DB_URL") as String
user = props.get("DB_USER") as String
password = props.get("DB_PASSWORD") as String
}
generator {
name = 'org.jooq.codegen.JavaGenerator'
database {
name = 'org.jooq.meta.postgres.PostgresDatabase'
inputSchema = 'public'
includes = '.*'
excludes = ''
forcedTypes {
forcedType {
name = 'INSTANT'
includeTypes = 'TIMESTAMP'
}
forcedType {
name = 'INTERVALDAYTOSECOND'
includeTypes = 'INTERVAL'
}
}
}
generate {
records = true
immutablePojos = true
fluentSetters = true
}
target {
packageName = 'io.github.org.programming.jooq'
directory = "src/main/jooq"
}
strategy.name = "org.jooq.codegen.DefaultGeneratorStrategy"
}
}
}
}
}