forked from eclipse-archived/concierge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
266 lines (234 loc) · 7.7 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
// Build script for Concierge
// sample usages:
// Cleanup: ./gradlew clean
// Build and run tests: ./gradlew test
// Make complete fresh build: ./gradlew clean build publish assembleDist installDist
// Build and publish to local Maven repo: ./gradlew clean build publishToMavenLocal
buildscript {
repositories {
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
jcenter()
}
dependencies {
classpath "org.akhikhl.wuff:wuff-plugin:0.0.13-SNAPSHOT"
}
}
plugins {
// TODO jhi create p2 repo with this tool?
// see: https://github.com/stempler/bnd-platform
// id 'org.standardout.bnd-platform' version '1.2.0'
// see: https://github.com/akhikhl/wuff-sandbox/tree/master/007_repository
// id: ''
// see: https://github.com/netzwerg/gradle-release-plugin
id 'ch.netzwerg.release' version '1.1.0'
}
// only include in top level project
// apply plugin: 'org.standardout.bnd-platform'
apply plugin: 'org.akhikhl.wuff.eclipse-repository'
apply plugin: 'ch.netzwerg.release'
// global variables
project.ext {
buildQualifier = getBuildQualifier()
buildVersion = getBuildVersion()
}
allprojects {
apply plugin: 'distribution'
group = 'org.eclipse.concierge'
buildQualifier = rootProject.buildQualifier
buildVersion = rootProject.buildVersion
version = rootProject.buildVersion
// create all TARs as tar.gz compressed
tasks.withType(Tar){
compression = Compression.GZIP
extension = 'tar.gz'
}
}
// configure all java projects
// ignore distribution and intermediate projects
configure(subprojects.findAll {! (it.name in ['distribution', 'bundles', 'framework', 'tests']) }) {
apply plugin: 'java'
apply plugin: 'maven-publish'
clean {
delete "bin"
delete "storage"
delete "target"
}
sourceCompatibility = 1.5
targetCompatibility = 1.5
// TODO jhi align directory structure to Maven based one
sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDirs = [ ".", "../../distribution/src/config" ]
include "META-INF/services/**", "META-INF/micro-services", "about.html", "about_files/**"
}
}
test {
java {
srcDir 'test'
}
}
}
compileJava {
// disable warning: bootstrap class path not set in conjunction with -source 1.5
options.compilerArgs << '-Xlint:-options'
// TODO jhi fix warnings, then enable
// options.compilerArgs << '-Xlint:unchecked'
// TODO jhi fix deprecated warnings, then enable
// options.compilerArgs << '-Xlint:deprecation'
}
compileTestJava {
// disable warning: bootstrap class path not set in conjunction with -source 1.5
options.compilerArgs << '-Xlint:-options'
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.+'
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
}
jar {
manifest {
from('META-INF/MANIFEST.MF') {
eachEntry { details ->
if (details.key == 'Bundle-Version') {
details.value = details.value.replace ("qualifier", rootProject.buildQualifier)
// for debugging
// println details.key + "=" + details.value
}
}
}
}
}
// name jar file to given bundle symbolic name and version, NOT to project version
// as project version is for overall packaging
// we maintain the bundle version manually (or using bndtools)
// for debugging
// println ("configure: jar=" + jar)
jar.archiveName = jar.manifest.getEffectiveManifest().getAttributes().get("Bundle-SymbolicName") \
+ "-" + jar.manifest.getEffectiveManifest().getAttributes().get("Bundle-Version") \
+ ".jar"
repositories {
mavenCentral()
}
publishing {
repositories {
maven {
// TODO remove completely
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=467163
// https://repo.eclipse.org/content/repositories/concierge-snapshots/
// https://repo.eclipse.org/content/repositories/concierge-releases/
// println ("project.version=" + project.version)
if(project.version.contains('SNAPSHOT')) {
url "../../distribution/build/repo/maven/snapshots"
} else {
url "../../distribution/build/repo/maven/releases"
}
// println ("url=" + url)
}
}
}
}
project(':framework:org.eclipse.concierge.extension.permission') {
dependencies {
compile project(':framework:org.eclipse.concierge')
}
}
project(':framework:org.eclipse.concierge.profile.javase7') {
dependencies {
compile project(':framework:org.eclipse.concierge')
}
}
project(':bundles:org.eclipse.concierge.service.permission') {
dependencies {
compile project(':framework:org.eclipse.concierge')
}
}
project(':bundles:org.eclipse.concierge.service.packageadmin') {
dependencies {
compile project(':framework:org.eclipse.concierge')
}
}
project(':bundles:org.eclipse.concierge.service.eventadmin') {
dependencies {
compile project(':framework:org.eclipse.concierge')
}
}
project(':bundles:org.eclipse.concierge.service.startlevel') {
dependencies {
compile project(':framework:org.eclipse.concierge')
}
}
project(':bundles:org.eclipse.concierge.service.xmlparser') {
dependencies {
compile project(':framework:org.eclipse.concierge')
}
}
project(':bundles:org.eclipse.concierge.shell') {
dependencies {
compile project(':framework:org.eclipse.concierge')
}
}
// release management
release {
dependsOn distZip // 'distZip' could e.g be used in combination with the 'application' plugin
push = false // 'true' would e.g. be useful when triggering the release task on a CI server
versionSuffix = '.SNAPSHOT' // '.DEV' or '' (empty) could be useful alternatives
// TODO
// versionSuffix = qualifier // '.DEV' or '' (empty) could be useful alternatives
}
// task to create a gradle wrapper with used gradle version
task wrapper(type: Wrapper) {
gradleVersion = '2.8'
jarFile = '.gradle-wrapper/gradle-wrapper.jar'
}
// helper methods
// qualifier can be used to replace in Bundle-Version
// for release versions (RCn, Mn) this is the qualifier
// otherwise use the build time for the final build
def getBuildQualifier() {
String ver = project.version
String q
String now = buildTime()
if(ver.endsWith('.SNAPSHOT')) {
q = ver.substring(ver.indexOf("SNAPSHOT"),ver.length()) + "-" + now
} else if(ver.substring(0, ver.length()-1).endsWith('.RC')) {
// for RC versions: use RCn as qualifier for bundle versions
q = ver.substring(ver.indexOf("RC"),ver.length()) + "-" + now
} else if(ver.substring(0, ver.length()-1).endsWith('.M')) {
// for Milestone versions: use Mn as qualifier for bundle versions
q = ver.substring(ver.indexOf("M"),ver.length()) + "-" + now
} else {
// final build
q = now
}
// for debugging
// println ("getBuildQualifier: " + q)
return q
}
// project.version will be read from version.txt
// must be called as function as not initialized in all phases
// in case of SNAPSHOT the qualifier yet contains the SNAPSHOT prefix
def getBuildVersion() {
String ver = project.version
String buildVersion
if(ver.endsWith('.SNAPSHOT')) {
buildVersion = ver.replace (".SNAPSHOT", "." + rootProject.buildQualifier)
} else {
buildVersion = ver
}
// for debugging
// println ("getBuildVersion: " + buildVersion)
return buildVersion
}
def buildTime() {
def date = new Date()
def formattedDate = date.format('yyyyMMddHHmmss')
// for debugging: add "SSS" to date to get ms
// def formattedDate = date.format('yyyyMMddHHmmssSSS')
// println ("buildTime: " + formattedDate)
return formattedDate
}