-
Notifications
You must be signed in to change notification settings - Fork 28
/
zinc_sourceSets.gradle
153 lines (120 loc) · 5.22 KB
/
zinc_sourceSets.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
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.zinc.gradlestudy"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
// 资源合并优先级:
// Variant(helloDebug) > buildType(Debug) > flavor(hello) > (main > aapt -S) > dependencies
sourceSets {
main {
// 定义多个资源目录,如果资源间有重复,则会报错
// res.srcDirs 'src/main/res', 'src/main/zinc-res'
// The Android AIDL source directory for this source set.
// aidl.srcDirs 'src/main/aidl', 'src/main/zincAidl'
// assets.srcDirs 'src/main/assets', 'src/main/zincAssets'
java {
srcDirs = [
'src/main/java',
'src/main/patternFilterableDemo/exclude'
]
// excludes = ['zincStudy/*.java']
// 以属性的方式设置,会覆盖之前设置的值
// includes = ["com/zinc/gradlestudy/MainActivity.java"]
// 以方法的形式,则不会覆盖,而是追加
// include(['src/main/patternFilterableDemo/**/ZincTest.java'])
// 是只读属性
// sourceFiles = [fileTree(dir: 'mine', include: ['**/*.java'])]
// exclude {
// FileTreeElement elem ->
// println "====$elem"
// println "Searching for files, found: " + elem.relativePath
// !(elem.isDirectory() || elem.name.equals('zinc.java'))
// }
}
// The Android JNI source directory for this source set.
// jni.srcDir ''
// The Android JNI libs directory for this source set.
// jniLibs.srcDir()
// The Android Manifest file for this source set.
// manifest.srcFile 'src/main/ZincManifest.xml'
// The Android RenderScript source directory for this source set.
// renderscript.srcDir ''
// The Android Resources directory for this source set.
// res.srcDir ''
// The Java resources which are to be copied into the javaResources output directory.
// resources.srcDir ''
}
// // hello 风味会叠加在 main 上面,而不是替换
// hello {
//// java.srcDir 'src/main/helloJava'
// }
zinc {
// https://developer.android.google.cn/studio/build/gradle-tips
// If all the files for a source set are located under a single root
// directory, you can specify that directory using the setRoot property.
// When gathering sources for the source set, Gradle looks only in locations
// relative to the root directory you specify. For example, after applying
// the configuration below for the androidTest source set, Gradle looks for
// Java sources only in the src/tests/java/ directory.
// 这段话的意思是
// 如果我们的代码都在同一个目录下,可以用setRoot进行设置,
// 设置了 setRoot 之后,gradle的编译只会在同级目录下找资源,
// 例如:只会在 src/zincPower/java 找java代码
// 会忽略 java.srcDirs 设置的路径
setRoot 'src/zincPower'
// 这个会忽略
java.srcDirs 'zzz'
}
// debug.setRoot('build-types/zinc')
// java {
// srcDirs = [
// 'java'
// ]
// }
// }
// zinc{
// setRoot('app/src/build-types/zincApk')
// manifest.srcFile 'AndroidManifest.xml'
//
// println "rootDir: $rootDir"
//// println "root: $root"
// println "rootPorject: $rootProject"
// }
// main.java.getIncludes().each { println "Added include: $it" }
// main.java.getExcludes().each { println "Added exclude: $it" }
// main.java.sourceFiles.each { println "File in source set: " + it }
main.assets.getIncludes().each { println "Added include: $it" }
main.assets.getExcludes().each { println "Added exclude: $it" }
main.assets.sourceFiles.each { println "File in source set: " + it }
}
flavorDimensions('product')
productFlavors {
// hello {
// dimension 'product'
// }
zinc {
dimension 'product'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}