-
Notifications
You must be signed in to change notification settings - Fork 31
/
build.gradle
176 lines (148 loc) · 4.98 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// Copyright 2017-2020 Fitbit, Inc
// SPDX-License-Identifier: Apache-2.0
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'org.jetbrains.dokka-android'
id 'com.jfrog.artifactory'
id 'maven-publish'
}
def packageName = 'com.fitbit.goldengate.bindings'
apply from: '../gg_lib_android_build.gradle'
android {
defaultConfig {
ndk {
abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
}
externalNativeBuild {
cmake {
ndkVersion project.NDK_VERSION
arguments "-DGG_ENABLE_UNIT_TESTS=FALSE"
}
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
version project.CMAKE_VERSION
}
}
sourceSets {
main {
/* src directory for the xp shared library. Allows navigation to XP source in Android Studio */
jni.srcDirs += '../../../../xp/'
// These two are necessary to point gradle at the .so / .dylib files needed to run the app / unit tests
jniLibs.srcDirs = ['../../../../xp/build/cmake/android/']
test.jniLibs.srcDirs = ['../../../../xp/build/cmake/native/']
}
}
packagingOptions {
pickFirst 'lib/x86_64/libgg.so'
pickFirst 'lib/x86/libgg.so'
pickFirst 'lib/armeabi-v7a/libgg.so'
pickFirst 'lib/arm64-v8a/libgg.so'
}
testOptions {
unitTests.returnDefaultValues = true
}
}
def unixBuildDir = projectDir.absolutePath + '/.externalNativeBuild/cmake/debug/unix/'
task buildNativeXpLibrary(type: Exec) {
workingDir projectDir.absolutePath + '../../../../..' //Root dir of golden-gate project
commandLine 'invoke'
args 'native.build', '-t', 'gg'
}
task makeUnixBuildDir() {
def folder = new File(unixBuildDir)
if (!folder.exists()) {
folder.mkdirs()
}
}
task unixCMake(type: Exec) {
dependsOn buildNativeXpLibrary, makeUnixBuildDir
workingDir unixBuildDir
commandLine 'cmake' //just use native cmake; hopefully it's in everyone's PATH
def ndkDir = android.ndkDirectory
args "../../../../", //get back from unix build dir to GoldenGateBindings dir.
"-DGG_ENABLE_UNIT_TESTS=TRUE",
"-DGG_COVERAGE=TRUE",
"-DANDROID_NDK=${ndkDir}"
}
task unixMake(type: Exec) {
dependsOn unixCMake
workingDir unixBuildDir
commandLine 'make'
}
task unixClean(type: Delete) {
delete unixBuildDir
}
project.afterEvaluate {
if (org.gradle.internal.os.OperatingSystem.current().isUnix()) {
javaPreCompileDebugUnitTest.dependsOn unixMake
externalNativeBuildCleanDebug.dependsOn unixClean
}
//For reasons I don't understand, when this task is run via being included in the GoldenGateHost app,
//It doesn't execute because it's erroneously marked as up-to-date. Hardcoding this here until a better
//solution is found.
generateJsonModelDebug.outputs.upToDateWhen {false}
}
configurations {
ktlint
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation "junit:junit:$JUNIT_VERSION"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$KOTLIN_VERSION"
implementation "androidx.annotation:annotation:$ANDROIDX_APPCOMPAT_VERSION"
implementation "io.reactivex.rxjava2:rxjava:$RXJAVA_VERSION"
implementation "io.reactivex.rxjava2:rxandroid:$RXANDROID_VERSION"
implementation "com.squareup.okhttp3:okhttp:$OK_HTTP"
implementation "com.jakewharton.timber:timber:$TIMBER_VERSION"
ktlint "com.github.shyiko:ktlint:0.14.0"
testImplementation "org.mockito:mockito-core:$MOCKITO_VERSION"
testImplementation "org.mockito.kotlin:mockito-kotlin:$MOCKITO_KOTLIN_VERSION"
testImplementation "org.jetbrains.kotlin:kotlin-test:$KOTLIN_VERSION"
}
task ktlint (type: JavaExec, group: "verification") {
description "Check Kotlin code style"
classpath configurations.ktlint
main "com.github.shyiko.ktlint.Main"
args "src/**/*.kt"
}
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
main = "com.github.shyiko.ktlint.Main"
args "-F", "src/**/*.kt"
}
apply from: '../jacoco.gradle'
dokka {
outputFormat = 'html'
outputDirectory = "$buildDir/javadoc"
reportUndocumented = true
}
task sourceJar(type: Jar) {
from android.sourceSets.main.kotlin.srcDirs
classifier "sources"
}
publishing {
publications {
aar(MavenPublication) {
groupId packageName
version = libraryVersionName
artifactId project.getName()
artifact(sourceJar)
artifact ("$buildDir/outputs/aar/GoldenGateBindings-${publishVariant}.aar")
}
}
}
//For some reason the default clean task doesn't do this
task externalNativeBuildClean(type: Delete) {
delete '.externalNativeBuild/cmake'
}
clean {
dependsOn {
externalNativeBuildClean
}
}
setupPublishDependency(artifactoryPublish)