forked from openmainframeproject/cobol-check
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
198 lines (177 loc) · 5.5 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
import static org.apache.tools.ant.taskdefs.condition.Os.*
plugins {
id 'java-library'
id 'org.sonarqube' version '3.0'
id 'jacoco'
}
def productVersion = '0.1.0'
def productName = 'cobol-check'
group = 'com.neopragma'
description = 'Unit testing framework for Cobol'
def approvalExpectedOutput = "approval-test-expected.txt"
def approvalActualOutput = "approval-test-actual.txt"
sonarqube {
properties {
property "sonar.projectKey", "neopragma_cobol-check"
property "sonar.organization", "neopragma-github"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.exclusions", "**/EIBResponseCodes.java,**/Keyword.java"
}
}
jacoco {
toolVersion = "0.8.6"
}
jacocoTestCoverageVerification {
violationRules {
rule {
element = 'CLASS'
limit {
minimum = 0.8
}
excludes = ['*Constants',
'*Exception',
'*DirectoryNameMatcher',
'*Driver',
'*EIBResponseCodes',
'*Exception*',
'*Generator',
'*Keyword',
'*LinuxProcessLauncher',
'*Log',
'*Flag',
'*StringHelper',
'*TestSuiteConcatenator']
}
rule {
element = 'CLASS'
limit {
minimum = 0.2
}
includes = ['*LinuxProcessLauncher',
'*TestSuiteConcatenator']
}
}
}
ext {
mainClassName = 'com.neopragma.cobolcheck.Driver'
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
repositories {
mavenCentral()
}
sourceSets {
main {
resources {
srcDirs "src/main/resources", "src/test/resources"
}
}
}
test {
description 'Runs all tests'
testLogging {
showStandardStreams = true
events "passed", "skipped", "failed"
}
useJUnitPlatform()
}
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:deprecation'
options.deprecation = true
}
dependencies {
implementation 'org.jetbrains:annotations:15.0'
testImplementation('org.junit.jupiter:junit-jupiter:5.6.1')
testImplementation('org.junit.jupiter:junit-jupiter-params:5.7.0')
testImplementation 'org.mockito:mockito-inline:3.6.0'
testImplementation 'org.mockito:mockito-junit-jupiter:3.6.28'
}
def unitTest = tasks.register("unitTest", Test) {
description 'Run unit tests only'
useJUnitPlatform()
filter {
includeTestsMatching "com.neopragma.cobolcheck.*Test"
}
}
def integrationTest = tasks.register("integrationTest", Test) {
description 'Run integration tests only'
dependsOn unitTest
useJUnitPlatform()
filter {
includeTestsMatching "com.neopragma.cobolcheck.*IT"
}
}
task fatJar(type: Jar) {
// archiveFileName "${productName}-${productVersion}.jar"
archiveName "${productName}-${productVersion}.jar"
description 'Create executable jar'
dependsOn integrationTest
manifest {
attributes 'Main-Class': "${mainClassName}"
}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
task copyJar(type: Copy) {
description 'Copy executable jar to bin directory prior to distribution'
dependsOn fatJar
from('build/libs/')
include '**/*.jar'
into 'bin/'
}
task prepareDistribution(type: Zip) {
archiveName "${productName}-${productVersion}.zip"
description 'Prepare distribution archive'
dependsOn copyJar
from "${projectDir}"
include([ "config.properties",
"scripts/*",
"bin/${productName}-${productVersion}.jar",
"src/main/cobol/ALPHA.CBL",
"src/main/cobol/NUMBERS.CBL",
"src/test/cobol/ALPHA/*",
"src/test/cobol/NUMBERS/*",
"cobolcheck",
"cobolcheck.cmd" ])
rename("build/libs/(.*)", "\$1")
}
def approvalTest = tasks.register("approvalTest", Test) {
description 'Run approval test only'
dependsOn fatJar
doLast {
if ("${OS_NAME}" == "linux") {
println "Linux detected"
def proc = "./approvaltest".execute()
proc.waitForProcessOutput(System.out, System.err)
proc = "diff ${approvalExpectedOutput} ${approvalActualOutput}".execute()
proc.waitForProcessOutput(System.out, System.err)
println "exit code from diff: ${proc.exitValue()}"
if (proc.exitValue() > 0) {
throw new StopExecutionException("${approvalExpectedOutput} and ${approvalActualOutput} are different")
} else {
println "${approvalExpectedOutput} matches ${approvalActualOutput} - PASS"
}
}
}
}
task defaultProperties {
description 'Show the default properties for this project'
println "Project: $project"
println "Name: $name"
println "Path: $path"
println "Project directory: $projectDir"
println "Build directory: $buildDir"
println "Version: $version"
println "Group: $project.group"
println "Description: $project.description"
}
task osInfo {
description 'Show information about the operating system'
doLast {
println "Family: ${OS_NAME}"
println "Version: ${OS_VERSION}"
println "Architecture: ${OS_ARCH}"
}
}