-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbuild.gradle
140 lines (114 loc) · 4.3 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
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply from: "$project.rootDir/spotless.gradle"
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
ndkVersion "21.0.6113669"
defaultConfig {
minSdkVersion 24
targetSdkVersion 29
versionCode 14 // This number just needs to increase monotonically after every version change
versionName "2.1.9"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
ndk {
// Building for x86 is for chumps
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
// This is so we build the JNI wrapper
externalNativeBuild {
cmake {
path 'CMakeLists.txt'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
// So we can use Android framework code in unit tests
testOptions {
unitTests.includeAndroidResources = true
}
lintOptions {
disable 'InvalidPackage' // EJML doesn't properly separate out AWT classes into their own package
}
}
repositories {
// Needed for FTCLib
mavenCentral()
maven {
url 'https://maven.0x778.tk'
}
}
configurations {
downloadHeader
downloadSo
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation('org.ftclib.ftclib:core:1.2.0') { // For geometry classes
exclude group: 'org.ejml', module: 'ejml-all'
}
testImplementation 'junit:junit:4.12'
// So we can use Android framework code in unit tests
testImplementation 'androidx.test:core:1.3.0'
testImplementation 'androidx.test.ext:junit:1.1.2'
testImplementation 'androidx.test:runner:1.3.0'
testImplementation 'androidx.test:rules:1.3.0'
def rsVersion = '2.41.1-ftc265' // Change string to bump version
downloadSo 'com.intel.realsense:librealsense:' + rsVersion + '@aar'
implementation 'com.intel.realsense:librealsense:' + rsVersion + '@aar'
downloadHeader 'com.intel.realsense:librealsense:' + rsVersion + '@zip'
}
task extractHeaders(type: Sync) {
dependsOn configurations.downloadHeader
from { configurations.downloadHeader.collect { zipTree(it) } }
into "$projectDir/src/main/cpp/include"
}
task extractSo(type: Sync) {
dependsOn configurations.downloadSo
from { configurations.downloadSo.collect { zipTree(it) } }
include("jni/**")
into "$buildDir/"
}
preBuild.dependsOn(extractHeaders)
preBuild.dependsOn(extractSo)
afterEvaluate {
publishing {
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
groupId = "com.spartronics4915.lib"
artifactId "ftc265"
version = android.defaultConfig.versionName
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.implementation.allDependencies.each {
if (it.group != null && (it.name != null || "unspecified".equals(it.name)) && it.version != null) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
if (it.name == "librealsense") {
// There's no way to programmatically get the dependency classifier so we just check the name
// This is important because otherwise Gradle will try to resolve this dep as a jar
dependencyNode.appendNode('type', 'aar')
}
}
}
}
}
}
}
}