forked from melix/groovy-bytecode-ast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
86 lines (76 loc) · 2.67 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
apply plugin: 'idea'
apply plugin: 'groovy'
group = "groovyx.ast.bytecode"
version = "0.2.0-SNAPSHOT"
description = "Provides an AST Transformation which allows to write the body of a method as bytecode"
targetCompatibility = "1.5"
sourceCompatibility = "1.5"
/*
*
*
* Copyright 2011 Cédric Champeau
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* /
* /
*/
// specifies all Maven repositories for resolving external depedencies
repositories {
mavenCentral()
}
ext.cobSerFile="${project.buildDir}/cobertura.ser"
ext.srcOriginal="${sourceSets.main.output.classesDir}"
ext.srcCopy="${srcOriginal}-copy"
// external dependencies
dependencies {
groovy 'org.codehaus.groovy:groovy-all:2.2.1:indy'
testCompile "org.spockframework:spock-core:0.7-groovy-2.0"
testRuntime 'net.sourceforge.cobertura:cobertura:1.9.3'
testCompile "junit:junit:4.8.1"
}
test.doFirst {
ant {
// delete data file for cobertura, otherwise coverage would be added
delete(file:cobSerFile, failonerror:false)
// delete copy of original classes
delete(dir: srcCopy, failonerror:false)
// import cobertura task, so it is available in the script
taskdef(resource:'tasks.properties', classpath: configurations.testRuntime.asPath)
// create copy (backup) of original class files
copy(todir: srcCopy) {
fileset(dir: srcOriginal)
}
// instrument the relevant classes in-place
'cobertura-instrument'(datafile:cobSerFile) {
fileset(dir: srcOriginal,
includes:"groovyx/ast/bytecode/**/*.class",
excludes:"**/*Test.class")
}
}
}
test {
systemProperties "net.sourceforge.cobertura.datafile": cobSerFile
}
test.doLast {
if (new File(srcCopy).exists()) {
// replace instrumented classes with backup copy again
ant {
delete(file: srcOriginal)
move(file: srcCopy,
tofile: srcOriginal)
}
// create cobertura reports
ant.'cobertura-report'(destdir:"${project.buildDir}/test-results",
format:'html', srcdir:"src/main/groovy", datafile:cobSerFile)
}
}