|
1 | 1 | import org.apache.tools.ant.filters.FixCrLfFilter
|
2 |
| -import java.io.PrintStream |
3 | 2 |
|
4 | 3 | plugins {
|
5 | 4 | id("com.android.application")
|
@@ -143,32 +142,11 @@ android.applicationVariants.all {
|
143 | 142 | val outSrcDir = File(buildDir, "generated/source/keydata/$name")
|
144 | 143 | val outSrc = File(outSrcDir, "com/topjohnwu/magisk/signing/KeyData.java")
|
145 | 144 |
|
146 |
| - fun PrintStream.newField(name: String, file: File) { |
147 |
| - println("public static byte[] $name() {") |
148 |
| - print("byte[] buf = {") |
149 |
| - val bytes = file.readBytes() |
150 |
| - print(bytes.joinToString(",") { "(byte)(${it.toInt() and 0xff})" }) |
151 |
| - println("};") |
152 |
| - println("return buf;") |
153 |
| - println("}") |
154 |
| - } |
155 |
| - |
156 | 145 | val genSrcTask = tasks.register("generate${name.capitalize()}KeyData") {
|
157 | 146 | inputs.dir(keysDir)
|
158 | 147 | outputs.file(outSrc)
|
159 | 148 | doLast {
|
160 |
| - outSrc.parentFile.mkdirs() |
161 |
| - PrintStream(outSrc).use { |
162 |
| - it.println("package com.topjohnwu.magisk.signing;") |
163 |
| - it.println("public final class KeyData {") |
164 |
| - |
165 |
| - it.newField("testCert", File(keysDir, "testkey.x509.pem")) |
166 |
| - it.newField("testKey", File(keysDir, "testkey.pk8")) |
167 |
| - it.newField("verityCert", File(keysDir, "verity.x509.pem")) |
168 |
| - it.newField("verityKey", File(keysDir, "verity.pk8")) |
169 |
| - |
170 |
| - it.println("}") |
171 |
| - } |
| 149 | + genKeyData(keysDir, outSrc) |
172 | 150 | }
|
173 | 151 | }
|
174 | 152 | registerJavaGeneratingTask(genSrcTask, outSrcDir)
|
|
0 commit comments