-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
160 lines (137 loc) · 3.93 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
// Copyright (c) 2018 Gonzalo Müller Bravo.
// Licensed under the MIT License (MIT), see LICENSE.txt
plugins {
id 'all.shared.gradle.base-style-config-wrapper'
id 'all.shared.gradle.file-lister' version '1.0.1'
id 'com.github.ksoichiro.console.reporter' version '0.6.2'
id 'checkstyle'
id 'codenarc'
id 'com.gradle.plugin-publish' version '0.10.0'
id 'groovy'
id 'jacoco'
}
repositories {
jcenter()
maven {
url 'https://dl.bintray.com/gmullerb/all.shared.gradle'
}
}
dependencies {
implementation gradleApi()
testCompile 'all.shared.gradle:spy-project-factory:+'
testCompile 'org.junit.jupiter:junit-jupiter-api:+'
testCompile 'org.mockito:mockito-core:+'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:+'
}
final PLUGIN_SITE = 'https://github.com/gmullerb/base-style-config-wrapper/'
final allFilesInTree = fileLister.obtainPartialFileTree()
// Plugin settings
//////////////////
consoleReporter {
jacoco {
autoconfigureCoverageConfig false
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
pluginBundle {
website = PLUGIN_SITE
vcsUrl = PLUGIN_SITE
description = 'A wrapper for \'base-style-config\' configurations'
tags = ['base-style-config', 'code style', 'coding style', 'coding standards', 'best practices',
'checkstyle', 'pmd', 'codenarc', 'eslint', 'typescript-eslint', 'tslint', 'java', 'javascript', 'groovy', 'gradle code',
'backend code', 'frontend code', 'java code', 'groovy code', 'javascript code', 'js code', 'typescript code', 'ts code',
'build code', 'gradle code', 'java', 'groovy', 'javascript', 'js', 'typescript', 'ts', 'gradle',
'java style', 'groovy style', 'javascript style', 'js style', 'typescript style', 'ts style', 'gradle style',
'tabulation checking', 'end of file checking', 'tab character']
plugins {
thePlugin {
id = project.hasProperty('PLUGIN_ID')
? property('PLUGIN_ID')
: 'Set plugin id'
displayName = 'Base Style Configurations\' Wrapper plugin'
}
}
}
// TASKS
////////
task assessCommon (type: Checkstyle) {
// Checkstyle task settings
classpath = files('dummy') // Required by Checkstyle, Not required for Checker modules
config = baseStyleConfig.common.checkstyleConfig
source = allFilesInTree
// gradle task settings
description = 'Run Common Checkstyle analysis for all files.'
group = GROUP_ASSESS
}
task assessGradle(type: CodeNarc) {
// CodeNarc task settings
source = allFilesInTree.filter { it.name.matches('.*\\.gradle') }
// gradle task settings
description = 'Run Codenarc analysis for all gradle files.'
group = GROUP_ASSESS
}
task assess {
group = GROUP_ASSESS
dependsOn = ['codenarcMain', 'codenarcTest']
}
// Task settings
////////////////
codenarcTest {
mustRunAfter = ['compileTestGroovy']
}
check {
dependsOn += ['assess']
}
test {
// Test task settings
useJUnitPlatform()
// gradle task settings
finalizedBy jacocoTestReport, jacocoTestCoverageVerification, reportCoverage
}
jacocoTestReport {
doFirst {
classDirectories.from = files(classDirectories.files.collect {
fileTree(dir: it, exclude: '**/*_closure*')
})
}
reports {
xml.enabled true
}
}
jacocoTestCoverageVerification {
// jacocoTestCoverageVerification task settings
doFirst {
classDirectories.from = files(classDirectories.files.collect {
fileTree(dir: it, exclude: '**/*_closure*')
})
}
violationRules {
rule {
element = 'BUNDLE'
limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.95
}
}
rule {
element = 'BUNDLE'
limit {
counter = 'INSTRUCTION'
value = 'COVEREDRATIO'
minimum = 0.875
}
}
}
// gradle task settings
shouldRunAfter jacocoTestReport
}
reportCoverage {
shouldRunAfter jacocoTestReport
}
// Default task
///////////////
defaultTasks 'assessCommon', 'assessGradle', 'build'