-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle
executable file
·134 lines (118 loc) · 4.39 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
plugins {
id 'java'
id 'maven-publish'
id 'signing'
id 'jacoco'
id 'org.sonarqube' version '6.0.0.5145'
id 'com.github.kt3k.coveralls' version '2.12.2'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
id 'com.diffplug.spotless' version '6.25.0'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = 'io.github.devatherock'
description = 'java.util.logging.Formatter to log messages as JSON, compatible with Logstash'
version = (System.env.CIRCLE_TAG ? System.env.CIRCLE_TAG.substring(1): '1.3.0') +
(Boolean.valueOf(System.getProperty("snapshot")) ? "-SNAPSHOT" : "")
repositories {
mavenCentral()
}
ext {
jsonSimpleVersion = '1.1.1'
gsonVersion = '2.11.0'
jacksonVersion = '2.18.1'
// Properties for publishing
licenseUrl = 'https://github.com/devatherock/jul-jsonformatter/blob/master/LICENSE.txt'
scmUrl = 'https://github.com/devatherock/jul-jsonformatter/'
}
configurations {
// Force dependency versions to use dependencies without vulnerabilities
all {
resolutionStrategy {
force 'com.fasterxml.jackson.core:jackson-databind:2.18.1'
}
}
// Configurations for tests
jsonSimpleTestImplementation.extendsFrom testImplementation
jsonSimpleTestCompileOnly.extendsFrom compileOnly
gsonTestImplementation.extendsFrom testImplementation
gsonTestCompileOnly.extendsFrom compileOnly
jacksonTestImplementation.extendsFrom testImplementation
jacksonTestCompileOnly.extendsFrom compileOnly
customJsonTestImplementation.extendsFrom testImplementation
customJsonTestCompileOnly.extendsFrom compileOnly
}
dependencies {
compileOnly group: 'com.googlecode.json-simple', name: 'json-simple', version: jsonSimpleVersion
compileOnly group: 'com.google.code.gson', name: 'gson', version: gsonVersion
compileOnly group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
testImplementation group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.11.3'
// Test configuration dependencies
jsonSimpleTestImplementation group: 'com.googlecode.json-simple', name: 'json-simple', version: jsonSimpleVersion
gsonTestImplementation group: 'com.google.code.gson', name: 'gson', version: gsonVersion
jacksonTestImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion
}
// sourceSets for tests
def allTestFiles = [
'**/JSONSimpleFormatterTest*',
'**/GSONFormatterTest*',
'**/JacksonFormatterTest*',
'**/CustomJsonConverterTest*',
'**/CustomKeysTest*'
]
def inclusionsBySourceSet = [
'jsonSimpleTest': [
'**/JSONSimpleFormatterTest*'
],
'gsonTest': ['**/GSONFormatterTest*'],
'jacksonTest': [
'**/JacksonFormatterTest*',
'**/CustomKeysTest*'
],
'customJsonTest': [
'**/CustomJsonConverterTest*'
],
]
sourceSets {
inclusionsBySourceSet.each { name, inclusions ->
sourceSets.create(name) {
java {
srcDirs = [
"$projectDir/src/main/java",
"$projectDir/src/test/java"
]
allTestFiles.findAll { !inclusions.contains(it) }.each { testFile ->
exclude testFile
}
}
resources.srcDir file('src/test/resources')
}
}
}
/** Test tasks **/
def testDescriptions = [
'json-simple',
'gson',
'jackson',
'custom JSON'
]
def testSourceSetNames = [
'jsonSimpleTest',
'gsonTest',
'jacksonTest',
'customJsonTest'
]
for(int index = 0; index < testSourceSetNames.size(); index++) {
tasks.create(name: testSourceSetNames[index], type: Test) {
description = "Test ${testDescriptions}"
testClassesDirs = project.sourceSets[testSourceSetNames.get(index)].output.classesDirs
classpath = project.sourceSets[testSourceSetNames.get(index)].runtimeClasspath
// Prevent JUnit5 from scanning for tests in non-test classes
include(inclusionsBySourceSet[testSourceSetNames[index]])
}
}
apply from: 'https://raw.githubusercontent.com/devatherock/gradle-includes/master/publish.gradle'
apply from: 'checks.gradle'
apply from: 'https://raw.githubusercontent.com/devatherock/gradle-includes/master/non-test-checks.gradle'
compileTestJava.enabled = false