-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
353 lines (300 loc) · 10.2 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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'eclipse'
sourceCompatibility = 1.8
targetCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
version = file('version').text.trim()
ext.tf_vendor = 'Triniforce.com'
// Project configuration is used for Maven deploy:
ext.vgroupId = 'com.triniforce'
ext.GITHUB_OWNER = 'ProjectKaiser'
ext.GITHUB_REPOSITORY = 'tf-server-toolkit'
ext.vartifactId = 'tf-server-toolkit'
// Get dynamic environment settings
apply from: 'config.gradle'
ext.testFolderDir = new File(buildDir, 'test')
defaultTasks 'clean', 'ide'
repositories {
mavenCentral()
maven { url 'https://dev.untill.com/artifactory/repo' } // only for sojo 1.0.0
}
processResources {
from('src') {
include '**/*.properties'
include '**/*.wiki'
include '**/*.bsh'
include '**/*.htm'
}
from('test') {
include '**/*.jar'
include '**/*.bs'
include '**/*.txt'
include '**/*.properties'
include '**/*.soap'
include '**/*.wiki'
include '**/*.FDB'
}
}
configurations {
providedCompile
}
dependencies {
// compile(group: 'commons-pool', name: 'commons-pool', version: '1.5.6')
implementation group: 'org.apache.commons', name: 'commons-pool2', version: '2.11.1'
// compile 'commons-dbcp:commons-dbcp:1.2.2' // (latest: 1.4)
// compile 'commons-dbcp:commons-dbcp:1.4' // (latest: 1.4)
implementation group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.9.0'
compile 'commons-logging:commons-logging:1.1.1'
compile 'org.apache.commons:commons-lang3:3.8'
compile(group: 'log4j', name: 'log4j', version: '1.2.16')
compile(group: 'org.beanshell', name: 'bsh', version: '2.0b4')
compile(group: 'org.dbunit', name: 'dbunit', version: '2.7.3'){
exclude group: 'junit', module: 'junit'
}
compile(group: 'org.slf4j', name: 'slf4j-api', version: '1.6.1')
compile(group: 'net.sf.sojo', name: 'sojo', version: '1.0.0') //NOTE: this is a copy from tflib. Modern versions is not comatible with Tomcat
testCompile(group: 'com.h2database', name: 'h2', version: '2.1.214')
testCompile(group: 'org.apache.derby', name: 'derby', version: '10.8.1.2')
compile(group: 'joda-time', name: 'joda-time', version: '2.1')
compile 'com.googlecode.json-simple:json-simple:1.1.1'
implementation group: 'com.sun.mail', name: 'javax.mail', version: '1.6.2'
compile 'org.apache.poi:poi:3.10.1'
compile 'org.apache.httpcomponents:httpclient:4.5.13'
compile 'org.apache.commons:commons-text:1.8'
compile 'commons-io:commons-io:2.4'
testCompile(group: 'org.jmock', name: 'jmock', version: '2.5.1')
testCompile 'net.sourceforge.jtds:jtds:1.2.4'
testImplementation group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '9.4.0.jre8'
// testCompile 'org.firebirdsql.jdbc:jaybird-jdk18:2.2.15'
testCompile 'org.firebirdsql.jdbc:jaybird-jdk18:4.0.5.java8'
testCompile(group: 'junit', name: 'junit', version: '3.8.2', force: true)
testCompile(group: 'mysql', name: 'mysql-connector-java', version: '5.1.16')
testCompile 'com.google.guava:guava:19.0-rc2'
testCompile 'net.engio:mbassador:1.2.4'
testCompile 'com.icegreen:greenmail:1.3'
testImplementation group: 'com.icegreen', name: 'greenmail', version: '1.6.5'
testCompile 'org.slf4j:slf4j-nop:1.7.14'
testCompile 'org.mockito:mockito-core:1.+'
// Jetty
testCompile 'org.eclipse.jetty:jetty-webapp:9.2.0.RC0'
testCompile 'org.eclipse.jetty:jetty-plus:9.2.0.RC0'
testCompile 'org.eclipse.jetty:jetty-jndi:9.2.0.RC0'
testCompile 'javax.servlet.jsp:jsp-api:2.1'
testCompile( group: 'xerces', name: 'xercesImpl', version: '2.11.0')
testCompile 'com.graphql-java:graphql-java:11.0'
providedCompile 'javax.servlet:javax.servlet-api:3.0.1'
testImplementation group: 'com.sun.mail', name: 'javax.mail', version: '1.6.2'
}
sourceSets.main.compileClasspath += configurations.providedCompile
sourceSets.test.compileClasspath += configurations.providedCompile
sourceSets.test.runtimeClasspath += configurations.providedCompile
sourceSets {
main.java.srcDirs = ['src']
test.java.srcDirs = ['test']
inv {
java.srcDirs = ['investigation']
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
compileClasspath += sourceSets.test.output
runtimeClasspath += sourceSets.test.output
}
}
configurations {
invImplementation.extendsFrom testImplementation
invRuntimeOnly.extendsFrom testRuntimeOnly
}
tasks.eclipse.dependsOn(cleanEclipse)
eclipse {
classpath {
downloadJavadoc = true
plusConfigurations += [configurations.providedCompile]
file {
whenMerged {
def jre = entries.find { it.path.contains 'org.eclipse.jdt.launching.JRE_CONTAINER' }
jre.accessRules.add(new org.gradle.plugins.ide.eclipse.model.AccessRule('accessible', 'com/sun/net/**'))
entries.each {
if (it in org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry && it.entryAttributes['gradle_used_by_scope'] == 'inv')
it.entryAttributes['test'] = true
}
}
}
}
jdt.file.withProperties{
it['org.eclipse.jdt.core.compiler.problem.rawTypeReference']='ignore'
it['org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation']='ignore'
}
}
//eclipseJdt << {
// file('.settings/org.eclipse.core.resources.prefs').write(
// 'eclipse.preferences.version=1\n' +
// 'encoding/<project>=UTF-8\n'
// )
//}
task ide(dependsOn: tasks.eclipse) {
group = 'IDE'
description = 'preparing for work in the development environment'
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
tasks.withType(PublishToMavenRepository) { it.dependsOn test }
publishing{
repositories {
maven {
name = 'GitHubPackages'
url = 'https://maven.pkg.github.com/'+GITHUB_OWNER+'/'+GITHUB_REPOSITORY
credentials {
username = untillGithubRegistryUsername ?: ''
password = untillGithubRegistryToken
}
}
}
publications {
gpr(MavenPublication) {
groupId = vgroupId
artifactId = vartifactId
from(components.java)
}
}
}
generatePomFileForGprPublication.doFirst {
publishing.publications.gpr.version = getNextVersion(requestLastRegistryVersion())
}
task jar_lib(type: Copy, dependsOn:[jar]){
from "${jar.destinationDir}/${jar.archiveName}"
into "$System.env.TF_LIB_HOME/srvdist"
rename { String fileName -> 'tf-server-toolkit.jar' }
}
jar_lib.doFirst{
def envName = 'TF_LIB_HOME'
def env = System.env[envName]
if (null == env || env.length() == 0){
throw new StopExecutionException("Variable $envName must point to TF_LIB HOME")
}
}
jar {
manifest {
attributes(
'Specification-Title': project.name,
'Specification-Version': version,
'Specification-Vendor': tf_vendor,
'Implementation-Title': project.name,
'Implementation-Version': "$version (${new Date().format('yyyy-MM-dd')})",
'Implementation-Vendor': tf_vendor
)
}
}
task prepareTestFolder {
outputs.dir testFolderDir
doLast {
delete testFolderDir
mkdir testFolderDir
new File(testFolderDir, 'log4j.properties').write(
'log4j.rootLogger=trace, file\n' +
'log4j.appender.file=org.apache.log4j.RollingFileAppender\n' +
'log4j.appender.file.File=' + new File(testFolderDir, 'messages.log').absolutePath.replace('\\', '/') + '\n' +
'log4j.appender.file.MaxFileSize=8MB\n' +
'log4j.appender.file.MaxBackupIndex=10\n' +
'log4j.appender.file.layout=org.apache.log4j.PatternLayout\n' +
'log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %t %c{6}:%L - %m %l %n\n' +
'log4j.logger.com.triniforce.db.dml.StmtContainer=OFF\n'
)
new File(testFolderDir, 'test.properties').write(
'url=jdbc:h2:mem:db\n' +
'class=org.h2.Driver\n'+
'testSeqFile=seq.txt'
)
}
}
test {
dependsOn prepareTestFolder
doFirst {
environment.put('TF_SERVER_TOOLKIT_TEST_FOLDER', testFolderDir)
}
minHeapSize = '128m'
maxHeapSize = '256m'
testLogging {
events "failed"
exceptionFormat org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
showExceptions true
showCauses true
showStackTraces true
}
}
//task outputDirs << { sourceSets.test.java.srcDirs.each{f -> println(f)}}
//war {
// from 'war'
//}
import groovy.json.JsonOutput;
import groovy.json.JsonSlurper;
String requestLastRegistryVersion(){
def gqlQuery = """
query{repository(owner:"${GITHUB_OWNER}", name:"${GITHUB_REPOSITORY}"){
id
packages(last: 100) {
edges {
node {
id
latestVersion {
id
version
}
}
}
}
}}
""";
def baseUrl = new URL('https://api.github.com/graphql')
def connection = baseUrl.openConnection()
connection.with {
doOutput = true
doInput = true
requestMethod = 'POST'
def basicAuth = 'token ' + untillGithubRegistryToken
setRequestProperty('Authorization', basicAuth)
outputStream.withWriter { writer ->
writer << JsonOutput.toJson(['query': gqlQuery])
}
def strResp = content.text
def gqlResponse = new JsonSlurper().parseText(strResp)
if (gqlResponse.errors != null) {
System.err.println gqlResponse.errors
throw new GradleException(gqlResponse.errors[0]?.message)
}
def edges = gqlResponse?.data?.repository?.packages?.edges
def latestVersion = null
if (edges != null) {
latestVersion = edges[0]?.node?.latestVersion?.version
for (int i = 1; i < edges.size(); i++) {
println 'checking: ' + edges[i].node.latestVersion
if (edges[i].node?.latestVersion?.version != null &&
edges[i].node.latestVersion.version.startsWith(version)) {
latestVersion = edges[i].node.latestVersion.version
break
}
}
}
return latestVersion;
}
}
String getNextVersion(String registryVersion){
def matcher = registryVersion =~ /^(\d+\.\d+)\.(\d{1,4})$/
def nextVersion = version + '.0'
if (matcher.find()) {
def major = matcher[0][1]
def minor = matcher[0][2]
if (version.startsWith(major, 0))
nextVersion = major + '.' + ((minor as int) + 1)
}
return nextVersion
}
task showNextPackageVersion {
doLast {
println 'next version: ' + getNextVersion(requestLastRegistryVersion())
}
}