forked from Kotlin/kotlinx.coroutines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
79 lines (66 loc) · 2.15 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
/*
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
import org.gradle.api.artifacts.transform.*
import java.nio.file.Files
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
ext.tasks_version = '16.0.1'
def artifactType = Attribute.of("artifactType", String)
def unpackedAar = Attribute.of("unpackedAar", Boolean)
configurations.all {
afterEvaluate {
if (canBeResolved) {
attributes.attribute(unpackedAar, true) // request all AARs to be unpacked
}
}
}
dependencies {
attributesSchema {
attribute(unpackedAar)
}
artifactTypes {
aar {
attributes.attribute(unpackedAar, false)
}
}
registerTransform(UnpackAar) {
from.attribute(unpackedAar, false).attribute(artifactType, "aar")
to.attribute(unpackedAar, true).attribute(artifactType, "jar")
}
api("com.google.android.gms:play-services-tasks:$tasks_version") {
exclude group: 'com.android.support'
}
}
tasks.withType(dokka.getClass()) {
externalDocumentationLink {
url = new URL("https://developers.google.com/android/reference/")
// This is workaround for missing package list in Google API
packageListUrl = projectDir.toPath().resolve("package.list").toUri().toURL()
}
}
abstract class UnpackAar implements TransformAction<TransformParameters.None> {
@InputArtifact
abstract Provider<FileSystemLocation> getInputArtifact()
@Override
void transform(TransformOutputs outputs) {
ZipFile zip = new ZipFile(inputArtifact.get().asFile)
try {
for (entry in zip.entries()) {
if (!entry.isDirectory() && entry.name.endsWith(".jar")) {
unzipEntryTo(zip, entry, outputs.file(entry.name))
}
}
} finally {
zip.close()
}
}
private static void unzipEntryTo(ZipFile zip, ZipEntry entry, File output) {
InputStream stream = zip.getInputStream(entry)
try {
Files.copy(stream, output.toPath())
} finally {
stream.close()
}
}
}