forked from StrangeSkies/uk.co.strangeskies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
182 lines (147 loc) · 4.2 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
/*
* Master Gradle build script
*
* Depends on bndPlugin property set by settings.gradle.
* and bnd_* values from gradle.properties.
*/
import aQute.bnd.build.Workspace
import aQute.bnd.osgi.Constants
/* Add bnd gradle plugin as a script dependency */
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath bndPlugin
classpath "gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.13.1"
classpath ("org.ajoberstar:gradle-git:1.2.0") {
/* Resolve dependency conflict with bndtools: */
exclude group: "org.apache.httpcomponents"
}
}
}
plugins {
id 'com.gradle.build-scan' version '1.11'
}
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
}
task wrapper(type: Wrapper) {
jarFile = rootProject.file(".gradle-wrapper/gradle-wrapper.jar")
gradleVersion = "4.6"
}
/* Initialize the bnd workspace */
Workspace.setDriver(Constants.BNDDRIVER_GRADLE)
Workspace.addGestalt(Constants.GESTALT_BATCH, null)
ext.bndWorkspace = new Workspace(rootDir, bnd_cnf).setOffline(gradle.startParameter.offline)
ext.cnf = rootProject.project(bnd_cnf)
/* Configure the subprojects */
def bndProjects() {
return subprojects.findAll {
bndWorkspace.getProject(it.name) != null && new File(it.projectDir, "src").exists()
}
}
configure(bndProjects()) {
plugins.apply "biz.aQute.bnd"
}
/* Test Configuration */
configure(bndProjects()) {
apply plugin: 'jacoco'
repositories {
mavenCentral()
}
test {
jvmArgs = ['-Djdk.attach.allowAttachSelf']
}
jacoco {
toolVersion = "0.8.0"
}
jacocoTestReport {
reports {
xml.enabled true
html.enabled false
}
}
}
/* Source License Generation */
def copyrightProperties = new Properties()
rootProject.file("copyright.properties").withReader("UTF-8") { reader ->
copyrightProperties.load(reader)
}
apply plugin: "license"
configure(bndProjects()) {
apply plugin: "license"
license {
header rootProject.file("LICENSE.TEMPLATE")
strictCheck = true
encoding = "UTF-8"
ext."copyright.work.name" = project.name
ext."copyright.year" = Calendar.getInstance().get(Calendar.YEAR)
ext."copyright.holder.name" = copyrightProperties."copyright.holder.name"
ext."copyright.holder.email" = copyrightProperties."copyright.holder.email"
ext."copyright.holder.logo" = copyrightProperties."copyright.holder.logo"
mapping {
java = "SLASHSTAR_STYLE"
}
}
}
/* Javadoc Generation */
def javadocOptions(options, title) {
configure(options) {
docTitle = title
windowTitle = title
memberLevel = JavadocMemberLevel.PROTECTED
charSet = "UTF-8"
encoding = "UTF-8"
docEncoding = "UTF-8"
links("http://docs.oracle.com/javase/8/docs/api/")
}
}
def javadocExports(project) {
def javadocSpecs = project.bnd("Export-Package", project.name)
return javadocSpecs.split(/\s*,\s*/).collect {
it.replace(".","/")+"/*.java"
}
}
configure(bndProjects()) {
def javadocTitle = bnd("javadoc.title", project.name)
javadoc {
javadocOptions(options, javadocTitle)
javadocExports(project).each { include it }
doFirst {
project.delete(destinationDir)
logger.info "Title : ${options.windowTitle}"
logger.info "Destdir : ${destinationDir}"
}
}
}
task aggregateJavadoc(type: Javadoc) {
javadocOptions(options, project.name)
bndProjects().each {
javadocExports(it).each { include it }
}
source bndProjects().collect { it.sourceSets.main.allJava }
destinationDir = new File(buildDir, "javadoc")
classpath = files(bndProjects().collect {project -> project.sourceSets.main.compileClasspath})
doFirst {
project.delete(destinationDir)
logger.info "Title : ${options.windowTitle}"
logger.info "Destdir : ${destinationDir}"
}
}
/* Javadoc Publish to GH Pages */
apply plugin: "org.ajoberstar.github-pages"
githubPages {
repoUri = "https://github.com/StrangeSkies/uk.co.strangeskies.git"
if (project.hasProperty("githubUser") && project.hasProperty("githubPassword")) {
credentials.setUsername githubUser
credentials.setPassword githubPassword
}
pages {
from aggregateJavadoc
}
}