1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-29 09:42:06 +01:00
Smack/build.gradle

338 lines
9.2 KiB
Groovy
Raw Normal View History

import org.gradle.plugins.signing.Sign
2014-08-16 00:09:55 +02:00
buildscript {
repositories {
jcenter()
maven { url 'http://dl.bintray.com/content/aalmiray/kordamp' }
}
dependencies {
classpath 'org.kordamp:markdown-gradle-plugin:0.1.1'
}
}
apply plugin: 'org.kordamp.gradle.markdown'
2014-11-04 14:43:41 +01:00
apply from: 'version.gradle'
2014-02-14 18:13:51 +01:00
allprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
ext {
gitCommit = getGitCommit()
javadocAllDir = new File(buildDir, 'javadoc')
2014-08-16 00:09:55 +02:00
documentationDir = new File(buildDir, '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'
// Returns only the date in yyyy-MM-dd format, as otherwise, with
// hh:mm:ss information, the manifest files would change with every
// build, causing unnecessary rebuilds.
2014-08-08 15:08:43 +02:00
builtDate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new Date())
oneLineDesc = 'An Open Source XMPP (Jabber) client library'
2014-11-02 11:24:28 +01:00
jxmppVersion = "0.4.0"
smackMinAndroidSdk = 8
androidProjects = [':smack-tcp',':smack-core', ':smack-resolver-minidns', ':smack-sasl-provided', ':smack-extensions', ':smack-experimental'].collect{ project(it) }
androidBootClasspath = getAndroidRuntimeJar()
androidJavadocOffline = getAndroidJavadocOffline()
2014-02-14 18:13:51 +01:00
}
group = 'org.igniterealtime.smack'
sourceCompatibility = 1.7
targetCompatibility = sourceCompatibility
2014-02-14 18:13:51 +01:00
version = shortVersion
if (isSnapshot) {
version += '-SNAPSHOT'
}
ext.sharedManifest = manifest {
attributes('Implementation-Version': version,
'Implementation-GitRevision': ext.gitCommit,
// According to OSGi core 5.0 section 3.2.5 the qualifier (the fourth
// version element) must begin with a dot. So we replace only the
// first occurence of an dash with a dot.
// For example 4.0.0-rc1 becomes 4.0.0.rc1, but
// 4.0.0-SNAPSHOT-2014-05-01 becomes 4.0.0.SNAPSHOT-2014-05-01
'Bundle-Version': version.replaceFirst("-", "."),
2014-08-08 15:08:43 +02:00
'Built-Date': ext.builtDate,
'Built-JDK': System.getProperty('java.version'),
'Built-Gradle': gradle.gradleVersion,
'Built-By': System.getProperty('user.name')
)
2014-02-14 18:13:51 +01:00
}
eclipse {
classpath {
downloadJavadoc = true
}
}
repositories {
// Add OSS Sonatype Snapshot repository
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
2014-07-25 09:26:26 +02:00
2014-08-19 00:46:59 +02:00
compileJava {
// 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"
}
2014-07-25 09:26:26 +02:00
if (JavaVersion.current().isJava8Compatible()) {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
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'
}
2014-02-14 18:13:51 +01:00
}
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})
options.linkSource = true
options.use = true
options.links = ["http://docs.oracle.com/javase/$sourceCompatibility/docs/api/"] as String[]
2014-02-14 18:13:51 +01:00
}
import org.apache.tools.ant.filters.ReplaceTokens
task prepareReleasedocs(type: Copy) {
from 'resources/releasedocs'
into releasedocsDir
2014-08-08 15:08:43 +02:00
filter(ReplaceTokens, tokens: [version: version, releasedate: builtDate, targetCompatibility: targetCompatibility.toString()])
2014-02-14 18:13:51 +01:00
}
2014-08-16 00:09:55 +02:00
markdownToHtml {
sourceDir = new File(projectDir, "/documentation")
outputDir documentationDir
configuration = [tables: true, fencedCodeBlocks: true]
}
task distributionZip(type: Zip, dependsOn: [javadocAll, prepareReleasedocs, markdownToHtml]) {
2014-08-08 15:08:43 +02:00
classifier builtDate
2014-02-14 18:13:51 +01:00
into ('javadoc') {
from(javadocAllDir)
}
into ('releasedocs') {
from(releasedocsDir)
}
into ('releasedocs/documentation') {
from(documentationDir)
}
}
task maybeCheckForSnapshotDependencies {
// Don't check for Snapshot dependencies if this is a snapshot.
if (isSnapshot) return
allprojects { project ->
project.configurations.runtime.each {
if (it.toString().contains("-SNAPSHOT"))
throw new Exception("Release build contains snapshot dependencies: " + it)
}
}
}
test { dependsOn maybeCheckForSnapshotDependencies }
2014-02-14 18:13:51 +01:00
jar {
// Root project should not create empty jar artifact
enabled = false
}
// Disable upload archives for the root project
uploadArchives.enabled = false
2014-02-14 18:13:51 +01:00
description = """\
Smack ${version}
${oneLineDesc}."""
2014-02-14 18:13:51 +01:00
evaluationDependsOnChildren()
2014-02-14 18:13:51 +01:00
subprojects {
apply plugin: 'maven'
2014-02-14 18:13:51 +01:00
apply plugin: 'osgi'
apply plugin: 'signing'
apply plugin: 'checkstyle'
checkstyle {
configFile = new File(rootConfigDir, 'checkstyle.xml')
}
repositories {
2014-04-17 13:43:25 +02:00
mavenLocal()
2014-02-14 18:13:51 +01:00
mavenCentral()
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
2014-08-12 21:58:04 +02:00
task testJar(type: Jar) {
classifier = 'tests'
from sourceSets.test.output
}
2014-02-14 18:13:51 +01:00
artifacts {
archives sourcesJar
archives javadocJar
2014-08-12 21:58:04 +02:00
archives testJar
2014-02-14 18:13:51 +01:00
}
2014-02-14 18:13:51 +01:00
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)
}
}
2014-02-14 18:13:51 +01:00
pom.project {
name 'Smack'
packaging 'jar'
inceptionYear '2003'
2014-02-14 18:13:51 +01:00
url 'http://www.igniterealtime.org/projects/smack/'
description project.description
2014-02-18 10:51:24 +01:00
issueManagement {
system 'JIRA'
2014-06-22 22:44:00 +02:00
url 'https://igniterealtime.org/issues/browse/SMACK'
2014-02-18 10:51:24 +01:00
}
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/*${version}.jar"
include "$libsDirName/*${version}-javadoc.jar"
include "$libsDirName/*${version}-sources.jar"
2014-02-14 18:13:51 +01:00
}
}
signing {
required { signingRequired }
sign configurations.archives
}
}
['smack-extensions', 'smack-experimental', 'smack-legacy'].each { name ->
project(":$name") {
jar {
manifest {
instruction 'Service-Component', "org.jivesoftware.smackx/$name-components.xml"
}
}
}
}
Add smack-java7 declarative service So that everything is correctly initialized. Otherwise we get an NPE like: 02:55:01 PM SENT (242792115): <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5'>=</auth> 02:55:01 PM RCV (242792115): <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cmVhbG09ImVjLXhtcHAiLG5vbmNlPSJyWWpCYj Znc1I4WUVKZXNZUXV2bXBFQWNoRVVGRGowTnJnUFcxRjFmIixxb3A9ImF1dGgiLGNoYXJzZXQ9dXRmLT gsYWxnb3JpdGhtPW1kNS1zZXNz</challenge> org.jivesoftware.smack.SmackException$NoResponseException at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 247) at org.jivesoftware.smack.tcp.XMPPTCPConnection.login(XMPPTCPConnection.java:374) ... at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.ja va:932) at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.ja va:1) at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183) at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:317) at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261) at com.foobar.mgmt.tree.xmpp.skeleton.impl.activator.Activator.start(Activator.ja va:33) at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextI mpl.java:711) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(Bundl eContextImpl.java:702) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextI mpl.java:683) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java :381) at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.j ava:390) at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java: 1176) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartL evelManager.java:559) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartL evelManager.java:544) at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelMa nager.java:457) at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(Star tLevelManager.java:243) at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartL evelManager.java:438) at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartL evelManager.java:1) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.jav a:230) at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.j ava:340) Sep 18, 2014 2:55:06 PM org.jivesoftware.smack.AbstractXMPPConnection callConnectionClosedOnErrorListener Warnung: Connection closed with error java.lang.NullPointerException at org.jivesoftware.smack.util.stringencoder.Base64.decode(Base64.java:87) at org.jivesoftware.smack.sasl.SASLMechanism.challengeReceived(SASLMechanism.java: 206) at org.jivesoftware.smack.SASLAuthentication.challengeReceived(SASLAuthentication. java:325) at org.jivesoftware.smack.SASLAuthentication.challengeReceived(SASLAuthentication. java:310) at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1105) at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPCon nection.java:969) at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:988) SMACK-343
2014-09-18 15:16:22 +02:00
['smack-resolver-javax', 'smack-resolver-dnsjava', 'smack-resolver-minidns', 'smack-sasl-javax', 'smack-sasl-provided', 'smack-java7'] .each { name ->
project(":$name") {
jar {
manifest {
instruction 'Service-Component', "org.jivesoftware.smack/$name-components.xml"
}
}
}
}
subprojects*.jar {
manifest {
from sharedManifest
}
}
2014-02-14 18:13:51 +01:00
def getGitCommit() {
def dotGit = new File("$projectDir/.git")
if (!dotGit.isDirectory()) return 'non-git build'
2014-07-28 16:12:57 +02:00
def cmd = 'git describe --always --tags --dirty=+'
2014-02-14 18:13:51 +01:00
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")
}
}
def getAndroidJavadocOffline() {
def androidHome = getAndroidHome()
return androidHome.toString() + "/docs/reference"
2014-07-20 12:58:05 +02:00
}
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
2014-07-20 12:58:05 +02:00
}