mirror of
https://github.com/iBotPeaches/Apktool.git
synced 2024-11-23 04:30:04 +00:00
Migrate to Gradle Kotlin DSL (#3249)
* feat: initial migration to kotlin * feat: initial migration to kotlin * fix: wire up dependencies * fix: Deprecated tag for kotlin detection * refactor: put all modules into sub-projects * fix: include jar file (android framework) * fix: add version message/info * fix: wire up version/gitrev to properties * fix: wire up proguard on cli * fix: wire up proguard * fix: wire up output cleaning command * fix: drop license header on gradle files - fully rewritten from scratch by myself - no longer including license header on build files * fix: add compile utf8/flags for java8 * refactor: remove unneeded curly braces * feat: progress towards maven-publish * build: publish to maven * docs: update documentation * refactor: prevent implicit order by removal of afterEvaluate * build: remove unused license plugin
This commit is contained in:
parent
0a354a9d97
commit
342ff67a4c
17
INTERNAL.md
17
INTERNAL.md
@ -4,17 +4,7 @@ The steps taken for slicing an official release of Apktool.
|
|||||||
|
|
||||||
### Ensuring proper license headers
|
### Ensuring proper license headers
|
||||||
|
|
||||||
Before we build a release, its a good practice to ensure all headers in source files contain
|
_Currently broken after movement to kotlin dsl._
|
||||||
proper licenses.
|
|
||||||
|
|
||||||
./gradlew licenseMain && ./gradlew licenseTest
|
|
||||||
|
|
||||||
If any license violations were found you can automatically fix them with either
|
|
||||||
|
|
||||||
./gradlew licenseFormatMain
|
|
||||||
./gradlew licenseFormatTest
|
|
||||||
|
|
||||||
Like described, one formats the `src/main` directory, while the other formats the `src/test` directory.
|
|
||||||
|
|
||||||
### Tagging the release.
|
### Tagging the release.
|
||||||
|
|
||||||
@ -56,12 +46,12 @@ ossrhUsername={sonatypeUsername}
|
|||||||
ossrhPassword={sonatypePassword}
|
ossrhPassword={sonatypePassword}
|
||||||
```
|
```
|
||||||
|
|
||||||
If `release` or `snapshot` is used publishing will be automatically attempted.
|
Release with maven with `./gradlew build shadowJar release publish`.
|
||||||
|
|
||||||
### Building the binary.
|
### Building the binary.
|
||||||
|
|
||||||
In order to maintain a clean slate. Run `gradlew clean` to start from a clean slate. Now lets build
|
In order to maintain a clean slate. Run `gradlew clean` to start from a clean slate. Now lets build
|
||||||
the new version. We should not have any new commits since the tagged commit.
|
the new binary version. We should not have any new commits since the tagged commit.
|
||||||
|
|
||||||
./gradlew build shadowJar proguard release
|
./gradlew build shadowJar proguard release
|
||||||
|
|
||||||
@ -151,7 +141,6 @@ except for containing sha256 hashes.
|
|||||||
|
|
||||||
The hashes match so we are good with the backup server.
|
The hashes match so we are good with the backup server.
|
||||||
|
|
||||||
|
|
||||||
#### Sonatype
|
#### Sonatype
|
||||||
|
|
||||||
You'll want to log in and view the Staging repositories and confirm you see the recently made build. You'll want to:
|
You'll want to log in and view the Staging repositories and confirm you see the recently made build. You'll want to:
|
||||||
|
@ -1,100 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* https://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.
|
|
||||||
*/
|
|
||||||
import proguard.gradle.ProGuardTask
|
|
||||||
|
|
||||||
buildscript {
|
|
||||||
dependencies {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
gradlePluginPortal()
|
|
||||||
}
|
|
||||||
|
|
||||||
classpath(depends.proguard_gradle) {
|
|
||||||
exclude group: 'com.android.tools.build'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id 'com.github.johnrengelman.shadow'
|
|
||||||
id 'application'
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation depends.commons_cli
|
|
||||||
implementation project(':brut.apktool:apktool-lib')
|
|
||||||
}
|
|
||||||
|
|
||||||
application {
|
|
||||||
mainClass = 'brut.apktool.Main'
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.named('run') {
|
|
||||||
// run from root directory
|
|
||||||
// otherwise run from brut.apktool/apktool-cli
|
|
||||||
workingDir = file(System.getProperty('user.dir'))
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
|
||||||
manifest {
|
|
||||||
attributes 'Main-Class': 'brut.apktool.Main'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register('cleanOutputDirectory', Delete) {
|
|
||||||
delete fileTree(dir: jar.getDestinationDirectory().getAsFile(), exclude: "apktool-cli-all.jar")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register('proguard', ProGuardTask) {
|
|
||||||
dependsOn shadowJar
|
|
||||||
injars shadowJar.getArchiveFile()
|
|
||||||
|
|
||||||
// Java 9 and prior uses merged package for runtime, later uses split jmod files.
|
|
||||||
if (JavaVersion.current() <= JavaVersion.VERSION_1_8) {
|
|
||||||
libraryjars "${System.properties['java.home']}/lib/jce.jar"
|
|
||||||
libraryjars "${System.properties['java.home']}/lib/rt.jar"
|
|
||||||
} else {
|
|
||||||
libraryjars "${System.properties['java.home']}/jmods/java.base.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
|
|
||||||
libraryjars "${System.properties['java.home']}/jmods/java.compiler.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
|
|
||||||
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'
|
|
||||||
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'
|
|
||||||
libraryjars "${System.properties['java.home']}/jmods/java.scripting.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
|
|
||||||
|
|
||||||
libraryjars "${System.properties['java.home']}/jmods/jdk.unsupported.jmod", jarfilter: '!**.jar', filter: '!module-info.class'
|
|
||||||
}
|
|
||||||
|
|
||||||
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 '**'
|
|
||||||
// between Java 1.8 and 1.9, the signature of `flip()` changed, which trips up proguard.
|
|
||||||
|
|
||||||
def outPath = jar.getDestinationDirectory().getAsFile().get().toString()
|
|
||||||
def extension = jar.archiveExtension.get().toString()
|
|
||||||
def outFile = outPath + '/' + "apktool" + '-' + project.apktool_version + '-small' + '.' + extension
|
|
||||||
outjars outFile
|
|
||||||
}
|
|
||||||
|
|
||||||
proguard.dependsOn cleanOutputDirectory
|
|
||||||
tasks.getByPath(':release').dependsOn(proguard)
|
|
74
brut.apktool/apktool-cli/build.gradle.kts
Normal file
74
brut.apktool/apktool-cli/build.gradle.kts
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
import proguard.gradle.ProGuardTask
|
||||||
|
|
||||||
|
val commonsCliVersion: String by rootProject.extra
|
||||||
|
val apktoolVersion: String by rootProject.extra
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("com.github.johnrengelman.shadow")
|
||||||
|
application
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buildscript is deprecated, but the alternative approach does not support expanded properties
|
||||||
|
// https://github.com/gradle/gradle/issues/9830
|
||||||
|
// So we must hard-code the version here.
|
||||||
|
buildscript {
|
||||||
|
dependencies {
|
||||||
|
// Proguard doesn't support plugin DSL - https://github.com/Guardsquare/proguard/issues/225
|
||||||
|
classpath("com.guardsquare:proguard-gradle:7.3.2")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("commons-cli:commons-cli:$commonsCliVersion")
|
||||||
|
implementation(project(":brut.apktool:apktool-lib"))
|
||||||
|
}
|
||||||
|
|
||||||
|
application {
|
||||||
|
mainClass.set("brut.apktool.Main")
|
||||||
|
|
||||||
|
tasks.run.get().workingDir = file(System.getProperty("user.dir"))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Jar> {
|
||||||
|
manifest {
|
||||||
|
attributes["Main-Class"] = "brut.apktool.Main"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register<Delete>("cleanOutputDirectory") {
|
||||||
|
delete(fileTree("build/libs") {
|
||||||
|
exclude("apktool-cli-all.jar")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register<ProGuardTask>("proguard") {
|
||||||
|
dependsOn("cleanOutputDirectory")
|
||||||
|
dependsOn("shadowJar")
|
||||||
|
injars(tasks.named("shadowJar").get().outputs.files)
|
||||||
|
|
||||||
|
val javaHome = System.getProperty("java.home")
|
||||||
|
if (JavaVersion.current() <= JavaVersion.VERSION_1_8) {
|
||||||
|
libraryjars("$javaHome/lib/jce.jar")
|
||||||
|
libraryjars("$javaHome/lib/rt.jar")
|
||||||
|
} else {
|
||||||
|
libraryjars(mapOf("jarfilter" to "!**.jar", "filter" to "!module-info.class"),
|
||||||
|
{
|
||||||
|
"$javaHome/jmods/"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
dontobfuscate()
|
||||||
|
dontoptimize()
|
||||||
|
|
||||||
|
keep("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("**")
|
||||||
|
|
||||||
|
val outPath = "build/libs/apktool-cli-$apktoolVersion.jar"
|
||||||
|
outjars(outPath)
|
||||||
|
}
|
@ -553,7 +553,7 @@ public class Main {
|
|||||||
|
|
||||||
// print out license info prior to formatter.
|
// print out license info prior to formatter.
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"Apktool v" + ApktoolProperties.getVersion() + " - a tool for reengineering Android apk files\n" +
|
"Apktool " + ApktoolProperties.getVersion() + " - a tool for reengineering Android apk files\n" +
|
||||||
"with smali v" + ApktoolProperties.get("smaliVersion") +
|
"with smali v" + ApktoolProperties.get("smaliVersion") +
|
||||||
" and baksmali v" + ApktoolProperties.get("baksmaliVersion") + "\n" +
|
" and baksmali v" + ApktoolProperties.get("baksmaliVersion") + "\n" +
|
||||||
"Copyright 2010 Ryszard Wiśniewski <brut.alll@gmail.com>\n" +
|
"Copyright 2010 Ryszard Wiśniewski <brut.alll@gmail.com>\n" +
|
||||||
@ -577,9 +577,8 @@ public class Main {
|
|||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
// print out more information
|
// print out more information
|
||||||
System.out.println(
|
System.out.println("For additional info, see: https://apktool.org \n"
|
||||||
"For additional info, see: https://apktool.org/ \n"
|
+ "For smali/baksmali info, see: https://github.com/google/smali");
|
||||||
+ "For smali/baksmali info, see: https://github.com/google/smali");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setupLogging(final Verbosity verbosity) {
|
private static void setupLogging(final Verbosity verbosity) {
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* https://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.
|
|
||||||
*/
|
|
||||||
import org.apache.tools.ant.filters.*
|
|
||||||
|
|
||||||
apply plugin: 'java-library'
|
|
||||||
|
|
||||||
processResources {
|
|
||||||
from('src/main/resources/properties') {
|
|
||||||
include '**/*.properties'
|
|
||||||
into 'properties'
|
|
||||||
filter(ReplaceTokens, tokens: [version: project.apktool_version, gitrev: project.hash] )
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
}
|
|
||||||
from('src/main/resources/') {
|
|
||||||
include '**/*.jar'
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
}
|
|
||||||
|
|
||||||
includeEmptyDirs = false
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
api project(':brut.j.dir')
|
|
||||||
api project(':brut.j.util')
|
|
||||||
api project(':brut.j.common')
|
|
||||||
|
|
||||||
implementation depends.baksmali
|
|
||||||
implementation depends.smali
|
|
||||||
implementation depends.xmlpull
|
|
||||||
implementation depends.guava
|
|
||||||
implementation depends.commons_lang
|
|
||||||
implementation depends.commons_io
|
|
||||||
implementation depends.commons_text
|
|
||||||
|
|
||||||
testImplementation depends.junit
|
|
||||||
testImplementation depends.xmlunit
|
|
||||||
}
|
|
52
brut.apktool/apktool-lib/build.gradle.kts
Normal file
52
brut.apktool/apktool-lib/build.gradle.kts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
val baksmaliVersion: String by rootProject.extra
|
||||||
|
val smaliVersion: String by rootProject.extra
|
||||||
|
val xmlpullVersion: String by rootProject.extra
|
||||||
|
val guavaVersion: String by rootProject.extra
|
||||||
|
val commonsLangVersion: String by rootProject.extra
|
||||||
|
val commonsIoVersion: String by rootProject.extra
|
||||||
|
val commonsTextVersion: String by rootProject.extra
|
||||||
|
val junitVersion: String by rootProject.extra
|
||||||
|
val xmlunitVersion: String by rootProject.extra
|
||||||
|
|
||||||
|
val gitRevision: String by rootProject.extra
|
||||||
|
val apktoolVersion: String by rootProject.extra
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
processResources {
|
||||||
|
from("src/main/resources/properties") {
|
||||||
|
include("**/*.properties")
|
||||||
|
into("properties")
|
||||||
|
expand("version" to apktoolVersion, "gitrev" to gitRevision)
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||||
|
}
|
||||||
|
from("src/main/resources") {
|
||||||
|
include("**/*.jar")
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||||
|
}
|
||||||
|
includeEmptyDirs = false
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
// https://github.com/iBotPeaches/Apktool/issues/3174 - CVE-2023-22036
|
||||||
|
// Increases validation of extra field of zip header. Some older Android applications
|
||||||
|
// used this field to store data violating the zip specification.
|
||||||
|
systemProperty("jdk.util.zip.disableZip64ExtraFieldValidation", true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api(project(":brut.j.dir"))
|
||||||
|
api(project(":brut.j.util"))
|
||||||
|
api(project(":brut.j.common"))
|
||||||
|
|
||||||
|
implementation("com.android.tools.smali:smali-baksmali:$baksmaliVersion")
|
||||||
|
implementation("com.android.tools.smali:smali:$smaliVersion")
|
||||||
|
implementation("xpp3:xpp3:$xmlpullVersion")
|
||||||
|
implementation("com.google.guava:guava:$guavaVersion")
|
||||||
|
implementation("org.apache.commons:commons-lang3:$commonsLangVersion")
|
||||||
|
implementation("commons-io:commons-io:$commonsIoVersion")
|
||||||
|
implementation("org.apache.commons:commons-text:$commonsTextVersion")
|
||||||
|
|
||||||
|
testImplementation("junit:junit:$junitVersion")
|
||||||
|
testImplementation("org.xmlunit:xmlunit-legacy:$xmlunitVersion")
|
||||||
|
}
|
@ -42,7 +42,7 @@ public class ApkInfo implements YamlSerializable {
|
|||||||
public Map<String, String> unknownFiles = new LinkedHashMap<>();
|
public Map<String, String> unknownFiles = new LinkedHashMap<>();
|
||||||
public List<String> doNotCompress;
|
public List<String> doNotCompress;
|
||||||
|
|
||||||
/** @deprecated use {@link #resourcesAreCompressed} */
|
/** @Deprecated use {@link #resourcesAreCompressed} */
|
||||||
public boolean compressionType;
|
public boolean compressionType;
|
||||||
|
|
||||||
public ApkInfo() {
|
public ApkInfo() {
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
application.version=@version@
|
application.version=${version}
|
||||||
git.commit.id.abbrev=@gitrev@
|
git.commit.id.abbrev=${gitrev}
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* https://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.
|
|
||||||
*/
|
|
0
brut.j.common/build.gradle.kts
Normal file
0
brut.j.common/build.gradle.kts
Normal file
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* https://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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation project(':brut.j.common')
|
|
||||||
implementation project(':brut.j.util')
|
|
||||||
implementation depends.commons_io
|
|
||||||
}
|
|
7
brut.j.dir/build.gradle.kts
Normal file
7
brut.j.dir/build.gradle.kts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
val commonsIoVersion: String by rootProject.extra
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(project(":brut.j.common"))
|
||||||
|
implementation(project(":brut.j.util"))
|
||||||
|
implementation("commons-io:commons-io:$commonsIoVersion")
|
||||||
|
}
|
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* https://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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation project(':brut.j.common')
|
|
||||||
implementation depends.commons_io
|
|
||||||
implementation depends.guava
|
|
||||||
}
|
|
8
brut.j.util/build.gradle.kts
Normal file
8
brut.j.util/build.gradle.kts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
val commonsIoVersion: String by rootProject.extra
|
||||||
|
val guavaVersion: String by rootProject.extra
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(project(":brut.j.common"))
|
||||||
|
implementation("commons-io:commons-io:$commonsIoVersion")
|
||||||
|
implementation("com.google.guava:guava:$guavaVersion")
|
||||||
|
}
|
235
build.gradle
235
build.gradle
@ -1,235 +0,0 @@
|
|||||||
import java.nio.charset.StandardCharsets
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* https://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.
|
|
||||||
*/
|
|
||||||
buildscript {
|
|
||||||
ext {
|
|
||||||
depends = [
|
|
||||||
baksmali : 'com.android.tools.smali:smali-baksmali:3.0.3',
|
|
||||||
commons_cli : 'commons-cli:commons-cli:1.5.0',
|
|
||||||
commons_io : 'commons-io:commons-io:2.13.0',
|
|
||||||
commons_lang : 'org.apache.commons:commons-lang3:3.13.0',
|
|
||||||
commons_text : 'org.apache.commons:commons-text:1.10.0',
|
|
||||||
guava : 'com.google.guava:guava:32.0.1-jre',
|
|
||||||
junit : 'junit:junit:4.13.2',
|
|
||||||
proguard_gradle: 'com.guardsquare:proguard-gradle:7.3.2',
|
|
||||||
smali : 'com.android.tools.smali:smali:3.0.3',
|
|
||||||
xmlpull : 'xpp3:xpp3:1.1.4c',
|
|
||||||
xmlunit : 'org.xmlunit:xmlunit-legacy:2.9.1',
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
gradlePluginPortal()
|
|
||||||
google()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath "gradle.plugin.com.github.johnrengelman:shadow:8.0.0"
|
|
||||||
classpath "gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:0.16.1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply from: 'gradle/functions.gradle'
|
|
||||||
|
|
||||||
version = '2.8.2'
|
|
||||||
def suffix = 'SNAPSHOT'
|
|
||||||
|
|
||||||
defaultTasks 'build', 'shadowJar', 'proguard'
|
|
||||||
|
|
||||||
allprojects {
|
|
||||||
apply plugin: 'java'
|
|
||||||
apply plugin: 'com.github.hierynomus.license'
|
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
|
|
||||||
license {
|
|
||||||
header rootProject.file("brut.j.common/src/templates/apache2.0-header.txt")
|
|
||||||
exclude "**/android/content/res/*.java"
|
|
||||||
exclude "**/android/util/*.java"
|
|
||||||
include "**/*.java"
|
|
||||||
mapping {
|
|
||||||
java = 'SLASHSTAR_STYLE'
|
|
||||||
}
|
|
||||||
ext {
|
|
||||||
year = '2010'
|
|
||||||
brut = 'Ryszard Wiśniewski'
|
|
||||||
brutEmail = 'brut.alll@gmail.com'
|
|
||||||
ibot = 'Connor Tumbleson'
|
|
||||||
ibotEmail = 'connor.tumbleson@gmail.com'
|
|
||||||
}
|
|
||||||
strictCheck true
|
|
||||||
}
|
|
||||||
|
|
||||||
// license plugin automatically fires these tasks, disable them and run them during releases
|
|
||||||
gradle.startParameter.excludedTaskNames += [
|
|
||||||
"licenseMain",
|
|
||||||
"licenseTest"
|
|
||||||
]
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
google()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
|
||||||
options.encoding = StandardCharsets.UTF_8.toString()
|
|
||||||
options.compilerArgs += ["-Xlint:-options"]
|
|
||||||
}
|
|
||||||
|
|
||||||
def mavenVersion = 'unspecified'
|
|
||||||
if (!('release' in gradle.startParameter.taskNames)) {
|
|
||||||
def hash = getCheckedOutGitCommitHash()
|
|
||||||
|
|
||||||
if (hash == null) {
|
|
||||||
project.ext.set("hash", "dirty")
|
|
||||||
project.ext.set("apktool_version", version + "-dirty")
|
|
||||||
println "Building SNAPSHOT (no .git folder found)"
|
|
||||||
} else {
|
|
||||||
project.ext.set("hash", hash)
|
|
||||||
project.ext.set("apktool_version", version + "-" + hash + "-SNAPSHOT")
|
|
||||||
mavenVersion = version + "-SNAPSHOT"
|
|
||||||
println "Building SNAPSHOT (${getCheckedOutBranch()}): $hash"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
project.ext.set("hash", "")
|
|
||||||
if (suffix.length() > 0) {
|
|
||||||
project.ext.set("apktool_version", version + "-" + suffix)
|
|
||||||
} else {
|
|
||||||
project.ext.set("apktool_version", version)
|
|
||||||
}
|
|
||||||
mavenVersion = version
|
|
||||||
println "Building RELEASE (${getCheckedOutBranch()}): $project.ext.apktool_version"
|
|
||||||
}
|
|
||||||
|
|
||||||
build.doFirst {
|
|
||||||
def javaVersion = System.getProperty("java.version")
|
|
||||||
|
|
||||||
// fail the build if java (1.5/1.6/1.7)
|
|
||||||
if (javaVersion.startsWith("1.5") || javaVersion.startsWith("1.6") || javaVersion.startsWith("1.7")) {
|
|
||||||
throw new GradleException("You can fix this problem!\n" +
|
|
||||||
"We found a " + javaVersion + " JDK\n" +
|
|
||||||
"Please update JAVA_HOME to use at least a 1.8 JDK\n" +
|
|
||||||
"Currently it is set to: " + System.getProperty("java.home")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// used for official releases only. Please don't use
|
|
||||||
task release {
|
|
||||||
}
|
|
||||||
|
|
||||||
// used for publishing snapshot builds to maven.
|
|
||||||
task snapshot {
|
|
||||||
}
|
|
||||||
|
|
||||||
subprojects {
|
|
||||||
apply plugin: 'java'
|
|
||||||
|
|
||||||
test {
|
|
||||||
// https://github.com/iBotPeaches/Apktool/issues/3174
|
|
||||||
systemProperty 'jdk.nio.zipfs.allowDotZipEntry', 'true'
|
|
||||||
systemProperty 'jdk.util.zip.disableZip64ExtraFieldValidation', 'true'
|
|
||||||
|
|
||||||
testLogging {
|
|
||||||
exceptionFormat = 'full'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def mavenProjects = ['apktool-lib', 'apktool-cli', 'brut.j.common', 'brut.j.util', 'brut.j.dir']
|
|
||||||
|
|
||||||
if (project.name in mavenProjects) {
|
|
||||||
apply plugin: 'maven-publish'
|
|
||||||
apply plugin: 'signing'
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
maven(MavenPublication) {
|
|
||||||
from project.components.java
|
|
||||||
|
|
||||||
groupId = 'org.apktool'
|
|
||||||
artifactId = project.name
|
|
||||||
version = mavenVersion
|
|
||||||
|
|
||||||
pom {
|
|
||||||
name = 'Apktool'
|
|
||||||
description = 'A tool for reverse engineering Android apk files.'
|
|
||||||
url = 'https://apktool.org'
|
|
||||||
|
|
||||||
licenses {
|
|
||||||
license {
|
|
||||||
name = 'The Apache License 2.0'
|
|
||||||
url = 'https://opensource.org/licenses/Apache-2.0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
developers {
|
|
||||||
developer {
|
|
||||||
id = 'iBotPeaches'
|
|
||||||
name = 'Connor Tumbleson'
|
|
||||||
email = 'connor.tumbleson@gmail.com'
|
|
||||||
}
|
|
||||||
developer {
|
|
||||||
id = 'brutall'
|
|
||||||
name = 'Ryszard Wiśniewski'
|
|
||||||
email = 'brut.alll@gmail.com'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scm {
|
|
||||||
connection = 'scm:git:git://github.com/iBotPeaches/Apktool.git'
|
|
||||||
developerConnection = 'scm:git:git@github.com:iBotPeaches/Apktool.git'
|
|
||||||
url = 'https://github.com/iBotPeaches/Apktool'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
if (mavenVersion.endsWith('-SNAPSHOT')) {
|
|
||||||
url = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
|
|
||||||
} else {
|
|
||||||
url = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
|
|
||||||
}
|
|
||||||
credentials {
|
|
||||||
username ossrhUsername
|
|
||||||
password ossrhPassword
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
signing {
|
|
||||||
required { gradle.taskGraph.hasTask('publish') }
|
|
||||||
sign(publishing.publications["maven"])
|
|
||||||
}
|
|
||||||
|
|
||||||
java {
|
|
||||||
withJavadocJar()
|
|
||||||
withSourcesJar()
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.getByPath(':release').dependsOn(publish)
|
|
||||||
tasks.getByPath(':snapshot').dependsOn(publish)
|
|
||||||
|
|
||||||
tasks.withType(Javadoc).tap {
|
|
||||||
configureEach {
|
|
||||||
options.addStringOption('Xdoclint:none', '-quiet')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
186
build.gradle.kts
Normal file
186
build.gradle.kts
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
|
||||||
|
val baksmaliVersion by extra("3.0.3")
|
||||||
|
val commonsCliVersion by extra("1.5.0")
|
||||||
|
val commonsIoVersion by extra("2.13.0")
|
||||||
|
val commonsLangVersion by extra("3.13.0")
|
||||||
|
val commonsTextVersion by extra("1.10.0")
|
||||||
|
val guavaVersion by extra("32.0.1-jre")
|
||||||
|
val junitVersion by extra("4.13.2")
|
||||||
|
val smaliVersion by extra("3.0.3")
|
||||||
|
val xmlpullVersion by extra("1.1.4c")
|
||||||
|
val xmlunitVersion by extra("2.9.1")
|
||||||
|
|
||||||
|
val version = "2.8.2"
|
||||||
|
val suffix = "SNAPSHOT"
|
||||||
|
|
||||||
|
// Strings embedded into the build.
|
||||||
|
var gitRevision by extra("")
|
||||||
|
var apktoolVersion by extra("")
|
||||||
|
|
||||||
|
defaultTasks("build", "shadowJar", "proguard")
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
val gitDescribe: String? by lazy {
|
||||||
|
val stdout = ByteArrayOutputStream()
|
||||||
|
try {
|
||||||
|
rootProject.exec {
|
||||||
|
commandLine("git", "describe", "--tags")
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
|
stdout.toString().trim().replace("-g", "-")
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val gitBranch: String? by lazy {
|
||||||
|
val stdout = ByteArrayOutputStream()
|
||||||
|
try {
|
||||||
|
rootProject.exec {
|
||||||
|
commandLine("git", "rev-parse", "--abbrev-ref", "HEAD")
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
|
stdout.toString().trim()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("release" !in gradle.startParameter.taskNames) {
|
||||||
|
val hash = this.gitDescribe
|
||||||
|
|
||||||
|
if (hash == null) {
|
||||||
|
gitRevision = "dirty"
|
||||||
|
apktoolVersion = "$version-dirty"
|
||||||
|
project.logger.lifecycle("Building SNAPSHOT (no .git folder found)")
|
||||||
|
} else {
|
||||||
|
gitRevision = hash
|
||||||
|
apktoolVersion = "$hash-SNAPSHOT"
|
||||||
|
project.logger.lifecycle("Building SNAPSHOT ($gitBranch): $gitRevision")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
gitRevision = ""
|
||||||
|
apktoolVersion = if (suffix.isNotEmpty()) "$version-$suffix" else version;
|
||||||
|
project.logger.lifecycle("Building RELEASE ($gitBranch): $apktoolVersion")
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
`java-library`
|
||||||
|
`maven-publish`
|
||||||
|
signing
|
||||||
|
}
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
google()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("gradle.plugin.com.github.johnrengelman:shadow:8.0.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<JavaCompile> {
|
||||||
|
options.compilerArgs.add("-Xlint:-options")
|
||||||
|
options.compilerArgs.add("--release 8")
|
||||||
|
|
||||||
|
options.encoding = "UTF-8"
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
google()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
apply(plugin = "java")
|
||||||
|
apply(plugin = "java-library")
|
||||||
|
|
||||||
|
val mavenProjects = arrayOf("apktool-lib", "apktool-cli", "brut.j.common", "brut.j.util", "brut.j.dir")
|
||||||
|
|
||||||
|
if (project.name in mavenProjects) {
|
||||||
|
apply(plugin = "maven-publish")
|
||||||
|
apply(plugin = "signing")
|
||||||
|
|
||||||
|
java {
|
||||||
|
withJavadocJar()
|
||||||
|
withSourcesJar()
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url = if (suffix.contains("SNAPSHOT")) {
|
||||||
|
uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
|
||||||
|
} else {
|
||||||
|
uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
|
||||||
|
}
|
||||||
|
credentials {
|
||||||
|
username = (project.properties["ossrhUsername"] ?: "").toString()
|
||||||
|
password = (project.properties["ossrhPassword"] ?: "").toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
publications {
|
||||||
|
register("mavenJava", MavenPublication::class) {
|
||||||
|
from(components["java"])
|
||||||
|
groupId = "org.apktool"
|
||||||
|
artifactId = project.name
|
||||||
|
version = apktoolVersion
|
||||||
|
|
||||||
|
pom {
|
||||||
|
name = "Apktool"
|
||||||
|
description = "A tool for reverse engineering Android apk files."
|
||||||
|
url = "https://apktool.org"
|
||||||
|
|
||||||
|
licenses {
|
||||||
|
license {
|
||||||
|
name = "The Apache License 2.0"
|
||||||
|
url = "https://opensource.org/licenses/Apache-2.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
id = "iBotPeaches"
|
||||||
|
name = "Connor Tumbleson"
|
||||||
|
email = "connor.tumbleson@gmail.com"
|
||||||
|
}
|
||||||
|
developer {
|
||||||
|
id = "brutall"
|
||||||
|
name = "Ryszard Wiśniewski"
|
||||||
|
email = "brut.alll@gmail.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scm {
|
||||||
|
connection = "scm:git:git://github.com/iBotPeaches/Apktool.git"
|
||||||
|
developerConnection = "scm:git:git@github.com:iBotPeaches/Apktool.git"
|
||||||
|
url = "https://github.com/iBotPeaches/Apktool"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Javadoc>() {
|
||||||
|
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
|
||||||
|
}
|
||||||
|
|
||||||
|
signing {
|
||||||
|
sign(publishing.publications["mavenJava"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Used for official releases.
|
||||||
|
task("release") {
|
||||||
|
dependsOn("build")
|
||||||
|
finalizedBy("publish")
|
||||||
|
}
|
@ -1,52 +0,0 @@
|
|||||||
import org.codehaus.groovy.runtime.MethodClosure
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copyright 2014 Ryszard Wiśniewski <brut.alll@gmail.com>
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* https://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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
def getCheckedOutGitCommitHash() {
|
|
||||||
def gitFolder = "$projectDir/.git/"
|
|
||||||
def takeFromHash = 6
|
|
||||||
|
|
||||||
def head
|
|
||||||
try {
|
|
||||||
head = new File(gitFolder + "HEAD").text.split(":")
|
|
||||||
} catch(Exception ignored) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
def isCommit = head.length == 1
|
|
||||||
if(isCommit) return head[0].trim().take(takeFromHash)
|
|
||||||
|
|
||||||
def refHead = new File(gitFolder + head[1].trim())
|
|
||||||
refHead.text.trim().take takeFromHash
|
|
||||||
}
|
|
||||||
|
|
||||||
def getCheckedOutBranch() {
|
|
||||||
def gitFolder = "$projectDir/.git/"
|
|
||||||
|
|
||||||
def head
|
|
||||||
try {
|
|
||||||
head = new File(gitFolder + "HEAD").text.split("/")
|
|
||||||
return head[2].trim()
|
|
||||||
} catch(Exception ignored) {
|
|
||||||
return "SNAPSHOT"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ext {
|
|
||||||
getCheckedOutGitCommitHash = this.&getCheckedOutGitCommitHash as MethodClosure
|
|
||||||
getCheckedOutBranch = this.&getCheckedOutBranch as MethodClosure
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
rootProject.name = 'apktool-cli'
|
|
||||||
include 'brut.j.common',
|
|
||||||
'brut.j.util',
|
|
||||||
'brut.j.dir',
|
|
||||||
'brut.apktool:apktool-lib',
|
|
||||||
'brut.apktool:apktool-cli'
|
|
2
settings.gradle.kts
Normal file
2
settings.gradle.kts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
rootProject.name = "apktool-cli"
|
||||||
|
include("brut.j.common", "brut.j.util", "brut.j.dir", "brut.apktool:apktool-lib", "brut.apktool:apktool-cli")
|
Loading…
Reference in New Issue
Block a user