forked from reposense/RepoSense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
325 lines (263 loc) · 9.6 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
plugins {
id 'application'
id 'checkstyle'
id 'idea'
id 'jacoco'
id 'java'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.liferay.node' version '7.2.18'
id 'com.github.psxpaul.execfork' version '0.2.0'
id 'com.palantir.git-version' version '0.13.0'
}
OperatingSystem os = DefaultNativePlatform.currentOperatingSystem;
mainClassName = 'reposense.RepoSense'
node.download = false // The Liferay Node Gradle Plugin will use the system PATH to find the Node/npm executable.
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
repositories {
mavenCentral()
}
configurations {
systemtestImplementation.extendsFrom testImplementation
systemtestRuntime.extendsFrom testRuntime
}
dependencies {
String jUnitVersion = '5.8.2'
implementation group: 'com.google.code.gson' ,name: 'gson', version:'2.9.0'
implementation group: 'net.freeutils', name: 'jlhttp', version: '2.6'
implementation group: 'net.sourceforge.argparse4j', name: 'argparse4j', version: '0.9.0'
implementation group: 'org.apache.ant', name: 'ant', version: '1.10.12'
implementation group: 'org.apache.commons', name: 'commons-csv', version: '1.9.0'
implementation group: 'org.fusesource.jansi', name: 'jansi', version: '2.4.0'
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.17.0'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: jUnitVersion
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: jUnitVersion
}
sourceSets {
systemtest {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
java.srcDir file('src/systemtest/java')
resources.srcDir file('src/systemtest/resources')
}
}
def installFrontend = tasks.register('installFrontend', com.liferay.gradle.plugins.node.tasks.ExecutePackageManagerTask) {
workingDir 'frontend/'
args = ['ci']
}
def buildFrontend = tasks.register('buildFrontend', com.liferay.gradle.plugins.node.tasks.ExecutePackageManagerTask) {
dependsOn installFrontend
workingDir 'frontend/'
args = ['run', 'devbuild']
}
def zipReport = tasks.register('zipReport', Zip) {
dependsOn buildFrontend
from 'frontend/build/'
archiveBaseName = 'templateZip'
destinationDirectory = file('src/main/resources')
}
def copyCypressConfig = tasks.register('copyCypressConfig', Copy) {
description 'Copies the config files used by the backend to generate the test report for Cypress testing into an isolated working directory'
from 'frontend/cypress/config'
into 'build/serveTestReport/exampleconfig'
}
def copyMainClasses = tasks.register('copyMainClasses', Copy) {
description 'Copies the backend classes used to generate the test report for Cypress testing into an isolated working directory'
dependsOn classes
from 'build/classes/java/main'
into 'build/serveTestReport/java/main'
}
def compileJava = tasks.compileJava
tasks.named("processSystemtestResources").configure {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
tasks.run.dependsOn(zipReport);
run {
//the second arguments indicates the default value associated with the property.
tasks.compileJava.mustRunAfter(zipReport)
args System.getProperty('args', '').split()
systemProperty "version", getRepoSenseVersion()
}
checkstyle {
toolVersion = '9.3'
getConfigDirectory().set(file("$rootProject.projectDir/config/checkstyle"))
}
idea {
module {
sourceSets.systemtest.allSource.srcDirs.each { srcDir -> module.testSourceDirs += srcDir }
}
}
test {
environment("REPOSENSE_ENVIRONMENT", "TEST")
testLogging {
events 'passed', 'skipped', 'failed'
showStandardStreams = true
}
doFirst {
deleteReposAddressDirectory()
}
useJUnitPlatform()
doLast {
deleteReposAddressDirectory()
}
}
tasks.shadowJar.dependsOn(zipReport);
shadowJar {
tasks.compileJava.mustRunAfter(zipReport)
tasks.processResources.mustRunAfter(zipReport)
archiveFileName = 'RepoSense.jar'
destinationDirectory = file("${buildDir}/jar/")
manifest {
attributes 'Implementation-Version': getRepoSenseVersion()
}
}
tasks.register('lintFrontend', com.liferay.gradle.plugins.node.tasks.ExecutePackageManagerTask) {
dependsOn installFrontend
workingDir 'frontend/'
args = ['run', 'lint']
}
def checkstyleMain = tasks.checkstyleMain
def checkstyleTest = tasks.checkstyleTest
def checkstyleSystemtest = tasks.checkstyleSystemtest
tasks.register('checkstyleAll', Checkstyle) {
dependsOn checkstyleMain, checkstyleTest, checkstyleSystemtest
tasks.checkstyleTest.mustRunAfter('checkstyleMain')
tasks.checkstyleSystemtest.mustRunAfter('checkstyleTest')
}
tasks.register('environmentalChecks', Exec) {
workingDir 'config/checks/'
if (os.isWindows()){
commandLine 'cmd', '/c', 'run-checks.bat'
} else {
commandLine 'sh', './run-checks.sh'
}
}
tasks.register('systemtest', Test) {
testClassesDirs = sourceSets.systemtest.output.classesDirs
classpath = sourceSets.systemtest.runtimeClasspath
environment("REPOSENSE_ENVIRONMENT", "TEST")
testLogging {
events 'passed', 'skipped', 'failed'
showStandardStreams = true
}
doFirst {
deleteReposAddressDirectory()
}
useJUnitPlatform()
doLast {
deleteReposAddressDirectory()
}
}
def serveTestReportInBackground = tasks.register('serveTestReportInBackground', com.github.psxpaul.task.JavaExecFork) {
description 'Creates a background server process for the test report that is to be used by Cypress'
dependsOn zipReport, compileJava, processResources, copyCypressConfig, copyMainClasses
tasks.compileJava.mustRunAfter(zipReport)
tasks.processResources.mustRunAfter(zipReport)
workingDir = 'build/serveTestReport'
main = mainClassName
classpath = sourceSets.main.runtimeClasspath
args = ['--config', './exampleconfig', '--since', 'd1', '--view', '-A']
String versionJvmArgs = '-Dversion=' + getRepoSenseVersion()
jvmArgs = [ versionJvmArgs ]
waitForPort = 9000
}
def installCypress = tasks.register('installCypress', com.liferay.gradle.plugins.node.tasks.ExecutePackageManagerTask) {
workingDir 'frontend/cypress/'
args = ['ci']
}
tasks.register('cypress', com.liferay.gradle.plugins.node.tasks.ExecutePackageManagerTask) {
dependsOn installCypress, serveTestReportInBackground
tasks.serveTestReportInBackground.mustRunAfter(installCypress)
workingDir = file('frontend/cypress/')
args = ["run-script", "debug"]
}
tasks.register('frontendTest', com.liferay.gradle.plugins.node.tasks.ExecutePackageManagerTask) {
dependsOn installCypress, serveTestReportInBackground
tasks.serveTestReportInBackground.mustRunAfter(installCypress)
workingDir = file('frontend/cypress/')
args = ["run-script", "tests"]
// Run tests in CI without slow motion
if (project.hasProperty('ci')) {
args = ["run-script", "ci"]
}
}
tasks.withType(Copy) {
includeEmptyDirs = true
}
jacoco {
toolVersion = "0.8.7"
}
jacocoTestReport {
reports {
html.required = true
xml.required = true
csv.required = false
html.destination file("${buildDir}/jacocoHtml")
}
executionData systemtest, frontendTest
}
tasks.register('coverage', JacocoReport)
coverage.configure {
sourceDirectories.from files(sourceSets.main.allSource.srcDirs)
classDirectories.from files(sourceSets.main.output)
executionData.from files(jacocoTestReport.executionData)
afterEvaluate {
classDirectories.from files(classDirectories.files.collect {
fileTree(dir: it, exclude: ['**/*.jar'])
})
}
reports {
html.required = true
xml.required = true
}
}
String getRepoSenseVersion() {
String repoSenseVersion = project.property("version")
if (repoSenseVersion.equals("unspecified")) {
repoSenseVersion = versionDetails().commitDistance == 0 ? versionDetails().lastTag : versionDetails().gitHash
}
return repoSenseVersion
}
def syncFrontendPublic = tasks.register('syncFrontendPublic', Sync) {
from 'reposense-report'
into 'frontend/public/'
include '**/*.json'
includeEmptyDirs = false
preserve {
include 'index.html'
include 'favicon.ico'
include 'title.md'
}
}
def macHotReloadFrontend = tasks.register('macHotReloadFrontend', Exec) {
dependsOn installFrontend
onlyIf {os.isMacOsX()}
workingDir 'frontend/'
commandLine 'npm', 'run', 'serveOpen'
}
def windowsHotReloadFrontend = tasks.register('windowsHotReloadFrontend', Exec) {
dependsOn installFrontend
onlyIf {os.isWindows()}
workingDir 'frontend/'
commandLine 'cmd','/c', 'START', '"hotreload RepoSense frontend"', 'npm', 'run', 'serveOpen'
}
def linuxHotReloadFrontend = tasks.register('linuxHotReloadFrontend', Exec) {
dependsOn installFrontend
onlyIf {os.isLinux()}
workingDir 'frontend/'
commandLine 'npm', 'run', 'serveOpen'
}
tasks.register('hotReloadFrontend') {
dependsOn syncFrontendPublic
finalizedBy windowsHotReloadFrontend
finalizedBy macHotReloadFrontend
finalizedBy linuxHotReloadFrontend
}
// End of hot reload Tasks
void deleteReposAddressDirectory() {
final String REPOS_ADDRESS = "repos"
def reposDirectory = new File(REPOS_ADDRESS)
reposDirectory.deleteDir()
}
defaultTasks 'clean', 'build', 'systemtest', 'frontendTest', 'coverage'