2013-01-16 23:06:32 +01:00
|
|
|
/**
|
2014-10-24 01:14:48 +02:00
|
|
|
* Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com>
|
2013-01-16 23:06:32 +01:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2021-03-04 13:21:22 +01:00
|
|
|
import proguard.gradle.ProGuardTask
|
|
|
|
|
2017-05-08 14:33:12 +02:00
|
|
|
apply plugin: 'com.github.johnrengelman.shadow'
|
2013-01-16 23:06:32 +01:00
|
|
|
|
2015-05-01 17:26:10 +02:00
|
|
|
dependencies {
|
2020-08-10 14:45:00 +02:00
|
|
|
implementation depends.commons_cli
|
|
|
|
implementation project(':brut.apktool:apktool-lib')
|
2013-01-17 04:51:04 +01:00
|
|
|
}
|
|
|
|
|
2015-05-01 17:26:10 +02:00
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
2020-08-10 15:07:06 +02:00
|
|
|
jcenter()
|
2015-05-01 17:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2020-08-10 15:07:06 +02:00
|
|
|
classpath(depends.proguard_gradle) {
|
|
|
|
exclude group: 'com.android.tools.build'
|
|
|
|
}
|
2015-05-01 17:26:10 +02:00
|
|
|
}
|
2013-01-16 23:06:32 +01:00
|
|
|
}
|
|
|
|
|
2017-05-08 14:33:12 +02:00
|
|
|
jar {
|
2013-01-16 23:06:32 +01:00
|
|
|
manifest {
|
2021-04-13 14:40:19 +02:00
|
|
|
attributes 'Main-Class': 'brut.apktool.Main'
|
2013-01-16 23:06:32 +01:00
|
|
|
}
|
2013-01-17 04:51:04 +01:00
|
|
|
}
|
|
|
|
|
2014-02-09 01:05:57 +01:00
|
|
|
task cleanOutputDirectory(type: Delete) {
|
2019-07-13 14:22:30 +02:00
|
|
|
delete fileTree(dir: jar.getDestinationDirectory().getAsFile(), exclude: "apktool-cli-all.jar")
|
2014-02-09 01:05:57 +01:00
|
|
|
}
|
|
|
|
|
2021-03-04 13:21:22 +01:00
|
|
|
task proguard(type: ProGuardTask, dependsOn: shadowJar) {
|
2019-07-13 14:22:30 +02:00
|
|
|
injars shadowJar.getArchiveFile()
|
2015-05-01 17:26:10 +02:00
|
|
|
|
2019-07-13 13:54:41 +02:00
|
|
|
// Java 9 and prior uses merged package for runtime, later uses split jmod files.
|
2019-07-13 14:37:59 +02:00
|
|
|
if (JavaVersion.current() <= JavaVersion.VERSION_1_8) {
|
2019-10-18 03:03:53 +02:00
|
|
|
libraryjars "${System.properties['java.home']}/lib/jce.jar"
|
2019-07-13 13:54:41 +02:00
|
|
|
libraryjars "${System.properties['java.home']}/lib/rt.jar"
|
|
|
|
} else {
|
2019-07-13 14:37:59 +02:00
|
|
|
libraryjars "${System.properties['java.home']}/jmods/java.base.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
|
2019-10-20 20:23:30 +02:00
|
|
|
libraryjars "${System.properties['java.home']}/jmods/java.compiler.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
|
2019-07-13 14:54:19 +02:00
|
|
|
libraryjars "${System.properties['java.home']}/jmods/java.logging.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
|
|
|
|
libraryjars "${System.properties['java.home']}/jmods/java.xml.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
|
2019-07-13 14:47:16 +02:00
|
|
|
libraryjars "${System.properties['java.home']}/jmods/java.desktop.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
|
|
|
|
libraryjars "${System.properties['java.home']}/jmods/java.sql.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
|
2019-07-13 14:54:19 +02:00
|
|
|
|
|
|
|
libraryjars "${System.properties['java.home']}/jmods/jdk.unsupported.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
|
2019-07-13 13:54:41 +02:00
|
|
|
}
|
2015-05-01 17:26:10 +02:00
|
|
|
|
|
|
|
dontobfuscate
|
|
|
|
dontoptimize
|
|
|
|
|
|
|
|
keep 'public class brut.apktool.Main { public static void main(java.lang.String[]); }'
|
|
|
|
keepclassmembers 'enum * { public static **[] values(); public static ** valueOf(java.lang.String); }'
|
|
|
|
dontwarn 'com.google.common.base.**'
|
|
|
|
dontwarn 'com.google.common.collect.**'
|
|
|
|
dontwarn 'com.google.common.util.**'
|
|
|
|
dontwarn 'javax.xml.xpath.**'
|
|
|
|
dontnote '**'
|
2021-04-13 14:40:19 +02:00
|
|
|
// between Java 1.8 and 1.9, the signature of `flip()` changed, which trips up proguard.
|
|
|
|
dontwarn 'org.yaml.snakeyaml.scanner.ScannerImpl'
|
2019-06-01 16:57:19 +02:00
|
|
|
|
2019-07-13 14:22:30 +02:00
|
|
|
def outPath = jar.getDestinationDirectory().getAsFile().get().toString()
|
|
|
|
def extension = jar.archiveExtension.get().toString()
|
|
|
|
def outFile = outPath + '/' + "apktool" + '-' + project.apktool_version + '-small' + '.' + extension
|
2019-06-01 16:57:19 +02:00
|
|
|
outjars outFile
|
2013-01-17 04:51:04 +01:00
|
|
|
}
|
|
|
|
|
2014-02-09 01:05:57 +01:00
|
|
|
proguard.dependsOn cleanOutputDirectory
|
2021-04-13 14:40:19 +02:00
|
|
|
tasks.getByPath(':release').dependsOn(proguard)
|