-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
115 lines (85 loc) · 3.57 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
File apktool = project.file(project.property('apktool'))
String apktoolVersion = project.property('apktoolVersion')
File aapt = project.file(project.property('aapt'))
File aapt2 = project.file(project.property('aapt2'))
/*
File apktoolDir = project.layout.buildDirectory.dir('apktool').get().getAsFile()
def unpackApktool = project.tasks.register('unpackApktool', Copy) {
it.doFirst {
project.delete apktoolDir
apktoolDir.mkdir()
}
it.from(project.zipTree(apktool)) { CopySpec spec ->
spec.include "prebuilt/"
}
it.into apktoolDir
}
*/
def packAapt = registerPackAaptTask('packAapt', 'aapt', apktool, aapt)
def packAapt2 = registerPackAaptTask('packAapt2', 'aapt2', apktool, aapt2)
def packAaptAndAapt2 = project.tasks.register('packAaptAndAapt2') {
it.dependsOn packAapt, packAapt2
}
TaskProvider<Jar> registerPackAaptTask(String name, String tool, File apktool, File out) {
return project.tasks.register(name, Jar) {
it.zip64 = true
it.reproducibleFileOrder = true
it.preserveFileTimestamps = false
it.duplicatesStrategy = DuplicatesStrategy.FAIL
//it.entryCompression = ZipEntryCompression.STORED
it.archiveFileName.set out.name
it.destinationDirectory.set project.layout.projectDirectory.dir(out.parent)
it.manifest { Manifest manifest ->
manifest.attributes(
'Apktool-Artifact': tool,
'Apktool-Version': apktoolVersion,
'Created-By': 'dexpatcher-repo-updater',
)
}
//it.dependsOn unpackApktool
//def source = apktoolDir
def source = project.zipTree(apktool)
def modeRegular = 0644
def modeExecutable = 0755
def modeLinux = modeExecutable
def modeMacosx = modeExecutable
def modeWindows = modeExecutable
// Apktool < 2.4.0 Naming Scheme
// 64/32-bit:
copyFile it, source, "prebuilt/${tool}/linux/${tool}", "linux/${tool}", modeLinux
copyFile it, source, "prebuilt/${tool}/macosx/${tool}", "macosx/${tool}", modeMacosx
copyFile it, source, "prebuilt/${tool}/windows/${tool}.exe", "windows/${tool}.exe", modeWindows
// 32-bit:
copyFile it, source, "prebuilt/${tool}/windows/${tool}.exe", "windows/i386/${tool}.exe", modeWindows
// Apktool >= 2.4.0 Naming Scheme
// 64-bit:
copyFile it, source, "prebuilt/linux/${tool}_64", "linux/${tool}", modeLinux
copyFile it, source, "prebuilt/macosx/${tool}_64", "macosx/${tool}", modeMacosx
copyFile it, source, "prebuilt/windows/${tool}_64.exe", "windows/${tool}.exe", modeWindows
// 32-bit:
copyFile it, source, "prebuilt/linux/${tool}", "linux/i386/${tool}", modeLinux
copyFile it, source, "prebuilt/macosx/${tool}", "macosx/i386/${tool}", modeMacosx
copyFile it, source, "prebuilt/windows/${tool}.exe", "windows/i386/${tool}.exe", modeWindows
it.from('aapt-NOTICE') { CopySpec spec ->
spec.eachFile { details ->
details.path = 'NOTICE'
details.mode = modeRegular
}
}
it.doLast {
// Delete archives not bundling any executables.
if (out.length() < 64 * 1024) {
project.delete out
}
}
}
}
def copyFile(def it, def source, def from, def to, def mode) {
it.from(source) { CopySpec spec ->
spec.include from
spec.eachFile { details ->
details.path = to
details.mode = mode
}
}
}