-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
141 lines (124 loc) · 4.25 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.11.24'
}
}
plugins {
id 'jvm-component'
id 'java-lang'
id 'cpp'
id 'maven-publish'
id 'org.bven.jniplugin' version '0.0.5'
}
import java.nio.file.*
import com.amazonaws.services.s3.transfer.TransferManager
def aws_bucket='bgorven-hello'
def aws_region=System.env.AWS_DEFAULT_REGION
version = '0.0'
group = 'org.bven'
// Process resources task doesn't get created if there aren't any resources; create a placeholder to ensure that it does.
def placeholder = file('src/main/resources/deleteme')
if (!placeholder.parentFile.exists()) {
placeholder.parentFile.mkdirs()
}
if (!placeholder.exists()) {
placeholder.createNewFile()
}
placeholder.deleteOnExit()
repositories {
maven { url "https://jitpack.io" }
}
model {
platforms {
['windows', 'linux', 'osx', 'freebsd-10', 'solaris'].each { os ->
['x86', 'x64', 'arm'].each { arch ->
"$os-$arch" {
architecture arch
operatingSystem os
}
}
}
}
toolChains {
if (project.hasProperty('vs2015')) {
//https://discuss.gradle.org/t/automatic-detection-of-visual-studio-community-2015-rc-not-working-properly/10309
visualCpp(VisualCpp) {
installDir "C:/Program Files (x86)/Microsoft Visual Studio 14.0"
}
}
}
components {
main(JvmLibrarySpec) {
dependencies {
module 'com.github.bgorven:Loader:0.0.2'
}
}
'native'(JNILibrarySpec) { jniLibSpec ->
library "main"
nativeClass "org.bven.hello.Native"
$.platforms.all {
jniLibSpec.targetPlatform it.name
}
binaries.all {
lib new JNIDependency(project)
if (project.hasProperty('vs2015') && targetPlatform.operatingSystem.windows) {
// https://github.com/couchbase/couchbase-lite-java-native/issues/23
cppCompiler.args "/IC:/Program Files (x86)/Windows Kits/10/Include/10.0.10586.0/ucrt"
def arch = {if (targetPlatform.architecture.name.contains('arm')) {
'arm'
} else if (targetPlatform.architecture.name.contains('64')) {
'x64'
} else {
'x86'
}}()
linker.args "/LIBPATH:C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10586.0/ucrt/${arch}"
}
}
}
}
tasks {
run(JavaExec) {
def compile = $.tasks.compileMainJarMainJava;
def jar = $.tasks.createMainJar;
dependsOn $.tasks.mainJar
classpath compile.classpath
classpath jar.outputs
main = 'org.bven.hello.Native'
}
def hash = 'git rev-parse --short HEAD'.execute().text.trim()
upload(Task) {
dependsOn $.tasks.processMainJarMainResources
doLast {
new TransferManager().uploadDirectory(aws_bucket, hash, project.file('src/main/resources/lib'), true).waitForCompletion()
}
}
if (!project.hasProperty('noDownload')) {
download(Task) {
doLast {
def url = "https://${aws_bucket}.s3-${aws_region}.amazonaws.com"
new XmlSlurper().parse(new URL("${url}?prefix=${hash}/").openStream()).Contents.Key.each { key ->
def dest = project.file('src/main/resources/lib/' + "${key}".replace("${hash}/", ''))
dest.parentFile.mkdirs()
dest.withOutputStream{
it << new URL("${url}/${key}").openStream()
}
}
}
}
processMainJarMainResources {
dependsOn $.tasks.download
}
}
wrapper {
gradleVersion = '3.0-rc-1'
}
}
publishing {
publications {
mavenJava(MavenPublication)
}
}
}