-
Notifications
You must be signed in to change notification settings - Fork 26
/
build.gradle
197 lines (173 loc) · 5.05 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
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:6.3.0"
}
}
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'eclipse'
apply plugin: 'biz.aQute.bnd.builder'
apply plugin: 'signing'
apply plugin: 'checkstyle'
apply from: 'version.gradle'
ext {
gitCommit = getGitCommit()
sonatypeCredentialsAvailable = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')
isReleaseVersion = !isSnapshot
isContinuousIntegrationEnvironment = Boolean.parseBoolean(System.getenv('CI'))
signingRequired = !(isSnapshot || isContinuousIntegrationEnvironment)
sonatypeSnapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
sonatypeStagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
buildDate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new Date())
androidBootClasspath = getAndroidRuntimeJar()
}
group = 'org.igniterealtime.jbosh'
version = shortVersion
if (isSnapshot) {
version += '-SNAPSHOT'
}
description = """\
JBOSH ${version}
XEP-0124: Bidirectional-streams Over Synchronous HTTP (BOSH)
"""
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task testSourcesJar(type: Jar, dependsOn: classes) {
classifier = 'test-sources'
from sourceSets.test.allSource
}
artifacts {
archives sourcesJar
archives javadocJar
archives testSourcesJar
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
artifact testSourcesJar
pom {
name = 'JBOSH'
description = 'XEP-0124: Bidirectional-streams Over Synchronous HTTP (BOSH)'
packaging = 'jar'
url = 'http://www.igniterealtime.org/projects/jbosh/'
scm {
url = 'https://github.com/igniterealtime/jbosh'
connection = 'scm:git:https://github.com/igniterealtime/jbosh.git'
developerConnection = 'scm:git:https://github.com/igniterealtime/jbosh.git'
}
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
developers {
developer {
id = 'flow'
name = 'Florian Schmaus'
email = '[email protected]'
}
}
}
}
}
repositories {
maven {
url isSnapshot ? sonatypeSnapshotUrl : sonatypeStagingUrl
if (sonatypeCredentialsAvailable) {
credentials {
username = sonatypeUsername
password = sonatypePassword
}
}
}
}
}
repositories {
mavenCentral()
maven {
url sonatypeSnapshotUrl
}
}
signing {
useGpgCmd()
required { signingRequired }
sign publishing.publications.mavenJava
}
dependencies {
implementation 'xpp3:xpp3:1.1.4c'
implementation 'org.apache.httpcomponents:httpclient:4.3.3'
testImplementation 'org.xlightweb:xlightweb:2.5'
testImplementation 'junit:junit:4.12'
}
tasks.withType(JavaCompile) {
options.release = 7
// Some systems may not have set their platform default
// converter to 'utf8', but we use unicode in our source
// files. Therefore ensure that javac uses unicode
options.encoding = "utf8"
options.compilerArgs = [
'-Xlint:all',
// Set '-options' because a non-java7 javac will emit a
// warning if source/traget is set to 1.7 and
// bootclasspath is *not* set.
// TODO implement a sound heuristic to determine a java7
// rt.jar on the build host. And if none is found,
// fallback to using a environment variable,
// e.g. JAVA7_HOME. See SMACK-651.
'-Xlint:-options',
'-Werror',
]
}
task compileAndroid(type: JavaCompile) {
source = compileJava.source
classpath = compileJava.classpath
destinationDir = new File(buildDir, 'android')
options.bootstrapClasspath = files(androidBootClasspath)
}
test { dependsOn compileAndroid }
def getGitCommit() {
def dotGit = new File("$projectDir/.git")
if (!dotGit.isDirectory()) return 'non-git build'
def cmd = 'git describe --tags --dirty=+'
def proc = cmd.execute()
def gitCommit = proc.text.trim()
assert !gitCommit.isEmpty()
gitCommit
}
def getAndroidRuntimeJar() {
def androidHome = getAndroidHome()
def androidJar = new File("$androidHome/platforms/android-$smackMinAndroidSdk/android.jar")
if (androidJar.isFile()) {
return androidJar
} else {
throw new Exception("Can't find android.jar for $smackMinAndroidSdk API. Please install corresponding SDK platform package")
}
}
// Currently not used by jbosh
def getAndroidJavadocOffline() {
def androidHome = getAndroidHome()
return androidHome.toString() + "/docs/reference"
}
def getAndroidHome() {
def androidHomeEnv = System.getenv("ANDROID_HOME")
if (androidHomeEnv == null) {
throw new Exception("ANDROID_HOME environment variable is not set")
}
def androidHome = new File(androidHomeEnv)
if (!androidHome.isDirectory()) throw new Exception("Environment variable ANDROID_HOME is not pointing to a directory")
return androidHome
}