-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
150 lines (122 loc) · 4.62 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
plugins {
id 'java'
id 'jacoco'
id 'application'
}
// Set project properties
group 'dod-c3pu'
version 'v0.1'
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
repositories {
mavenCentral()
}
dependencies {
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
testImplementation 'org.junit.jupiter:junit-jupiter-api:+'
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine
testImplementation 'org.junit.jupiter:junit-jupiter-engine:+'
// https://mvnrepository.com/artifact/org.mockito/mockito-core
testImplementation 'org.mockito:mockito-core:+'
// https://mvnrepository.com/artifact/com.miglayout/miglayout-swing
implementation 'com.miglayout:miglayout-swing:+'
// https://mvnrepository.com/artifact/com.miglayout/miglayout-core
implementation 'com.miglayout:miglayout-core:+'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
// implementation 'com.google.code.gson:gson:+'
implementation 'com.google.code.gson:gson:2.10.1'
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
application {
application.mainClass.set('view.Main')
}
test {
useJUnitPlatform()
// testLogging {
// events "passed", "skipped", "failed"
// }
// testLogging.showStandardStreams = true
finalizedBy('jacocoTestReport')
}
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
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))
}
}
}
}
task generateExampleList {
// Define the directory and output file
def examplesDir = file('src/main/resources/examples')
def outputFile = file('src/main/resources/examples/_example_list')
// Declare the output file as a task output. Otherwise, Gradle is not aware
// of it and does not include it in the jar file.
outputs.file(outputFile)
doLast {
// Ensure the output directory exists
if (!examplesDir.exists()) {
examplesDir.mkdirs()
}
// Ensure the output file exists and is empty
outputFile.text = ''
// List files and write their names to the output file
examplesDir.eachFile { File file ->
if (file.isFile() && file.name.endsWith('.txt')) {
outputFile.append(file.name + '\n')
}
}
}
}
// Since the generateExampleList task generates a file in the resources directory,
// we need to ensure it is run before the resources are processed.
processResources.dependsOn generateExampleList
// Configure the jar task
jar {
archiveBaseName.set('c3pu')
archiveVersion.set(version)
manifest {
attributes 'Main-Class': 'view.Main',
'Implementation-Title': archiveBaseName.get(),
'Implementation-Version': archiveVersion.get()
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
// Include the output of the generateExampleList task
from(generateExampleList)
// Specify how to handle duplicate entries
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
// Ensure this task is run before the jar is built
jar.dependsOn(generateExampleList)