forked from reposense/RepoSense
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
259 lines (210 loc) · 7.1 KB
/
build.gradle
File metadata and controls
259 lines (210 loc) · 7.1 KB
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
import org.apache.tools.ant.taskdefs.condition.Os
plugins {
id 'application'
id 'checkstyle'
id 'idea'
id 'jacoco'
id 'java'
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'com.liferay.node' version '4.4.0'
id 'com.github.psxpaul.execfork' version '0.1.8'
id 'com.palantir.git-version' version '0.12.3'
}
mainClassName = 'reposense.RepoSense'
node.nodeVersion = '10.16.0'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
}
configurations {
systemtestImplementation.extendsFrom testImplementation
systemtestRuntime.extendsFrom testRuntime
}
dependencies {
implementation group: 'com.google.code.gson' ,name: 'gson', version:'2.8.5'
implementation group: 'net.freeutils', name: 'jlhttp', version: '2.4'
implementation group: 'net.sourceforge.argparse4j', name: 'argparse4j', version: '0.8.1'
implementation group: 'org.apache.ant', name: 'ant', version: '1.10.3'
implementation group: 'org.apache.commons', name: 'commons-csv', version: '1.6'
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.9'
implementation group: 'org.fusesource.jansi', name: 'jansi', version: '1.18'
testImplementation group: 'junit', name: 'junit', version: '4.12'
}
sourceSets {
systemtest {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
java.srcDir file('src/systemtest/java')
resources.srcDir file('src/systemtest/resources')
}
}
wrapper {
gradleVersion = '5.2.1'
}
run {
//the second arguments indicates the default value associated with the property.
args System.getProperty('args', '').split()
systemProperty "version", getRepoSenseVersion()
}
checkstyle {
toolVersion = '8.1'
configDir = file("$rootProject.projectDir/config/checkstyle")
}
idea {
module {
sourceSets.systemtest.allSource.srcDirs.each { srcDir -> module.testSourceDirs += srcDir }
}
}
jacoco {
toolVersion = "0.8.3"
}
jacocoTestReport {
reports {
html.enabled = true
xml.enabled true
csv.enabled false
html.destination file("${buildDir}/jacocoHtml")
}
}
test {
environment("REPOSENSE_ENVIRONMENT", "TEST")
testLogging {
events 'passed', 'skipped', 'failed'
showStandardStreams = true
}
doFirst {
deleteReposAddressDirectory()
}
doLast {
deleteReposAddressDirectory()
}
}
shadowJar {
archiveName = 'RepoSense.jar'
destinationDir = file("${buildDir}/jar/")
manifest {
attributes 'Implementation-Version': getRepoSenseVersion()
}
}
task installFrontend(type: com.liferay.gradle.plugins.node.tasks.ExecuteNpmTask) {
workingDir 'frontend/'
args = ['install']
}
task buildFrontend(dependsOn: ['installFrontend'], type: com.liferay.gradle.plugins.node.tasks.ExecuteNpmTask) {
workingDir 'frontend/'
args = ['run', 'devbuild']
}
task lintFrontend(dependsOn: ['installFrontend'], type: com.liferay.gradle.plugins.node.tasks.ExecuteNpmTask) {
workingDir 'frontend/'
args = ['run', 'lint']
}
task zipReport(dependsOn: 'buildFrontend', type: Zip) {
from 'frontend/build/'
baseName = 'templateZip'
destinationDir = file('src/main/resources')
}
tasks.shadowJar.dependsOn('zipReport');
tasks.compileJava.dependsOn('zipReport');
tasks.run.dependsOn('compileJava');
task systemtest(dependsOn: 'zipReport', type: Test) {
testClassesDirs = sourceSets.systemtest.output.classesDirs
classpath = sourceSets.systemtest.runtimeClasspath
environment("REPOSENSE_ENVIRONMENT", "TEST")
testLogging {
events 'passed', 'skipped', 'failed'
showStandardStreams = true
}
doFirst {
deleteReposAddressDirectory()
}
doLast {
deleteReposAddressDirectory()
}
}
task startServerInBackground(dependsOn: 'classes', type: com.github.psxpaul.task.JavaExecFork) {
main = mainClassName
classpath = sourceSets.main.runtimeClasspath
args = ['--repo', 'https://github.com/reposense/RepoSense.git', 'https://github.com/reposense/testrepo-Empty.git', '--since', 'd1', '--view']
String versionJvmArgs = '-Dversion=' + getRepoSenseVersion()
jvmArgs = [ versionJvmArgs ]
waitForPort = 9000
}
task installCypress(type: com.liferay.gradle.plugins.node.tasks.ExecuteNpmTask) {
workingDir 'frontend/cypress/'
args = ['install']
}
task cypress(dependsOn: ['zipReport', 'installCypress', 'startServerInBackground'], type: com.liferay.gradle.plugins.node.tasks.ExecuteNpmTask) {
tasks.startServerInBackground.mustRunAfter('installCypress')
workingDir = file('frontend/cypress/')
args = ["run-script", "debug"]
}
task frontendTest(dependsOn: ['zipReport', 'installCypress', 'startServerInBackground'], type: com.liferay.gradle.plugins.node.tasks.ExecuteNpmTask) {
tasks.startServerInBackground.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
}
task coverage(type: JacocoReport) {
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.enabled = true
xml.enabled = true
}
}
String getRepoSenseVersion() {
String repoSenseVersion = project.property("version")
if (repoSenseVersion.equals("unspecified")) {
repoSenseVersion = versionDetails().commitDistance == 0 ? versionDetails().lastTag : versionDetails().gitHash
}
return repoSenseVersion
}
task syncFrontendPublic(type: Sync) {
from 'reposense-report'
into 'frontend/public/'
include '**/*.json'
includeEmptyDirs = false
preserve {
include 'index.html'
include 'favicon.ico'
}
}
task macHotReloadFrontend(type: Exec) {
dependsOn(installFrontend)
onlyIf {Os.isFamily(Os.FAMILY_MAC)}
workingDir 'frontend/'
commandLine 'osascript', '-e', '"tell application "Terminal" to do script "npm run serveOpen""'
}
task windowsHotReloadFrontend(type: Exec) {
dependsOn(installFrontend)
onlyIf {Os.isFamily(Os.FAMILY_WINDOWS)}
workingDir 'frontend/'
commandLine 'cmd','/c', 'START', '"hotreload RepoSense frontend"', 'npm', 'run', 'serveOpen'
}
task hotReloadFrontend() {
dependsOn syncFrontendPublic
finalizedBy windowsHotReloadFrontend
finalizedBy macHotReloadFrontend
}
// End of hot reload Tasks
void deleteReposAddressDirectory() {
final String REPOS_ADDRESS = "repos"
def reposDirectory = new File(REPOS_ADDRESS)
reposDirectory.deleteDir()
}
jacocoTestReport.executionData(systemtest)
jacocoTestReport.executionData(frontendTest)
defaultTasks 'clean', 'build', 'systemtest', 'frontendTest', 'coverage'