-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
150 lines (123 loc) · 4.3 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
/*
* This build file was auto generated by running the Gradle 'init' task
* by 'rupakhet' at '12/2/16 12:19 PM' with Gradle 3.0
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* user guide available at https://docs.gradle.org/3.0/userguide/tutorial_java_projects.html
*/
// Apply the java plugin to add support for Java
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'application'
// TODO: Change this to the class that has the main method of your application
mainClassName = "app.Application"
// TODO: Update the args value to choose what classes to run. Here is just an example.
run {
args "app.Application",
"java.lang.String"
}
sourceCompatibility = 1.8
version = "1.0.0-SNAPSHOT"
//create a single Jar with all dependencies
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Implementation-Version': version,
'Main-Class': 'app.Application'
}
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
//gradle.java.home="C:\\Program Files\\Java\\jdk1.8.0_91"
// In this section you declare where to find the dependencies of your project
repositories {
maven {
url "https://maven.csse.rose-hulman.edu/artifactory/libs-release"
}
maven {
url "https://mvnrepository.com/artifact/org.easymock/"
}
maven {
url "https://mvnrepository.com/artifact/org.json/json"
}
jcenter()
}
test {
testLogging.showStandardStreams = true
beforeTest { descriptor ->
logger.lifecycle("Running test: " + descriptor)
}
onOutput { descriptor, event ->
logger.lifecycle("Test: " + descriptor + " produced: " + event.message)
}
}
// Code coverage analyzer
jacoco {
toolVersion = "0.7.+"
}
jacocoTestReport {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)
reports {
xml.enabled true
csv.enabled false
html.enabled true
}
}
// In this section you declare the dependencies for your production and test code
dependencies {
// The production code uses asm core library
compile group: 'org.ow2.asm', name: 'asm-all', version: '5.0.+'
// https://mvnrepository.com/artifact/com.martiansoftware/jsap
compile group: 'com.martiansoftware', name: 'jsap', version: '2.1'
// https://mvnrepository.com/artifact/org.json/json
compile group: 'org.json', name: 'json', version: '20160810'
// The production code uses the SLF4J logging API at compile time
compile 'org.slf4j:slf4j-api:1.7.21'
// Declare the dependency for your favourite test framework you want to use in your tests.
testCompile 'junit:junit:4.+'
testCompile "org.mockito:mockito-core:2.+"
}
test {
jacoco {
append = false
}
}
test.finalizedBy(jacocoTestReport)
jacocoTestReport.mustRunAfter(test)
task codeCoverageInfo (dependsOn: jacocoTestReport) {
ext.srcFile = file("${reportsDir}/jacoco/test/jacocoTestReport.xml")
doLast {
println "Transforming source file."
def parser = new XmlParser()
parser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false);
parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
parser.setFeature("http://xml.org/sax/features/namespaces", false)
def reportNode = parser.parse(srcFile)
reportNode.children().each {
if(it.name() == 'counter') {
String type = it.@type
float missed = it.@missed as float
float covered = it.@covered as float
float percentage = covered / (missed + covered) * 100
println "Code Coverage[$type]: $percentage%"
}
}
}
}
jacocoTestReport.finalizedBy(codeCoverageInfo)
codeCoverageInfo.mustRunAfter(jacocoTestReport)
jar {
manifest {
attributes 'Implementation-Title': 'Rose-Hulman Reverse Engineered Design Application',
'Implementation-Version': '${version}'
}
}
task wraper(type: Wrapper) {
gradleVersion = "3.2.1"
}