Smack/build.gradle

391 lines
9.9 KiB
Groovy
Raw Normal View History

2014-02-14 18:13:51 +01:00
allprojects {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
ext {
shortVersion = '4.0.0'
isSnapshot = true
gitCommit = getGitCommit()
javadocAllDir = new File(buildDir, 'javadoc')
documentationDir = new File(projectDir, 'documentation')
2014-02-18 10:51:24 +01:00
releasedocsDir = new File(buildDir, 'releasedocs')
2014-02-14 18:13:51 +01:00
rootConfigDir = new File(rootDir, 'config')
sonatypeCredentialsAvailable = project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')
isReleaseVersion = !isSnapshot
signingRequired = isReleaseVersion
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())
}
group = 'org.igniterealtime.smack'
sourceCompatibility = 1.6
version = shortVersion
if (isSnapshot) {
version += '-SNAPSHOT'
}
ext.sharedManifest = manifest {
attributes('Implementation-Version': version,
'Implementation-GitRevision': ext.gitCommit,
'Bundle-Version': version)
}
}
task javadocAll(type: Javadoc) {
source subprojects.collect {project ->
project.sourceSets.main.allJava }
destinationDir = javadocAllDir
// Might need a classpath
classpath = files(subprojects.collect {project ->
project.sourceSets.main.compileClasspath})
}
import org.apache.tools.ant.filters.ReplaceTokens
task prepareReleasedocs(type: Copy) {
from 'resources/releasedocs'
into releasedocsDir
filter(ReplaceTokens, tokens: [version: version, releasedate: buildDate])
}
task distributionZip(type: Zip, dependsOn: [javadocAll, prepareReleasedocs]) {
classifier buildDate
into ('javadoc') {
from(javadocAllDir)
}
into ('releasedocs') {
from(releasedocsDir)
}
into ('releasedocs/documentation') {
from(documentationDir)
}
}
jar {
// Root project should not create empty jar artifact
enabled = false
}
import org.gradle.plugins.signing.Sign
gradle.taskGraph.whenReady { taskGraph ->
if (signingRequired && taskGraph.allTasks.any { it instanceof Sign }) {
// Use Java 6's console to read from the console (no good for a CI environment)
Console console = System.console()
console.printf '\n\nWe have to sign some things in this build.\n\nPlease enter your signing details.\n\n'
def password = console.readPassword('GnuPG Private Key Password: ')
allprojects { ext.'signing.password' = password }
console.printf '\nThanks.\n\n'
}
}
description = """\
Smack ${version}
An Open Source XMPP (Jabber) client library.
"""
subprojects {
apply plugin: 'osgi'
apply plugin: 'signing'
apply plugin: 'pmd'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
checkstyle {
configFile = new File(rootConfigDir, 'checkstyle.xml')
}
pmd {
ignoreFailures = true
}
findbugs {
ignoreFailures = true
}
repositories {
mavenCentral()
}
tasks.withType(Jar) {
baseName = 'smack'
appendix project.name
}
task sourcesJar(type: Jar, dependsOn: classes) {
appendix project.name
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
appendix project.name
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
uploadArchives {
repositories {
mavenDeployer {
if (signingRequired) {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
}
repository(url: project.sonatypeStagingUrl) {
if (sonatypeCredentialsAvailable) {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
}
snapshotRepository(url: project.sonatypeSnapshotUrl) {
if (sonatypeCredentialsAvailable) {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
}
pom.project {
name 'Smack'
packaging 'jar'
url 'http://www.igniterealtime.org/projects/smack/'
2014-02-18 10:51:24 +01:00
issueManagement {
system 'JIRA'
url 'http://issues.igniterealtime.org/browse/SMACK'
}
distributionManagement {
snapshotRepository {
id 'smack.snapshot'
url project.sonatypeSnapshotUrl
}
}
2014-02-14 18:13:51 +01:00
scm {
url 'https://github.com/igniterealtime/Smack'
connection 'scm:git:https://github.com/igniterealtime/Smack.git'
developerConnection 'scm:git:https://github.com/igniterealtime/Smack.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 'flow@igniterealtime.org'
}
}
}
}
}
}
rootProject.distributionZip {
dependsOn build
from(buildDir) {
include "$libsDirName/**"
}
}
signing {
required { signingRequired }
sign configurations.archives
}
}
project(':core') {
description = """\
Smack core components.
"""
configurations {
compression
dns
}
dependencies {
compile 'xpp3:xpp3:1.1.4c'
testCompile 'junit:junit:4.+'
testCompile 'xmlunit:xmlunit:1.5'
testCompile 'org.powermock:powermock-module-junit4:1.5.+'
testCompile 'org.powermock:powermock-api-mockito:1.5.+'
testCompile 'com.jamesmurty.utils:java-xmlbuilder:0.6+'
}
jar {
manifest {
attributes('Bundle-SymbolicName': project.group)
from sharedManifest
}
}
task compressionJar(type: Jar) {
appendix += '-compression'
dependsOn classes
from sourceSets.main.output
include('org/jivesoftware/smack/compression/**')
}
task dnsJar(type: Jar) {
appendix += '-dns'
dependsOn classes
from sourceSets.main.output
include('org/jivesoftware/smack/util/dns/**')
include('org/jivesoftware/smack/util/DNSUtil.class')
}
artifacts {
compression compressionJar
dns dnsJar
}
task createVersionResource(type: CreateFileTask) {
fileContent = version
outputFile = new File(projectDir, 'src/main/resources/org.jivesoftware.smack/version')
}
compileJava.dependsOn(createVersionResource)
}
class CreateFileTask extends DefaultTask {
@Input
String fileContent
@OutputFile
File outputFile
@TaskAction
def createFile() {
outputFile.text = fileContent
}
2014-02-14 18:13:51 +01:00
}
project(':compression-jzlib') {
description = """\
Compression with jzlib
Allow to compress the XMPP stream with help of jzlib.
"""
dependencies {
compile project(path: ':core', configuration: 'compression')
compile 'com.jcraft:jzlib:1.1.3'
}
}
project(':resolver-dnsjava') {
description = """\
DNS SRV with dnsjava
Use dnsjava for DNS SRV lookups. For platforms that don't provide the
javax.naming API (e.g. Android)
"""
dependencies {
compile project(path: ':core', configuration: 'dns')
compile 'dnsjava:dnsjava:2.1.1'
}
}
project(':resolver-javax') {
description = """\
DNS SRV with Java7
Use javax.naming for DNS SRV lookups. The javax.naming API is availabe in JavaSE
since Java7.
"""
dependencies {
compile project(path: ':core', configuration: 'dns')
}
}
project(':extensions') {
description = """\
Smack extensions.
Classes and methods that implement support for the various XMPP XEPs
(Multi-User Chat, PubSub, ) and other XMPP extensions.
"""
dependencies {
compile project(':core')
testCompile project(':core').sourceSets.test.runtimeClasspath
// Test dependencies (junit, …) are interfered from the sourceSet.test of the core project
// So there is no need to add them explicitly here again
}
}
project(':experimental') {
description = """\
Smack experimental extensions.
Classes and methods for XEPs that are in status 'experimental' or that should
otherwise carefully considered for deployment. The API may change even
between patch versions.
"""
dependencies {
compile project(':core')
compile project(':extensions')
testCompile project(':core').sourceSets.test.runtimeClasspath
// Test dependencies (junit, …) are interfered from the sourceSet.test of the core project
// So there is no need to add them explicitly here again
}
}
project(':legacy') {
description = """\
Smack legacy extensions.
Usually XEPs in the state 'retracted', 'rejected', 'deprecated',
'obsolete' or in a long standing 'deferred' state.
"""
dependencies {
compile project(':core')
compile project(':extensions')
testCompile project(':core').sourceSets.test.runtimeClasspath
// Test dependencies (junit, …) are interfered from the sourceSet.test of the core project
// So there is no need to add them explicitly here again
}
}
2014-02-14 18:13:51 +01:00
project(':debug') {
description = """\
Smack GUI debugger.
Inspect the exchanged XMPP stanzas.
"""
dependencies {
compile project(':core')
testCompile project(':core').sourceSets.test.runtimeClasspath
// Test dependencies (junit, …) are interfered from the sourceSet.test of the core project
// So there is no need to add them explicitly here again
}
}
project(':jingle') {
description = """\
Smack Jingle API.
Warning: This API is beta, outdated and currenlty unmaintained.
"""
dependencies {
compile project(':core')
compile project(':extensions')
compile 'javax.media:jmf:2.1.1e'
compile files('libs/jspeex-0.9.7-jfcom.jar', 'libs/jstun.jar', 'libs/Speex.jar')
testCompile project(':core').sourceSets.test.runtimeClasspath
// Test dependencies (junit, …) are interfered from the sourceSet.test of the core project
// So there is no need to add them explicitly here again
}
}
2014-02-19 20:06:30 +01:00
project(':bosh') {
description = """\
Smack BOSH API.
This API is considered beta quality.
"""
dependencies {
compile project(':core')
compile 'org.igniterealtime.jbosh:jbosh:0.6.0'
}
}
2014-02-14 18:13:51 +01:00
(subprojects - project(':core'))*.jar {
manifest {
attributes('Bundle-SymbolicName': project.group + '-' + appendix,
'Fragment-Host': project.group)
from sharedManifest
}
}
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
}