forked from iBotPeaches/Apktool
-
Notifications
You must be signed in to change notification settings - Fork 14
/
build.gradle.kts
164 lines (141 loc) · 4.73 KB
/
build.gradle.kts
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import java.io.ByteArrayOutputStream
val version = "2.10.1.1"
val suffix = ""
// 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
}
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")
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
val mavenProjects = arrayOf("brut.j.common", "brut.j.util", "brut.j.dir", "brut.j.xml", "apktool-lib", "apktool-cli")
if (project.name in mavenProjects) {
apply(plugin = "maven-publish")
apply(plugin = "signing")
java {
withJavadocJar()
withSourcesJar()
}
publishing {
repositories {
maven {
url = uri("https://maven.pkg.github.com/revanced/Apktool")
credentials {
username = System.getenv("GITHUB_ACTOR") ?: project.findProperty("gpr.user").toString()
password = System.getenv("GITHUB_TOKEN") ?: project.findProperty("gpr.key").toString()
}
}
}
publications {
register("mavenJava", MavenPublication::class) {
from(components["java"])
groupId = "app.revanced"
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/revanced/Apktool.git"
developerConnection = "scm:git:git@github.com:revanced/Apktool.git"
url = "https://github.com/revanced/Apktool"
}
}
}
}
}
tasks.withType<Javadoc>() {
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
}
signing {
useGpgCmd()
sign(publishing.publications["mavenJava"])
}
}
}
task("release") {
// Used for official releases.
}
tasks.wrapper {
distributionType = Wrapper.DistributionType.ALL
}