forked from iBotPeaches/Apktool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
166 lines (144 loc) · 4.89 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
165
166
import java.io.ByteArrayOutputStream
val version = "2.9.1"
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 {
alias(libs.plugins.shadow)
`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("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 = "[email protected]"
}
developer {
id = "brutall"
name = "Ryszard Wiśniewski"
email = "[email protected]"
}
}
scm {
connection = "scm:git:git://github.com/iBotPeaches/Apktool.git"
developerConnection = "scm:git:[email protected]: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")
}