-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathbuild.gradle
More file actions
147 lines (126 loc) · 5.05 KB
/
Copy pathbuild.gradle
File metadata and controls
147 lines (126 loc) · 5.05 KB
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
import org.gradle.api.tasks.testing.TestDescriptor
import org.gradle.api.tasks.testing.TestListener
import org.gradle.api.tasks.testing.TestResult
apply plugin: 'groovy'
apply plugin: 'java-gradle-plugin'
apply plugin: 'codenarc'
//TODO: Introduce new releasing mechanism - CDBoy is not compatible with Gradle 7+ (due to using old 'maven' plugin)
apply from: "$rootDir/gradle/publishing.gradle"
apply from: "$rootDir/gradle/report-version-consistency-check.gradle"
apply plugin: "com.github.ben-manes.versions"
buildscript {
repositories {
mavenCentral()
mavenLocal()
maven {
//for Plugin Publish plugin
url = 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'pl.allegro.tech.build.axion-release:pl.allegro.tech.build.axion-release.gradle.plugin:1.21.1'
classpath 'io.github.gradle-nexus.publish-plugin:io.github.gradle-nexus.publish-plugin.gradle.plugin:2.0.0'
classpath 'com.gradle.publish:plugin-publish-plugin:2.0.0'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.53.0'
}
}
java {
sourceCompatibility = 1.8
}
ext.pitestAggregatorVersion = "1.22.1" //Must be equal to default PIT version in PitestPlugin
repositories {
mavenCentral()
mavenLocal()
}
sourceSets {
funcTest
}
configurations {
funcTestImplementation.extendsFrom testImplementation
funcTestRuntimeOnly.extendsFrom testRuntimeOnly
}
dependencies {
implementation localGroovy()
compileOnly "org.pitest:pitest-aggregator:$pitestAggregatorVersion"
testImplementation('org.spockframework:spock-core:2.4-groovy-3.0') {
exclude group: 'org.codehaus.groovy'
}
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation 'net.bytebuddy:byte-buddy:1.18.4' //for Spying in Spock
funcTestImplementation sourceSets.main.output //to make production plugin classes visible in functional tests (it's not in testCompile configuration)
funcTestImplementation sourceSets.test.output
funcTestImplementation('com.netflix.nebula:nebula-test:10.6.2') {
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
}
}
tasks.register("funcTest", Test) {
description = 'Run the functional tests.'
group = 'Verification'
testClassesDirs = sourceSets.funcTest.output.classesDirs
classpath = sourceSets.funcTest.runtimeClasspath
jvmArgs '-Xmx1g'
}
funcTest.shouldRunAfter test
check.shouldRunAfter funcTest
check.dependsOn funcTestClasses //or more generically: tasks.withType(AbstractCompile)
//Both cannot be put into publishing.gradle due to: https://github.com/gradle/gradle/issues/1262
tasks.withType(com.gradle.publish.PublishTask).configureEach { it.dependsOn(funcTest, check) }
////do not generate extra load on Nexus with new staging repository if signing fails
tasks.withType(io.github.gradlenexus.publishplugin.InitializeNexusStagingRepository).configureEach {
shouldRunAfter(tasks.withType(Sign))
}
tasks.register("testReport", TestReport) {
destinationDirectory = file(layout.buildDirectory.dir("reports/allTests"))
testResults.from(test*.binaryResultsDirectory, funcTest*.binaryResultsDirectory)
}
tasks.withType(Test).configureEach { testTask ->
testTask.configure {
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
//Use TestListener interface instead of deprecated afterSuite(Closure) - see Gradle 9.4 upgrade guide
addTestListener(new TestListener() {
void beforeSuite(TestDescriptor suite) {}
void afterSuite(TestDescriptor suite, TestResult result) {
if (!suite.parent) {
if (result.testCount == 0) {
throw new IllegalStateException("No tests were found. Failing the build")
}
}
}
void beforeTest(TestDescriptor testDescriptor) {}
void afterTest(TestDescriptor testDescriptor, TestResult result) {}
})
}
}
tasks.validatePlugins {
enableStricterValidation = true
failOnWarning = true
}
codenarc {
toolVersion = "2.0.0"
}
tasks.register("codenarc") {
configure {
dependsOn tasks.withType(CodeNarc)
}
}
//Workaround on https://github.com/gradle/gradle/issues/12663
//TODO: "configureEach{}" causes: "DefaultTaskContainer#register(String, Action) on task set cannot be executed in the current context" - https://github.com/gradle/gradle/issues/26668
tasks.withType(CodeNarc) { codeNarcTask ->
reports {
text.required = true
html.required = true
}
codeNarcTask.finalizedBy(tasks.register("print${codeNarcTask.name.capitalize()}") {
onlyIf {
codeNarcTask.state.failure != null
}
doLast {
logger.warn("\n****************************** CODE NARC ******************************")
logger.warn(codeNarcTask.reports.text.outputLocation.getAsFile().get().text.trim())
logger.warn("****************************** CODE NARC ******************************\n")
}
})
}