build.gradle
3.11 KB
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
group = "com.example.speech_to_text_alibaba"
version = "1.0"
buildscript {
repositories {
google()
mavenCentral()
maven() {url 'https://mvnrepo.alibaba-inc.com/api/protocol/1/MAVEN/thirdparty'}
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.0")
}
}
// String mavenLocalPath = project(":speech_to_text_alibaba").mkdir("m2repository").absolutePath
// 定义一个方法, 用于获取当前moudle的dir
def getCurrentProjectDir() {
String result = ""
rootProject.allprojects { project ->
if (project.toString().contains ("speech_to_text_alibaba")) {
if (project.properties.get("identityPath").toString() == ":speech_to_text_alibaba") {
// 这里是flutter的约定, 插件的module名是插件名, :是gradle的约定. project前加:
//可能有朋友会纳闷这个本地的地址具体指向哪里,其实指向的是你插件项目存放的本地路径
// D:\flutter\.pub-cache\git\adhub_plugin-97145c094a41ad698e72896dbe0440842b180918\android\aar
result = project.properties.get("projectDir").toString()
}
}
// if (project.properties.get("identityPath").toString() == ":speech_to_text_alibaba") { // 这里是flutter的约定, 插件的module名是插件名, :是gradle的约定. project前加:
// result = project.properties.get("projectDir").toString()
// }
}
return result
}
rootProject.allprojects {
// 这个闭包是循环所有project, 我们让这个仓库可以被所有module找到
def dir = getCurrentProjectDir()
repositories {
google()
mavenCentral()
maven() {url 'https://mvnrepo.alibaba-inc.com/api/protocol/1/MAVEN/thirdparty'}
maven { // 添加这个指向本地的仓库目录
url "$dir/aar"
}
}
}
apply plugin: "com.android.library"
android {
if (project.android.hasProperty("namespace")) {
namespace = "com.example.speech_to_text_alibaba"
}
compileSdk = 34
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
defaultConfig {
minSdk = 21
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
lintOptions {
abortOnError false
}
repositories {
// flatDir {
// dirs 'libs'
// }
}
dependencies {
testImplementation("junit:junit:4.13.2")
testImplementation("org.mockito:mockito-core:5.0.0")
implementation files('libs/fastjson-1.1.46.android.jar')
implementation "com.pgyer:sdk:3.0.9" // 添加这个, 接着点sync project with gradle file 刷新一下项目就可以了. 是使用api还是implementation根据你的实际情况来看就好了
}
testOptions {
unitTests.all {
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
showStandardStreams = true
}
}
}
}