forked from google/bundletool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
246 lines (215 loc) · 8.42 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.13"
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.1"
}
}
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: "com.google.protobuf"
apply plugin: "java"
apply plugin: "maven-publish"
repositories {
mavenCentral()
google()
}
configurations {
implementationWindows
implementationMacOs
implementationLinux
}
// The repackaging rules are defined in the "shadowJar" task below.
dependencies {
implementation "com.android.tools:common:30.1.0-alpha07"
implementation "com.android.tools:r8:3.3.28"
implementation "com.android.tools.build:apksig:4.2.0-alpha13"
implementation "com.android.tools.ddms:ddmlib:30.1.0-alpha07"
implementation "com.android:zipflinger:7.1.0-alpha07"
shadow "com.android.tools.build:aapt2-proto:7.3.0-alpha07-8248216"
shadow "com.google.auto.value:auto-value-annotations:1.6.2"
annotationProcessor "com.google.auto.value:auto-value:1.6.2"
shadow "com.google.errorprone:error_prone_annotations:2.3.1"
shadow "com.google.guava:guava:30.1-jre"
shadow "com.google.protobuf:protobuf-java:3.10.0"
shadow "com.google.protobuf:protobuf-java-util:3.10.0"
shadow "com.google.dagger:dagger:2.28.3"
annotationProcessor "com.google.dagger:dagger-compiler:2.28.3"
shadow "javax.inject:javax.inject:1"
shadow("org.bitbucket.b_c:jose4j:0.7.0") {
exclude group: "org.slf4j", module: "slf4j-api"
}
shadow "org.slf4j:slf4j-api:1.7.30"
implementationWindows "com.android.tools.build:aapt2:7.3.0-alpha07-8248216:windows"
implementationMacOs "com.android.tools.build:aapt2:7.3.0-alpha07-8248216:osx"
implementationLinux "com.android.tools.build:aapt2:7.3.0-alpha07-8248216:linux"
compileOnly "org.bouncycastle:bcprov-jdk15on:1.56"
compileOnly "org.bouncycastle:bcpkix-jdk15on:1.56"
runtimeOnly "org.slf4j:slf4j-jdk14:1.7.30"
testImplementation "com.android.tools.build:aapt2-proto:7.3.0-alpha07-8248216"
testImplementation "com.google.auto.value:auto-value-annotations:1.6.2"
testAnnotationProcessor "com.google.auto.value:auto-value:1.6.2"
testImplementation "com.google.errorprone:error_prone_annotations:2.3.1"
testImplementation "com.google.guava:guava:30.1-jre"
testImplementation "com.google.truth.extensions:truth-java8-extension:0.45"
testImplementation "com.google.truth.extensions:truth-proto-extension:0.45"
testImplementation "com.google.jimfs:jimfs:1.1"
testImplementation "com.google.protobuf:protobuf-java:3.10.0"
testImplementation "com.google.protobuf:protobuf-java-util:3.10.0"
testImplementation "org.mockito:mockito-core:2.18.3"
testImplementation "junit:junit:4.12"
testImplementation "org.bouncycastle:bcprov-jdk15on:1.56"
testImplementation "org.bouncycastle:bcpkix-jdk15on:1.56"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.2.0"
testImplementation "org.junit.vintage:junit-vintage-engine:5.2.0"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.2.0"
testImplementation "org.junit.platform:junit-platform-runner:1.2.0"
testImplementation "com.google.dagger:dagger:2.28.3"
testAnnotationProcessor "com.google.dagger:dagger-compiler:2.28.3"
testImplementation "javax.inject:javax.inject:1"
testImplementation("org.smali:dexlib2:2.3.4") {
exclude group: "com.google.guava", module: "guava"
}
testImplementation("org.bitbucket.b_c:jose4j:0.7.0") {
exclude group: "org.slf4j", module: "slf4j-api"
}
testImplementation "org.slf4j:slf4j-api:1.7.30"
testRuntimeOnly "org.slf4j:slf4j-jdk14:1.7.30"
}
def osName = System.getProperty("os.name").toLowerCase()
// Use utf-8 instead of the platform default encoding.
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
test {
if (osName.contains("linux")) {
environment "AAPT2_PATH", "build/resources/main/linux/aapt2"
}
if (osName.contains("windows")) {
environment "AAPT2_PATH", 'build/resources/main/windows/aapt2'
}
if (osName.contains("mac")) {
environment "AAPT2_PATH", 'build/resources/main/macos/aapt2'
}
testLogging {
events "passed", "skipped", "failed"
showStandardStreams = true
}
reports {
html.enabled = false
}
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.4.0"
}
}
publishing {
publications {
shadow(MavenPublication) { publication ->
project.shadow.component(publication)
groupId = 'com.android.tools.build'
artifactId = 'bundletool'
version = project.release_version
pom {
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
}
pom.withXml { xml ->
def jose4jDependencyNode = xml.asNode().dependencies.'*'.find {
it.artifactId.text() == 'jose4j'
}
if (jose4jDependencyNode != null) {
def exclusionNode = jose4jDependencyNode
.appendNode('exclusions')
.appendNode('exclusion');
exclusionNode.appendNode('groupId', 'org.slf4j')
exclusionNode.appendNode('artifactId', 'slf4j-api')
}
}
}
}
repositories {
maven {
def localRepo = project.hasProperty('localRepo') ?
project.localRepo : "$buildDir/repo"
url = "file://$localRepo"
}
}
}
// Artifact released to Maven.
shadowJar {
baseName = 'bundletool'
classifier = ''
// Package all the Android Gradle plugin dependencies that are compiled from
// source.
dependencies {
include(dependency('com.android:zipflinger:.*'))
include(dependency {
it.moduleGroup.startsWith('com.android.tools')
})
}
relocate('com.android', 'shadow.bundletool.com.android') {
// BundleTool classes.
exclude 'com.android.tools.build.bundletool.**'
// Bundle protos.
exclude 'com.android.bundle.**'
// Aapt protos.
exclude 'com.android.aapt.**'
// String constants in classes.
// For some reason, the Shadow plug-in seems to rename strings in classes too!
exclude 'com.android.vending.splits'
exclude 'com.android.vending.splits.required'
exclude 'com.android.dynamic.apk.fused.modules'
}
// Exclude ddmlib protos from maven jar
exclude 'app_processes.proto'
exclude 'instrumentation-data.proto'
}
// Artifact to use as standalone command line tool.
task executableJar(type: ShadowJar) {
baseName = 'bundletool'
classifier = 'all'
from sourceSets.main.output
from({ zipTree(project.configurations.implementationWindows.singleFile) }) { into 'windows/' }
from({ zipTree(project.configurations.implementationMacOs.singleFile) }) { into 'macos/' }
from({ zipTree(project.configurations.implementationLinux.singleFile) }) { into 'linux/' }
configurations = [
project.configurations.runtimeClasspath,
project.configurations.shadow
]
manifest {
attributes 'Main-Class': 'com.android.tools.build.bundletool.BundleToolMain'
}
exclude 'META-INF/*.SF'
exclude 'META-INF/*.DSA'
exclude 'META-INF/*.RSA'
}
// Unzip the aapt2 dependency jar.
task unzipAapt2Jar(type: Copy) {
if (osName.contains("linux")) {
from zipTree(project.configurations.implementationLinux.singleFile)
into('build/resources/main/linux')
}
if (osName.contains("windows")) {
from zipTree(project.configurations.implementationWindows.singleFile)
into('build/resources/main/windows')
}
if (osName.contains("mac")) {
from zipTree(project.configurations.implementationMacOs.singleFile)
into('build/resources/main/macos')
}
}
task uploadShadow {
dependsOn ':publishShadowPublicationToMavenRepository'
}
compileTestJava.dependsOn(unzipAapt2Jar)