1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-02 06:45:59 +01:00
Smack/build.gradle
Florian Schmaus 2ad517b6dd Add initializer tests and move classpath files
The initializer tests verify that every non-optional initializer, this
includes Providers, is loadable.

Creating files under META-INF is not considered best practice. Smack's
configuration and provider files reside now in classpath directory
qualified by Smack's package namespace.
2014-02-15 22:12:12 +01:00

337 lines
8.5 KiB
Groovy

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')
releasedocsDir = new File(buildDir, 'releasedocs')
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')
ignoreFailures = true
}
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/'
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
}
}
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(':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
}
}
(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
}