File tree 2 files changed +31
-34
lines changed
integration/kotlinx-coroutines-play-services
2 files changed +31
-34
lines changed Original file line number Diff line number Diff line change
1
+ import org.gradle.api.artifacts.transform.InputArtifact
2
+ import org.gradle.api.artifacts.transform.TransformAction
3
+ import org.gradle.api.artifacts.transform.TransformOutputs
4
+ import org.gradle.api.artifacts.transform.TransformParameters
5
+ import org.gradle.api.file.FileSystemLocation
6
+ import org.gradle.api.provider.Provider
7
+ import java.io.File
8
+ import java.nio.file.Files
9
+ import java.util.zip.ZipEntry
10
+ import java.util.zip.ZipFile
11
+
12
+ @Suppress(" UnstableApiUsage" )
13
+ abstract class UnpackAar : TransformAction <TransformParameters .None > {
14
+ @get:InputArtifact
15
+ abstract val inputArtifact: Provider <FileSystemLocation >
16
+
17
+ override fun transform (outputs : TransformOutputs ) {
18
+ ZipFile (inputArtifact.get().asFile).use { zip ->
19
+ zip.entries().asSequence()
20
+ .filter { ! it.isDirectory }
21
+ .filter { it.name.endsWith(" .jar" ) }
22
+ .forEach { zip.unzip(it, outputs.file(it.name)) }
23
+ }
24
+ }
25
+ }
26
+
27
+ private fun ZipFile.unzip (entry : ZipEntry , output : File ) {
28
+ getInputStream(entry).use {
29
+ Files .copy(it, output.toPath())
30
+ }
31
+ }
Original file line number Diff line number Diff line change 2
2
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3
3
*/
4
4
5
- import org.gradle.api.artifacts.transform.*
6
-
7
- import java.nio.file.Files
8
- import java.util.zip.ZipEntry
9
- import java.util.zip.ZipFile
10
-
11
5
ext. tasks_version = ' 16.0.1'
12
6
13
7
def artifactType = Attribute . of(" artifactType" , String )
@@ -49,31 +43,3 @@ tasks.withType(dokka.getClass()) {
49
43
packageListUrl = projectDir. toPath(). resolve(" package.list" ). toUri(). toURL()
50
44
}
51
45
}
52
-
53
- abstract class UnpackAar implements TransformAction<TransformParameters. None > {
54
- @InputArtifact
55
- abstract Provider<FileSystemLocation > getInputArtifact ()
56
-
57
- @Override
58
- void transform (TransformOutputs outputs ) {
59
- ZipFile zip = new ZipFile (inputArtifact. get(). asFile)
60
- try {
61
- for (entry in zip. entries()) {
62
- if (! entry. isDirectory() && entry. name. endsWith(" .jar" )) {
63
- unzipEntryTo(zip, entry, outputs. file(entry. name))
64
- }
65
- }
66
- } finally {
67
- zip. close()
68
- }
69
- }
70
-
71
- private static void unzipEntryTo (ZipFile zip , ZipEntry entry , File output ) {
72
- InputStream stream = zip. getInputStream(entry)
73
- try {
74
- Files . copy(stream, output. toPath())
75
- } finally {
76
- stream. close()
77
- }
78
- }
79
- }
You can’t perform that action at this time.
0 commit comments