corda/build.gradle
2014-08-28 14:58:35 -06:00

236 lines
4.6 KiB
Groovy

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.4'
}
}
apply plugin: 'native-component'
apply plugin: 'ivy-publish'
apply plugin: 'java'
apply plugin: 'artifactory-publish'
ext {
libDir = "${buildDir}/lib"
}
repositories {
ivy {
name "ivyLocal"
url "${System.env.HOME}/.ivy2/local"
layout 'maven'
}
ivy {
name "jcenter"
if(version.contains("SNAPSHOT")) {
url "http://oss.jfrog.org/artifactory/oss-snapshot-local"
} else {
url "http://oss.jfrog.org/artifactory/oss-release-local"
}
layout 'maven'
}
}
configurations {
create('windows-i386')
create('windows-x86_64')
}
dependencies {
'windows-i386' "com.readytalk:win32:1.0.0-SNAPSHOT"
'windows-x86_64' "com.readytalk:win64:1.0.0-SNAPSHOT"
}
model {
platforms {
if(project.hasProperty("platform") && project.hasProperty("arch")) {
create("${platform}-${arch}") {
operatingSystem "${platform}"
architecture "${arch}"
}
} else {
create("linux-x86_64") {
operatingSystem "linux"
architecture "x86_64"
}
create("linux-i386") {
operatingSystem "linux"
architecture "i386"
}
create("windows-x86_64") {
operatingSystem "windows"
architecture "x86_64"
}
create("windows-i386") {
operatingSystem "windows"
architecture "i386"
}
}
}
tasks {
platforms.each { platform ->
task "build${platform.name}"(type: Exec) {
executable "make"
args "platform=${platform.operatingSystem.name}",
"arch=${platform.architecture.name}"
switch ( platform.name ) {
case "windows-i386":
dependsOn extractWin32
args "win32=${libDir}/tools/win32"
break
case "windows-x86_64":
dependsOn extractWin64
args "win32=${libDir}/tools/win64"
break
}
environment JAVA_HOME: "/usr/local/java"
}
assemble {
dependsOn "build${platform.name}"
}
}
}
}
task extractWin32(type: Copy) {
from {
tarTree(configurations."windows-i386".find { it.name =~ 'win32' })
}
into "${libDir}/tools"
}
task extractWin64(type: Copy) {
from {
tarTree(configurations."windows-x86_64".find { it.name =~ 'win64' })
}
into "${libDir}/tools"
}
tasks.withType(JavaCompile) {
sourceCompatibility = "1.6"
targetCompatibility = "1.6"
options.with {
encoding = "UTF-8"
bootClasspath = sourceSets.main.output.classesDir
}
}
sourceSets {
main {
java {
srcDir 'classpath'
}
resources {
srcDir 'classpath'
}
}
}
javadoc {
title = "Avian v${version} Class Library API"
}
task javadocJar(type: Jar) {
dependsOn javadoc
classifier = 'javadoc'
from {
javadoc.destinationDir
}
}
task install {
dependsOn assemble, publish
}
publishing {
repositories {
add(project.repositories."ivyLocal")
}
publications {
def binSuffix=""
def publishBinSuffix="bin"
ivy(IvyPublication) {
from components.java
artifact(javadocJar)
}
platforms.each { platform ->
create(platform.name, IvyPublication) {
def nativeBuildDir = "${buildDir}/${platform.operatingSystem.name}-${platform.architecture.name}"
if(platform.operatingSystem.name == "windows") {
publishBinSuffix = "exe"
binSuffix = ".${publishBinSuffix}"
}
module "${project.name}-${platform.name}"
artifact("${nativeBuildDir}/avian${binSuffix}") {
name "avian"
type publishBinSuffix
extension publishBinSuffix
}
artifact("${nativeBuildDir}/binaryToObject/binaryToObject") {
name "binaryToObject"
type publishBinSuffix
extension publishBinSuffix
}
artifact("${nativeBuildDir}/libavian.a") {
name "libavian"
type "a"
extension "a"
}
}
}
}
}
artifactoryPublish {
dependsOn assemble
}
artifactory {
contextUrl = "http://oss.jfrog.org"
resolve {
repository {
repoKey = 'libs-releases'
}
}
publish {
repository {
repoKey = 'oss-snapshot-local'
username = System.env.BINTRAY_USER
password = System.env.BINTRAY_API_KEY
ivy {
ivyLayout = "[organisation]/[module]/[revision]/ivy-[revision].xml"
}
}
defaults {
platforms.each {
publications it.name
}
}
}
}
task wrapper(type: Wrapper) {
distributionUrl = 'http://services.gradle.org/distributions/gradle-2.0-bin.zip'
}