mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-19 18:42:06 +01:00
cc026a7e85
Now that Java 8 is released, it's time to raise Smack's source compatibility. Let's also use some of the "new" Java 7 features like "catch multiple".
218 lines
5.5 KiB
Groovy
218 lines
5.5 KiB
Groovy
import org.gradle.plugins.signing.Sign
|
|
|
|
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())
|
|
oneLineDesc = 'An Open Source XMPP (Jabber) client library'
|
|
}
|
|
group = 'org.igniterealtime.smack'
|
|
sourceCompatibility = 1.7
|
|
version = shortVersion
|
|
if (isSnapshot) {
|
|
version += '-SNAPSHOT'
|
|
}
|
|
|
|
ext.sharedManifest = manifest {
|
|
attributes('Implementation-Version': version,
|
|
'Implementation-GitRevision': ext.gitCommit,
|
|
'Bundle-Version': version)
|
|
}
|
|
|
|
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'
|
|
}
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
description = """\
|
|
Smack ${version}
|
|
${oneLineDesc}."""
|
|
|
|
subprojects {
|
|
apply plugin: 'osgi'
|
|
apply plugin: 'signing'
|
|
apply plugin: 'checkstyle'
|
|
|
|
checkstyle {
|
|
configFile = new File(rootConfigDir, 'checkstyle.xml')
|
|
}
|
|
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'
|
|
inceptionYear '2003'
|
|
url 'http://www.igniterealtime.org/projects/smack/'
|
|
|
|
issueManagement {
|
|
system 'JIRA'
|
|
url 'http://issues.igniterealtime.org/browse/SMACK'
|
|
}
|
|
|
|
distributionManagement {
|
|
snapshotRepository {
|
|
id 'smack.snapshot'
|
|
url project.sonatypeSnapshotUrl
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
(subprojects - project(':core'))*.jar {
|
|
manifest {
|
|
attributes('Bundle-SymbolicName': project.group + '-' + appendix,
|
|
'Fragment-Host': project.group)
|
|
from sharedManifest
|
|
}
|
|
}
|
|
|
|
// This is not really beautifully, but it's the only way I found to add
|
|
// the sub-projects description as description element to the POM
|
|
subprojects*.uploadArchives {
|
|
repositories {
|
|
mavenDeployer {
|
|
pom.project {
|
|
description project.description
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|