forked from wrdv/testme-idea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
208 lines (190 loc) · 7.19 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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
buildscript {
repositories {
maven { url 'http://dl.bintray.com/jetbrains/intellij-plugin-service' }
}
}
plugins {
id "org.jetbrains.intellij" version "0.4.7"
id 'jacoco'
id 'org.unbroken-dome.test-sets' version '2.1.1'
// id 'net.saliman.cobertura' version '2.3.1'
id 'com.github.kt3k.coveralls' version '2.8.2'
}
//cobertura.coverageFormats = ['html', 'xml'] // coveralls plugin depends on xml format report
//def buildTrigger = System.getenv('TRAVIS_EVENT_TYPE')
def enableIdeaGroovyPlugin=Boolean.valueOf(enableIdeaGroovyPlugin)
def groovyOn = enableIdeaGroovyPlugin ? 'enabled':'disabled'
def enableIdeaScalaPlugin=Boolean.valueOf(enableIdeaScalaPlugin)
def scalaOn = enableIdeaScalaPlugin ? 'enabled':'disabled'
println "*****************************************************************************************************************************************************************"
println " Running build for ideaVersion: $ideaVersion and scalaPluginVersion: $scalaPluginVersion with Groovy plugin ${groovyOn} and Scala plugin ${scalaOn}"
println "*****************************************************************************************************************************************************************"
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'org.jetbrains.intellij'
def isRunInCI=Boolean.valueOf(System.getenv('CI'))
def spockVersion = ideaVersion.startsWith("14.") || ideaVersion.startsWith("15.")? "1.0-groovy-2.3" : "1.0-groovy-2.4"
jacoco {
toolVersion = "0.7.6.201602180812"
}
allprojects{
sourceCompatibility = jvmTargetVersion
targetCompatibility = jvmTargetVersion
repositories {
mavenCentral()
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
if (!javaHome) {
javaHome = System.getenv().JAVA_HOME// javaHome = 'C:\\Program Files\\AdoptOpenJDK\\jdk-13.0.2.8-hotspot'
}
// options.bootClasspath = "$javaHome/jre/lib/rt.jar"
}
testSets {
integrationTest
}
integrationTest {
afterTest { desc, result ->
println "Executing test [${desc.className}].${desc.name} with result: ${result.resultType}"
}
reports.html.enabled = !isRunInCI
}
tasks.withType(Test) {
systemProperty 'enableIdeaGroovyPlugin', enableIdeaGroovyPlugin
systemProperty 'enableIdeaScalaPlugin', enableIdeaScalaPlugin
reports.html.destination = file("${reporting.baseDir}/${name}")
testLogging {
exceptionFormat = TestExceptionFormat.FULL
// events TestLogEvent.FAILED, TestLogEvent.STANDARD_OUT, TestLogEvent.STANDARD_ERROR
events TestLogEvent.values()
showStandardStreams = true
}
}
test {
afterTest { desc, result ->
println "Executing test [${desc.className}].${desc.name} with result: ${result.resultType}"
}
reports.html.enabled = !isRunInCI
}
}
subprojects{
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'jacoco'
dependencies {
testCompile("org.spockframework:spock-core:$spockVersion"){
exclude group: 'org.codehaus.groovy'
}
}
}
def inspectedProjects = subprojects + rootProject
task jacocoMerge(type: JacocoMerge) {
inspectedProjects.each { subproject ->
executionData subproject.tasks.withType(Test)
}
doFirst {
executionData = files(executionData.findAll { it.exists() })
}
}
/*ref: https://docs.gradle.org/current/userguide/jacoco_plugin.html
jacocoTestReport {
reports {
xml.enabled isRunInCI
csv.enabled isRunInCI
html{
enabled !isRunInCI
destination "${buildDir}/reports/jacoco"
}
// html.destination file("${buildDir}/jacocoHtml")
}
}*/
task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'
dependsOn inspectedProjects.test, jacocoMerge
additionalSourceDirs = files(inspectedProjects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(inspectedProjects.sourceSets.main.allSource.srcDirs)
classDirectories = files(inspectedProjects.sourceSets.main.output)
executionData jacocoMerge.destinationFile
reports {
xml.enabled isRunInCI
csv.enabled isRunInCI
html{
enabled !isRunInCI
destination file("${buildDir}/reports/jacoco")
}
}
}
def shouldInstrumentCode = !isRunInCI && !Boolean.valueOf(System.getProperty('skipCodeInstrumentation','false'))
def enabledPlugins = ['java','junit','properties']
if (enableIdeaGroovyPlugin) {
enabledPlugins += 'Groovy'
}
if (enableIdeaScalaPlugin) {
enabledPlugins += ('org.intellij.scala:' + scalaPluginVersion)
}
apply from: "$rootProject.projectDir/shared.gradle"
enabledPlugins = filterPlugins(enabledPlugins)
intellij {
pluginName 'TestMe'
instrumentCode = shouldInstrumentCode
version ideaVersion
type ideaType
downloadSources !isRunInCI
sameSinceUntilBuild false
updateSinceUntilBuild false
plugins = enabledPlugins
publishPlugin {
token System.getenv("ORG_GRADLE_PROJECT_intellijPublishToken")
channels = [ideaPublishChannel]
}
}
idea {
project {
jdkName = jvmTargetVersion
languageLevel = jvmTargetVersion
vcs = 'Git'
}
}
dependencies {
compile(project(':testme-intellij-common')){
exclude group:'com.jetbrains', module: 'ideaIC'
exclude group:'org.jetbrains.plugins', module: 'junit'
exclude group:'org.jetbrains.plugins', module: 'properties'
exclude group:'org.jetbrains.plugins', module: 'Groovy'
}
compile(project(':testme-intellij-groovy')){
exclude group:'com.jetbrains', module: 'ideaIC'
exclude group:'org.jetbrains.plugins', module: 'junit'
exclude group:'org.jetbrains.plugins', module: 'properties'
exclude group:'org.jetbrains.plugins', module: 'Groovy'
}
compile(project(':testme-intellij-scala')){
exclude group:'com.jetbrains', module: 'ideaIC'
exclude group:'org.jetbrains.plugins', module: 'junit'
exclude group:'org.jetbrains.plugins', module: 'properties'
exclude group:'org.jetbrains.plugins', module: 'Groovy'
exclude group:'org.jetbrains.plugins', module: 'Scala'
}
testCompile 'junit:junit:4.12'
testCompile("org.spockframework:spock-core:$spockVersion"){
exclude group: 'org.codehaus.groovy'
}
testCompileOnly group: 'org.scala-lang', name: 'scala-library', version: '2.10.6'
}
check.dependsOn integrationTest
integrationTest.mustRunAfter test
tasks.build.dependsOn(jacocoTestReport)
coveralls {
sourceDirs = inspectedProjects.sourceSets.main.allSource.srcDirs.flatten()
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}
tasks.coveralls {
// group = 'Coverage reports'
// description = 'Uploads the aggregated coverage report to Coveralls'
dependsOn jacocoRootReport
onlyIf { isRunInCI}
}