-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
223 lines (203 loc) · 8.33 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
import groovy.json.JsonSlurper
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21' // needed for YuvToRgbConverter
classpath 'de.undercouch:gradle-download-task:5.3.1'
}
}
allprojects {
def jsonFile = file("$rootDir/config.json")
if (!jsonFile.exists()) {
jsonFile = file("$rootDir/config.template.json")
}
def pythonconfig = new JsonSlurper().parseText(jsonFile.text)
if (pythonconfig.CUSTOM) {
ext.ip = pythonconfig.CUSTOM.ip
ext.port = pythonconfig.CUSTOM.port
} else {
ext.ip = pythonconfig.DEFAULT.ip
ext.port = pythonconfig.DEFAULT.port
}
// Check for GITHUB_USER and GITHUB_TOKEN environment variables
if (!System.getenv("GITHUB_USER") || !System.getenv("GITHUB_TOKEN")) {
throw new GradleException("Environment variables GITHUB_USER and GITHUB_TOKEN must be set.")
}
}
subprojects {
group = 'jp.oist'
version = getGitVersion()
println "version = " + getGitVersion()
ext.gitVersion = scmTag()
ext.versionNamespace = 'abcvlib'
ext.versionString = sprintf("%s%s", versionNamespace, version)
repositories {
mavenCentral()
mavenLocal()
maven { url 'https://jitpack.io' }
google()
jcenter()
maven {
url = uri("https://maven.pkg.github.com/topherbuckley/smartphone-robot-flatbuffers")
credentials {
username = System.getenv("GITHUB_USER")
password = System.getenv("GITHUB_TOKEN")
}
}
}
apply plugin: 'maven-publish'
apply plugin: 'signing'
if (gradle.ext.androidLibs.any{name -> name == project.name}){
apply plugin: 'com.android.library'
apply plugin: "kotlin-android" // needed for YuvToRgbConverter
} else if (gradle.ext.apps.any{name -> name == project.name}){
apply plugin: 'com.android.application'
dependencies {
implementation(project(":abcvlib"))
}
}
dependencies {
implementation 'androidx.annotation:annotation:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation "androidx.lifecycle:lifecycle-livedata:2.3.1"
implementation "androidx.lifecycle:lifecycle-viewmodel:2.3.1"
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.activity:activity:1.3.1'
implementation "androidx.fragment:fragment:1.3.6"
implementation "androidx.core:core-ktx:1.6.0"
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
implementation 'org.tensorflow:tensorflow-lite-task-vision:0.4.0'
implementation 'org.tensorflow:tensorflow-lite-gpu-delegate-plugin:0.4.0'
implementation 'org.tensorflow:tensorflow-lite-gpu:2.9.0'
// CameraX core library using the camera2 implementation
implementation "androidx.camera:camera-camera2:1.1.0-alpha07"
// If you want to additionally use the CameraX Lifecycle library
implementation "androidx.camera:camera-lifecycle:1.1.0-alpha07"
// If you want to additionally use the CameraX View class
implementation "androidx.camera:camera-view:1.0.0-alpha27"
// If you want to additionally use the CameraX Extensions library
implementation "androidx.camera:camera-extensions:1.0.0-alpha27"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.21"
implementation "com.google.flatbuffers:flatbuffers-java:1.12.0"
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.zxing:core:3.4.1'
implementation 'com.google.zxing:android-integration:3.3.0'
implementation 'io.github.nishkarsh:android-permissions:2.0.54'
implementation 'com.github.mik3y:usb-serial-for-android:3.6.0'
implementation 'jp.oist.abcvlib.core.learning:fbclasses:0.0.1'
}
android {
namespace 'jp.oist.abcvlib'
compileOptions {
sourceCompatibility(JavaVersion.VERSION_1_8)
targetCompatibility(JavaVersion.VERSION_1_8)
}
defaultConfig {
compileSdkVersion = 30
buildToolsVersion = '30.0.2'
minSdkVersion 30
targetSdkVersion 30
buildConfigField("String", "IP", "\"${ip.toString()}\"")
buildConfigField("int", "PORT", "${port.toString()}")
// Fetch the version according to git latest tag and "how far are we from last tag"
try {
def longVersionName = "git -C ${rootDir} describe --tags --long --dirty".execute().text.trim()
def (fullVersionTag, commitCount, gitSha, dirty) = longVersionName.tokenize('-')
def versionTagWithoutV = fullVersionTag.startsWith('v') ? fullVersionTag.substring(1) : fullVersionTag
def (versionMajor, versionMinor, versionPatch) = versionTagWithoutV.tokenize('.')
// Set the version name
versionName = "$versionMajor.$versionMinor.$versionPatch-$commitCount-$dirty"
// Turn the version name into a version code
versionCode = versionMajor.toInteger() * 100000 +
versionMinor.toInteger() * 10000 +
versionPatch.toInteger() * 1000 +
commitCount.toInteger()
} catch (Exception e) {
// Handle cases where there are no tags or the git command fails
println "Warning: No tags present or failed to fetch version from git. Setting default version. Error: ${e.message}"
// Set a default version name and version code
versionName = "0.0.0-0-unknown"
versionCode = 1
}
}
buildTypes {
release {
minifyEnabled true
}
debug {
minifyEnabled false
}
}
ndkVersion = "21.0.6113669"
}
}
static def getGitVersion() {
try {
def longVersionName = "git describe --tags --long".execute().text.trim()
def (fullVersionTag, commitCount, gitSha, dirty) = longVersionName.tokenize('-')
// Release
if (commitCount.toInteger() == 0) {
return "$fullVersionTag"
}
// Quickfixes
else {
return "$longVersionName"
}
} catch (Exception e) {
println "Warning: Failed to fetch git version. Error: ${e.message}"
return "0.0.0-0-unknown"
}
}
static def scmTag() {
try {
def gitVersion = "$System.env.VERSION"
if (gitVersion.equals("null")) {
def processTag = "git describe --tags --dirty".execute()
def processHash = "git rev-parse HEAD".execute()
gitVersion = processTag.text.toString().trim() + "_" + processHash.text.toString().trim()
} else {
def gitVersionToken = gitVersion.split("/")
if (gitVersionToken.size() > 2)
gitVersion = gitVersionToken[2]
else
gitVersion = gitVersionToken[0]
}
return gitVersion
} catch (Exception e) {
println "Warning: Failed to fetch SCM tag. Error: ${e.message}"
return "0-unknown"
}
}
static def gitHash() {
try {
def processHash = "git rev-parse HEAD".execute()
return processHash.text.toString().trim()
} catch (Exception e) {
println "Warning: Failed to fetch git hash. Error: ${e.message}"
return "unknown"
}
}
static def isDirty() {
try {
def dirtyString = "git describe --tags --dirty".execute().text.trim().tokenize("-")[-1]
return dirtyString.equals("dirty")
} catch (Exception e) {
println "Warning: Failed to determine if repository is dirty. Error: ${e.message}"
return false
}
}
static def isTagged() {
try {
def longVersionName = "git describe --tags --long".execute().text.trim()
def (fullVersionTag, commitCount, gitSha, dirty) = longVersionName.tokenize('-')
return commitCount.toInteger() == 0
} catch (Exception e) {
println "Warning: Failed to determine if repository is tagged. Error: ${e.message}"
return false
}
}