forked from jbake-org/jbake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
188 lines (154 loc) · 5.96 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
plugins {
id "eclipse"
id "idea"
id "io.sdkman.vendors" version "2.0.0" apply false
id "com.jfrog.bintray" version "1.8.5" apply false
id "com.github.kt3k.coveralls" version "2.10.2" apply false
id "org.sonarqube" version "3.1.1" apply false
id 'com.github.ben-manes.versions' version '0.38.0'
id "nebula.optional-base" version "5.0.3" apply false
}
// common variables
ext {
isTravis = (System.getenv("TRAVIS") == "true")
isTravisPullRequest = (System.getenv("TRAVIS_PULL_REQUEST")) != "false"
pullRequestId = System.getenv("TRAVIS_PULL_REQUEST")
pullRequestBranch = System.getenv("TRAVIS_PULL_REQUEST_BRANCH")
hasGithub = System.getenv("GITHUBTOKEN") && System.getenv("GITHUBREPO")
hasSonar = System.getenv("SONARORG") && System.getenv("SONARLOGIN")
sonarDefaultURL = "https://sonarcloud.io"
sonarDefaultProjectKey = "org.jbake:jbake-base:jbake-core"
sonarURL = System.getenv("SONARHOST") ?: sonarDefaultURL
sonarProjectKey = System.getenv("SONARPROJECTKEY") ?: sonarDefaultProjectKey
}
/**
* Apply coveralls to the root project as we just need it here to send the
* aggregated coverage execution data from the jacocoRootReport task
*/
apply plugin: 'com.github.kt3k.coveralls'
/**
* Apply jacoco plugin to all projects and add jcenter as default repository
*/
allprojects {
apply plugin: 'jacoco'
if ( JavaVersion.current().isJava8Compatible() ) {
apply plugin: 'checkstyle'
tasks.withType(Checkstyle) {
reports {
xml.enabled false
html.enabled true
}
}
}
repositories {
jcenter()
}
jacoco {
toolVersion = jacocoVersion
}
}
/**
* Common setup for all subprojects
*/
subprojects {
apply plugin: 'java'
apply plugin: 'nebula.optional-base'
// We do not publish any jars from the jbake-dist project
if ( project.name != "jbake-dist" ) {
apply from: "$rootDir/gradle/maven-publishing.gradle"
apply from: "$rootDir/gradle/signing.gradle"
apply from: "$rootDir/gradle/publishing.gradle"
}
// add source and target compatibility for all JavaCompile tasks
tasks.withType(JavaCompile) {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
}
}
dependencies {
implementation "org.slf4j:slf4j-api:$slf4jVersion"
implementation "org.slf4j:jul-to-slf4j:$slf4jVersion"
implementation "org.slf4j:jcl-over-slf4j:$slf4jVersion"
implementation "ch.qos.logback:logback-classic:$logbackVersion", optional
implementation "ch.qos.logback:logback-core:$logbackVersion", optional
testImplementation "org.junit-pioneer:junit-pioneer:$junitPioneer"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit5Version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5Version"
// compatibility for Junit 4 test
testCompileOnly "junit:junit:$junit4Version"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$junit5Version"
testImplementation "org.assertj:assertj-core:$assertjCoreVersion"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "org.mockito:mockito-junit-jupiter:$mockitoVersion"
testImplementation 'org.itsallcode:junit5-system-extensions:1.1.0'
}
dependencyUpdates.resolutionStrategy {
componentSelection { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm'].any { qualifier ->
selection.candidate.version ==~ /(?i).*[.-]?${qualifier}[.\d-]*/
}
if (rejected) {
selection.reject('Release candidate')
}
}
}
}
//set jvm for all Test tasks (like test and smokeTest)
tasks.withType(Test) {
def args = ['-Xms512m', '-Xmx3g', '-Dorientdb.installCustomFormatter=false=false','-Djna.nosys=true']
/**
* jdk9 build is unable to determine the amount of MaxDirectMemorySize
* See https://pastebin.com/ECvQeHx0
*/
if ( JavaVersion.current().java9Compatible ) {
args << '-XX:MaxDirectMemorySize=2g'
}
jvmArgs args
}
jacocoTestReport {
reports {
xml.enabled = true // coveralls plugin depends on xml format report
html.enabled = true
}
}
jacocoTestReport.dependsOn test
}
task jacocoMerge(type: JacocoMerge) {
description 'Merge all testreport execution data from subprojects excluding jbake-dist'
dependsOn subprojects.test
executionData subprojects.findAll{it.name!="jbake-dist"}.jacocoTestReport.executionData
}
task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'
dependsOn jacocoMerge
sourceDirectories.from files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories.from files(subprojects.sourceSets.main.output)
executionData.from jacocoMerge.executionData
reports {
html.enabled = true
xml.enabled = true
}
}
task testReport(type: TestReport) {
description "Generate an aggregated Testreport for all projects"
destinationDir = file("$buildDir/reports/allTests")
// Include the results from the `test` task in all subprojects
reportOn subprojects*.test
}
coveralls {
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}
tasks.coveralls {
group = 'Coverage reports'
description = 'Uploads the aggregated coverage report to Coveralls'
dependsOn jacocoRootReport
// Skip Task if not run on CI Server
onlyIf { System.env.'CI' }
}