-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
218 lines (189 loc) · 5.78 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
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.8
version = '1.0'
def classesJava = "${project.buildDir}/classes/java/main/"
def javasRoot = "${rootProject.rootDir}/src/main/java"
def testClassesJava = "${project.buildDir}/classes/java/test"
def testJavaRoot = "${rootProject.rootDir}/src/test/java"
def javaRootFB = "${javasRoot}/com/tactfactory/algotojava"
def classesJavaFB = "${classesJava}/com/tactfactory/algotojava"
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart',
'Implementation-Version': version
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'com.google.guava:guava:22.0'
testCompile group: 'junit', name: 'junit', version: '4.+'
compile 'mysql:mysql-connector-java:5.1.37'
}
test {
systemProperties 'property': 'value'
ignoreFailures = true
}
uploadArchives {
repositories {
flatDir {
dirs 'repos'
}
}
}
/*sourceSets {
main {
//if you truly want to override the defaults:
output.resourcesDir = file('build')
// Compiled Java classes should use this directory
java.outputDir = file(classesJava)
}
}*/
apply plugin: 'jacoco'
jacoco {
toolVersion "0.7.4.201502262128"
}
jacocoTestReport {
description 'Run code coverage with JaCoCo.'
group 'Verification'
reports {
xml.enabled = false
csv.enabled = false
html.enabled = true
html.destination "${buildDir}/reports/jacoco"
}
}
/**
* Checkstyle tasks
* Usage:
* - place this file under root dir of your project at /gradle directory
* - apply script from your gradle file:
* apply from : "{rootDir}/gradle/checkstyle.gradle"
*
* To configure checkstyle use configs at:
* "{rootDir}/config/checkstyle/checkstyle.xml" - for main projects
* "{rootDir}/config/checkstyle/checkstyle-test.xml" - for tests
* "{rootDir}/config/checkstyle/suppresions.xml" - for style suppressions
*
* Xml and HTML reports are stored:
* "{project.buildDir}/reports/checkstyle/"
* HTML styling is done by XSLT stylesheet:
* "{rootDir}/config/checkstyle/checkstyle-noframes-sorted.xsl"
*/
apply plugin: 'checkstyle'
checkstyle {
toolVersion = "6.13"
}
task checkstyleMain (type: Checkstyle, overwrite: true) {
ignoreFailures = true
showViolations = false
source fileTree('src/main/java')
include '**/*.java'
exclude '**/gen/**'
exclude '**/R.java'
exclude '**/BuildConfig.java'
reports {
xml.destination "$project.buildDir/reports/checkstyle/main.xml"
}
classpath = fileTree(classesJava)
configFile = file("${rootProject.rootDir}/checkstyle_rules.xml")
}
task checkstyleTest (type: Checkstyle, overwrite: true){
ignoreFailures = true
showViolations = false
source fileTree('src/test/java')
include '**/*.java'
exclude '**/gen/**'
exclude '**/R.java'
exclude '**/BuildConfig.java'
reports {
xml.destination "$project.buildDir/reports/checkstyle/test.xml"
}
classpath = fileTree("$project.buildDir/classes/test/")
configFile = file("${rootProject.rootDir}/checkstyle_rules.xml")
}
task checkstyleReport << {
checkType = project.ext.get("checkType")
if (file("$buildDir/reports/checkstyle/${checkType}.xml").exists()) {
ant.xslt(in: "$project.buildDir/reports/checkstyle/${checkType}.xml",
style:"C:/ContinuousIntegration/checkstyle-6.13/checkstyle-noframes-sorted.xsl",
out:"$project.buildDir/reports/checkstyle/checkstyle_${checkType}.html"
)
}
}
task checkstyle(dependsOn:['checkstyleMain', 'checkstyleTest']){
description 'Runs Checkstyle inspection against Android sourcesets.'
group = 'Code Quality'
}
gradle.taskGraph.afterTask {Task task, TaskState state ->
if(state.failure) {
if (task.name in ['checkstyleMain', 'checkstyleTest']) {
checkstyleReport {
def matcher = task.name =~ /^checkstyle(.*)$/
if (matcher.matches()) {
project.ext.set("checkType", matcher.group(1).toLowerCase())
}
}
checkstyleReport.execute()
}
}
}
/**
* PMD task
* Usage:
* - place this file under root dir of your project at /gradle directory
* - apply script from your gradle file:
* apply from : "{rootDir}/gradle/pmd.gradle"
*
* To configure pmd ruleset use configs at:
* "{rootDir}/config/pmd/pmd-ruleset.xml"
*
* Xml and HTML reports are stored:
* "{project.buildDir}/reports/pmd/"
*/
apply plugin: 'pmd'
task pmdMain(type: Pmd, overwrite: true) {
ignoreFailures = true
description 'Runs PMD inspection against Android sourcesets.'
group = 'Code Quality'
ruleSetFiles = files("${rootProject.rootDir}/pmd_rules.xml")
source = fileTree(javasRoot)
include '**/*.java'
exclude '**/gen/**'
reports {
xml.enabled = false
html.enabled = true
}
}
task pmdTest(type: Pmd, overwrite: true) {
ignoreFailures = true
description 'Runs PMD inspection against Android sourcesets.'
group = 'Code Quality'
ruleSetFiles = files("${rootProject.rootDir}/pmd_rules.xml")
source = fileTree(testJavaRoot)
include '**/*.java'
exclude '**/gen/**'
reports {
xml.enabled = false
html.enabled = true
}
}
// add CPD to check
check << {
File outDir = new File('build/reports/pmd/')
outDir.mkdirs()
ant.taskdef(name: 'cpd', classname: 'net.sourceforge.pmd.cpd.CPDTask',
classpath: configurations.pmd.asPath)
ant.cpd(minimumTokenCount: '100', format: 'xml',
outputFile: new File(outDir , 'cpd.xml')) {
fileset(dir: javasRoot) {
include(name: '**/*.java')
}
}
}
task copyDeps(type: Copy) {
from configurations.runtime
into 'libs'
}