forked from Inactionware/uapi.cornerstone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
164 lines (136 loc) · 4.29 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
/*
* Copyright (C) 2017. The UAPI Authors
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at the LICENSE file.
*
* You must gained the permission from the authors if you want to
* use the project into a commercial product
*/
buildscript {
repositories {
jcenter()
}
}
apply plugin: 'jacoco'
ext.project_version = getProjectVersion()
ext.publish_repo = getMavenRepo()
allprojects {
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven { url "http://dl.bintray.com/typesafe/maven-releases" }
maven { url "http://dl.bintray.com/inactionware/maven-snapshot" }
maven { url "http://dl.bintray.com/inactionware/maven-release" }
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'jacoco'
apply plugin: 'maven'
apply plugin: 'maven-publish'
group = "${project_group}"
version = "${project_version}"
sourceCompatibility = 1.8
targetCompatibility = 1.8
configurations {
codacy
}
dependencies {
testCompile "org.spockframework:spock-core:${spock_version}"
testRuntime (
"cglib:cglib-nodep:${cglib_version}", // allows mocking of classes (in addition to interfaces)
"org.objenesis:objenesis:${objenesis_version}" // allows mocking of classes without default constructor (together with CGLIB)
)
}
jar {
manifest.attributes
exclude('**/*.java')
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
def generatedSources = ['**/*_Generated.*']
test {
jacoco {
excludes = generatedSources
}
}
jacocoTestReport {
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it, exclude: generatedSources)
})
}
reports {
xml.enabled = true
html.enabled = true
}
}
jacoco {
toolVersion = "${jacoco_version}"
}
build.dependsOn jacocoTestReport
}
task wrapper(type: Wrapper) {
gradleVersion = "${gradle_version}"
}
def publishedProjects = subprojects.findAll { it.path != ':uapi.example' }
task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'
dependsOn(publishedProjects.test)
additionalSourceDirs = files(publishedProjects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(publishedProjects.sourceSets.main.allSource.srcDirs)
classDirectories = files(publishedProjects.sourceSets.main.output)
executionData = files(publishedProjects.jacocoTestReport.executionData)
reports {
html.enabled = true // human readable
xml.enabled = true // required by coveralls
}
doFirst {
executionData = files(executionData.findAll { it.exists() })
}
}
configurations {
codacy
}
dependencies {
codacy group: 'com.codacy', name: 'codacy-coverage-reporter', version: '1.0.7'
}
task uploadCoverageToCodacy(type: JavaExec) {
main = "com.codacy.CodacyCoverageReporter"
classpath = configurations.codacy
args = [
"-l",
"Java",
"-r",
"${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
]
}
def getProjectVersion() {
def release = project.hasProperty("project_release") ? project.project_release.toBoolean() : null
def rcno = project.hasProperty("project_rcno") ? project.project_rcno.toInteger() : null
def prjVer = "${project_version_major}.${project_version_minor}.${project_version_fix}"
if (release) {
return "${prjVer}-release"
} else if (rcno > 0) {
return "${prjVer}-rc${rcno}"
} else {
def timestampFormat = new java.text.SimpleDateFormat('yyyyMMddHHmmss')
timestampFormat.timeZone = TimeZone.getTimeZone("UTC")
def ts = timestampFormat.format(new Date())
return "${prjVer}-${ts}"
}
}
def getMavenRepo() {
if (project.project_release.toBoolean()) {
return 'maven-release'
} else {
return 'maven-snapshot'
}
}