forked from OpenLiberty/yoko
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
192 lines (166 loc) · 6.24 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
/* Configure classpath to find 3rd party plugins */
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:4.1.0'
}
}
plugins {
id "biz.aQute.bnd.builder" version "6.3.1" apply false
}
ext {
testCount = 0
successfulTestCount = 0
failedTestCount = 0
skippedTestCount = 0
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
}
/**
* Compute a hash no longer than <code>length</code> for the git repository.
* @param length
* @return the hash as a string
*/
def getGitHash(length) {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', "--short=$length", 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
def testProjects = "osgi util rmi-impl core test".split(" ").collect{s->project(":yoko-" + s)}
def shipProjects = "osgi util spec-corba rmi-spec rmi-impl core".split(" ").collect{s->project(":yoko-" + s)}
/* Standard configuration for each subproject */
subprojects { sp ->
apply plugin: 'java-library'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenLocal()
maven { url "https://repository.apache.org/snapshots" }
maven { url "https://repo.maven.apache.org/maven2" }
}
configurations {
// declare a test library configuration
testLib
testImplementation.extendsFrom testLib
}
// additional configuration for projects that have bnd.bnd files
if (sp.file("bnd.bnd").exists()) {
apply plugin: 'biz.aQute.bnd.builder'
group = 'org.apache.yoko'
// to extend the project with a new property, use project.ext.<new property name>
project.ext.symbolicName = project.name.replaceFirst("^yoko-", project.group.toString() + ".")
version = '1.5.0.' + getGitHash(10)
}
}
/* Standard configuration for subprojects with tests */
configure(testProjects) {
// standardise the test deps here
dependencies {
testLib 'junit:junit:4.12'
testLib 'org.mockito:mockito-core:2.22.0'
testLib 'org.mockito:mockito-junit-jupiter:2.22.0'
testLib "org.hamcrest:hamcrest:2.1"
testLib "org.junit.jupiter:junit-jupiter:5.8.2"
testLib "org.junit.platform:junit-platform-runner:1.8.2"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.8.2"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.8.2"
}
if (JavaVersion.current() < JavaVersion.VERSION_11) {
throw new GradleException("This build must be run with java 11 or higher")
}
// ensure tests run under $buildDir somewhere
test {
useJUnitPlatform()
workingDir = "$buildDir/testWorkingDir"
doFirst {workingDir.mkdirs()}
testLogging {
// set options for log level LIFECYCLE
events "skipped", "failed", "passed", "standardOut"
showExceptions true
exceptionFormat "full"
showCauses true
showStackTraces true
// set options for log level DEBUG and INFO
debug {
events "skipped", "failed", "started", "passed", "standardOut", "standardError"
exceptionFormat "full"
}
info.events = debug.events
info.exceptionFormat = debug.exceptionFormat
afterTest { desc, result ->
def totalTime = result.endTime - result.startTime
println """"Test elapsed time","$desc.name",$totalTime"""
}
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
rootProject.testCount += result.testCount
rootProject.successfulTestCount += result.successfulTestCount
rootProject.failedTestCount += result.failedTestCount
rootProject.skippedTestCount += result.skippedTestCount
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
def totalTime = result.endTime - result.startTime
println """"Suite elapsed time","$desc.name",$totalTime"""
}
}
}
}
/* Standard configuration for subprojects with shippable outputs */
configure(shipProjects) {
apply plugin: 'maven-publish'
publishing {
publications {
maven(MavenPublication) {
artifact jar
pom.withXml {
def rootNode = asNode()
// // specify packaging type as bundle (default is pom)
// def packaging = root.packaging[0] ?:
// root.appendNode('packaging')
// packaging.setValue('bundle')
def depsNode = rootNode.dependencies[0] ?:
rootNode.appendNode('dependencies')
// declare compile scope dependencies in the pom.xml
// as compile dependencies
configurations.implementation.allDependencies.each {
def depNode = depsNode.appendNode('dependency')
depNode.appendNode('groupId', it.group)
depNode.appendNode('artifactId', it.name)
depNode.appendNode('version', it.version)
depNode.appendNode('scope', 'compile')
}
}
}
}
}
jar {
dependsOn "generatePomFileForMavenPublication"
// generate the maven dependency metadata
into("/META-INF/maven/$project.group/$project.name") {
from 'build/publications/maven'
rename "pom-default.xml", "pom.xml"
}
}
publish.dependsOn build
// generated tasks need to be expressed as strings
// because they don't exist yet when these lines are executed
publish.dependsOn "publishMavenPublicationToMavenLocal"
publish.dependsOn "publishToMavenLocal"
}
// Summarise the number of tests
//gradle.buildFinished {
// if (testCount == 0) return
// def output = "FINAL RESULT: ${failedTestCount ? "FAILURE" : "SUCCESS"} (${testCount} tests, ${successfulTestCount} successes, ${failedTestCount} failures, ${skippedTestCount} skipped)"
// def startItem = '| ', endItem = ' |'
// def repeatLength = startItem.length() + output.length() + endItem.length()
// println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
//}