-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
189 lines (153 loc) · 4.44 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
/*
* Master Gradle build script
*
* Depends on bndPlugin property set by settings.gradle.
* and bnd_* values from gradle.properties.
*/
import aQute.bnd.build.Workspace
/* Add bnd gradle plugin as a script dependency */
buildscript {
repositories {
jcenter()
}
dependencies {
classpath bndPlugin
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1'
classpath ('nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0') {
/* Resolve dependency conflict with aether: */
exclude group: 'org.apache.maven'
}
classpath ('org.ajoberstar:gradle-git:1.2.0') {
/* Resolve dependency conflict with bndtools: */
exclude group: 'org.apache.httpcomponents'
}
}
}
task wrapper(type: Wrapper) {
jarFile = rootProject.file('.gradle-wrapper/gradle-wrapper.jar')
gradleVersion = '2.10'
}
/* Initialize the bnd workspace */
ext.bndWorkspace = Workspace.getWorkspace(rootDir, bnd_cnf)
if (bndWorkspace == null) {
throw new GradleException("Unable to load workspace ${rootDir}/${bnd_cnf}")
}
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'
}
/* Source License Generation */
apply plugin: 'license'
configure(bndProjects()) {
apply plugin: 'license'
license {
header rootProject.file('LICENSE')
ext.year = Calendar.getInstance().get(Calendar.YEAR)
ext.name = 'Elias N Vasylenko'
ext.email = '[email protected]'
ext.software = project.name
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.modabi.git'
if (project.hasProperty('githubUser') && project.hasProperty('githubPassword')) {
credentials.setUsername githubUser
credentials.setPassword githubPassword
}
pages {
from aggregateJavadoc
}
}
/* Artifactory Publication */
configure(bndProjects()) {
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
artifactory {
contextUrl = 'https://oss.jfrog.org'
publish {
repository {
repoKey = 'oss-snapshot-local'
maven = true
if (project.hasProperty('jfrogUser') && project.hasProperty('jfrogPassword')) {
username = jfrogUser
password = jfrogPassword
}
}
defaults {
project.bnd.project.getSubBuilders().each {
publications("maven_${it.getBsn()}")
}
}
}
}
artifactoryPublish {
dependsOn jar
properties = ['bintray.package': project.name]
}
publishing {
publications {
bnd.project.getSubBuilders().each {
builder -> "maven_${builder.getBsn()}"(MavenPublication) {
artifactId = builder.getBsn()
version = builder.getProperty('Bundle-Version').replaceAll('.[^.]+$', '-SNAPSHOT')
artifact new File("${buildDir}/${artifactId}.jar")
}
}
}
}
}