-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathbuild.gradle
140 lines (127 loc) · 3.88 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
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.2.0'
// This uses Flatbuffers at 1.9 because the 1.10 version added a feature
// that requires using a newer version of the JDK and at least Android N.
// This has already been fixed at head, but a tagged release is not yet
// available with that fix.
classpath 'com.google.flatbuffers:flatbuffers-java:1.12.0'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
apply plugin: 'com.android.library'
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
compileSdkVersion 34
defaultConfig {
minSdkVersion 23
}
sourceSets {
main {
manifest.srcFile '../src/android/java/LibraryManifest.xml'
java {
srcDirs = ['../src/android/java/com/google/firebase/messaging',
"$buildDir/flatbuffer_generated"]
}
}
}
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:33.1.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.flatbuffers:flatbuffers-java:1.12.0'
}
afterEvaluate {
generateReleaseBuildConfig.enabled = false
// Define a Task that will add a Flatbuffers dependency, downloading
// the source from GitHub if needed.
task generateFlatbufferFiles {
// Locate or download flatbuffers.
def flatbuffersDir = "$buildDir/flatbuffers"
def flatbuffersFolder = new File(flatbuffersDir)
if (!flatbuffersFolder.exists()) {
exec {
executable 'git'
args 'clone',
'--branch',
'v1.12.0',
'--depth',
'1',
'https://github.com/google/flatbuffers.git',
flatbuffersDir
}
exec {
executable 'git'
args 'apply',
'../../scripts/git/patches/flatbuffers/0001-remove-unused-var.patch',
'--verbose',
'--directory',
'messaging/messaging_java/build/flatbuffers'
}
}
// Locate or build flatc.
String flatcDirPath = "$flatbuffersDir/flatc_build"
def flatcDir = new File(flatcDirPath)
flatcDir.mkdir()
String flatcExecDirPath = flatcDirPath
String flatcFilename = "flatc"
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
flatcFilename += ".exe"
flatcExecDirPath = "$flatcDirPath/Debug"
}
def flatcExecDir = new File(flatcExecDirPath)
def flatcExec = new File(flatcExecDir, flatcFilename)
if (!flatcExec.exists()) {
exec {
executable 'cmake'
args '..'
workingDir "${flatcDir.getPath()}"
}
exec {
executable 'cmake'
args '--build',
'.',
'--target',
'flatc'
workingDir "${flatcDir.getPath()}"
}
}
// Generate the java files from the schema files.
def schemaFile = new File("../src/android/schemas/messaging.fbs")
exec {
executable "${flatcExec.getPath()}"
args '--java',
'-o',
"$buildDir/flatbuffer_generated",
"${schemaFile.getPath()}"
}
}
preBuild.dependsOn generateFlatbufferFiles
}