-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathbuild.gradle
185 lines (152 loc) · 6.11 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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
id 'java'
}
group 'cs321'
version '1.0'
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}
repositories {
mavenCentral()
}
dependencies {
// https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc
implementation group: 'org.xerial', name: 'sqlite-jdbc', version: '3.36.0.3'
testImplementation group: 'junit', name: 'junit', version: '4.12'
}
task createJarGeneBankCreateBTree(type: Jar) {
group = 'Run'
description = 'create build/libs/GeneBankCreateBTree.jar'
from(sourceSets.main.output) {
include "cs321/create/**"
}
manifest {
attributes 'Implementation-Title': 'GeneBankCreateBTree',
'Implementation-Version': archiveVersion,
'Main-Class': 'cs321.create.GeneBankCreateBTree'
}
archiveBaseName = 'GeneBankCreateBTree'
archiveVersion = ''
// the duplicatesStrategy is required by Gradle 7
duplicatesStrategy = DuplicatesStrategy.INCLUDE //allow duplicate *.class files in the jar
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
task createJarGeneBankSearchBTree(type: Jar) {
group = 'Run'
description = 'create build/libs/GeneBankSearchBTree.jar'
from(sourceSets.main.output) {
include "cs321/search/**"
}
manifest {
attributes 'Implementation-Title': 'GeneBankSearchBTree',
'Implementation-Version': archiveVersion,
'Main-Class': 'cs321.search.GeneBankSearchBTree'
}
archiveBaseName = 'GeneBankSearchBTree'
archiveVersion = ''
// the duplicatesStrategy is required by Gradle 7
duplicatesStrategy = DuplicatesStrategy.INCLUDE //allow duplicate *.class files in the jar
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
task createJarGeneBankSearchDatabase(type: Jar) {
group = 'Run'
description = 'create build/libs/GeneBankSearchDatabase.jar'
from(sourceSets.main.output) {
include "cs321/search/**"
}
manifest {
attributes 'Implementation-Title': 'GeneBankSearchDatabase',
'Implementation-Version': archiveVersion,
'Main-Class': 'cs321.search.GeneBankSearchDatabase'
}
archiveBaseName = 'GeneBankSearchDatabase'
archiveVersion = ''
// the duplicatesStrategy is required by Gradle 7
duplicatesStrategy = DuplicatesStrategy.INCLUDE //allow duplicate *.class files in the jar
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
tasks.createJarGeneBankCreateBTree.finalizedBy('printInstructionsToRunJarGeneBankCreateBTree')
task printInstructionsToRunJarGeneBankCreateBTree {
doLast {
println ''
println '------------------------------------------------------------'
println 'The GeneBankCreateBTree.jar was created successfully. Run:'
println '$ java -jar build/libs/GeneBankCreateBTree.jar <arguments>'
println '------------------------------------------------------------'
println ''
}
onlyIf {
tasks.createJarGeneBankCreateBTree.state.failure == null
}
}
tasks.createJarGeneBankSearchBTree.finalizedBy('printInstructionsToRunJarGeneBankSearchBTree')
task printInstructionsToRunJarGeneBankSearchBTree {
doLast {
println ''
println '------------------------------------------------------------'
println 'The GeneBankSearchBTree.jar was created successfully. Run:'
println '$ java -jar build/libs/GeneBankSearchBTree.jar <arguments>'
println '------------------------------------------------------------'
println ''
}
onlyIf {
tasks.createJarGeneBankSearchBTree.state.failure == null
}
}
tasks.createJarGeneBankSearchDatabase.finalizedBy('printInstructionsToRunJarGeneBankSearchDatabase')
task printInstructionsToRunJarGeneBankSearchDatabase {
doLast {
println ''
println '------------------------------------------------------------'
println 'The GeneBankSearchDatabase.jar was created successfully. Run:'
println '$ java -jar build/libs/GeneBankSearchDatabase.jar <arguments>'
println '------------------------------------------------------------'
println ''
}
onlyIf {
tasks.createJarGeneBankSearchDatabase.state.failure == null
}
}
// When running
// `$ ./gradlew test`
// print to console the test outcome and a summary of the tests
// Source:
// https://stackoverflow.com/questions/3963708/gradle-how-to-display-test-results-in-the-console-in-real-time
tasks.withType(Test) {
testLogging {
// set options for log level LIFECYCLE
events TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT
exceptionFormat TestExceptionFormat.FULL
showExceptions true
showCauses true
showStackTraces true
// set options for log level DEBUG and INFO
debug {
events TestLogEvent.STARTED,
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT
exceptionFormat TestExceptionFormat.FULL
}
info.events = debug.events
info.exceptionFormat = debug.exceptionFormat
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
}
}
}