-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathbuild.gradle
175 lines (151 loc) · 4.23 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
/*
* Build configuraiton for the ImageLab project.
* Version: 1.8.2
*/
plugins {
// Apply the java plugin to add support for Java
id 'java'
// Apply the application plugin to add support for building a CLI application
id 'application'
// Apply the jacoco plugin to add support for junit code coverage analysis
id 'jacoco'
// Apply the checkstyle plugin to add support for adherence to coding conventions
id 'checkstyle'
}
repositories {
jcenter()
}
dependencies {
implementation 'junit:junit:4.12'
// These dependencies are used by the application.
// implementation 'com.google.guava:guava:28.0-jre'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
// JUnit compile dependencies
testCompile 'junit:junit:4.12'
compile 'junit:junit:4.12'
}
// Add source code directories
sourceSets {
main {
java {
srcDirs('imagelab','filters','sound',"${project.projectDir}")
}
}
test {
java {
srcDirs('imagelab','filters','sound',"${project.projectDir}")
}
}
}
application {
// Define the main class for the application
mainClassName = 'Run'
}
jar {
manifest {
attributes "Main-Class": "Run"
}
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
test {
useJUnit()
reports.html.destination = file("$buildDir/reports/JUnit")
}
// Define jacoco version to be used
jacoco {
toolVersion = "0.8.4"
reportsDir = file("$buildDir/reports/jacoco")
applyTo run
}
// Define file type for structured reports
jacocoTestReport {
reports{
xml.enabled false
csv.enabled false
html.destination file("$buildDir/reports/jacoco")
}
}
// Define coverage pass/fail rules for unit tests
jacocoTestCoverageVerification {
violationRules {
rule {
element = 'CLASS'
limit {
counter = "LINE"
value = "COVEREDRATIO"
minimum = 0.85
}
}
}
}
task checkstyle(type: Checkstyle, dependsOn: ['checkstyleMain', 'checkstyleTest']) {
group 'Verification'
description 'Generates reports from Checkstyle.'
}
tasks.withType(Checkstyle) {
ignoreFailures = true
reports {
xml.enabled false
html.enabled true
}
}
/* moveClassFilesToRootDirs will move all compiled
** .class files to their corresponding root directory.
** Moving the files to their corresponding root
** directory is necessary for mimicking BlueJ's
** convention as the project is designed to search
** the root directories for .class files.
*/
task moveClassFilesToRootDirs {
task copyFilterClassFiles(type: Copy) {
from ('build/classes/java/main/filters')
into 'filters/'
}
task copyImagelabClassFiles(type: Copy) {
from ('build/classes/java/main/imagelab')
into 'imagelab/'
}
task copySoundClassFiles(type: Copy) {
from ('build/classes/java/main/sound')
into 'sound/'
}
task copyRunClassFile(type: Copy) {
from ('build/classes/java/main')
into "${project.projectDir}"
}
task copyImageLabJarFile(type: Copy) {
from ('build/libs')
into "${project.projectDir}"
}
task removeBuildClassesDir(type: Delete) {
delete 'build/classes'
}
task removeBuildLibsDir(type: Delete) {
delete 'build/libs'
}
}
// List the tasks to be executed within moveClassFilesToRootDirs task
moveClassFilesToRootDirs.dependsOn copyFilterClassFiles, copyImagelabClassFiles,
copySoundClassFiles, copyRunClassFile, copyImageLabJarFile
moveClassFilesToRootDirs.finalizedBy removeBuildClassesDir, removeBuildLibsDir
run.dependsOn copyFilterClassFiles
build.finalizedBy moveClassFilesToRootDirs
// remove all *.class files from filters, imagelab, sound
task removeClassFilesFromRootDirs {
delete fileTree("filters").matching {
include "*.class"
}
delete fileTree("imagelab").matching {
include "*.class"
}
delete fileTree("sound").matching {
include "*.class"
}
delete fileTree("${project.projectDir}").matching {
include "Run.class"
}
}
clean.finalizedBy removeClassFilesFromRootDirs