mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2026-05-09 18:11:26 +08:00
supports user-defined application_id/package_name (#628)
This commit is contained in:
12
README.md
12
README.md
@@ -32,7 +32,15 @@ Feature of [Clash.Meta](https://github.com/MetaCubeX/Clash.Meta)
|
||||
sdk.dir=/path/to/android-sdk
|
||||
```
|
||||
|
||||
4. Create `signing.properties` in project root with
|
||||
4. (Optional) Custom app package name. Add the following configuration to `local.properties`.
|
||||
|
||||
```properties
|
||||
# config your ownn applicationId, or it will be 'com.github.metacubex.clash'
|
||||
custom.application.id=com.my.compile.clash
|
||||
# remove application id suffix, or the applicaion id will be 'com.github.metacubex.clash.alpha'
|
||||
remove.suffix=true
|
||||
|
||||
5. Create `signing.properties` in project root with
|
||||
|
||||
```properties
|
||||
keystore.path=/path/to/keystore/file
|
||||
@@ -41,7 +49,7 @@ Feature of [Clash.Meta](https://github.com/MetaCubeX/Clash.Meta)
|
||||
key.password=<key password>
|
||||
```
|
||||
|
||||
5. Build
|
||||
6. Build
|
||||
|
||||
```bash
|
||||
./gradlew app:assembleAlphaRelease
|
||||
|
||||
@@ -31,11 +31,23 @@ subprojects {
|
||||
|
||||
apply(plugin = if (isApp) "com.android.application" else "com.android.library")
|
||||
|
||||
fun queryConfigProperty(key: String): Any? {
|
||||
val localProperties = Properties()
|
||||
val localPropertiesFile = rootProject.file("local.properties")
|
||||
if (localPropertiesFile.exists()) {
|
||||
localProperties.load(localPropertiesFile.inputStream())
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
return localProperties.getProperty(key)
|
||||
}
|
||||
|
||||
extensions.configure<BaseExtension> {
|
||||
buildFeatures.buildConfig = true
|
||||
defaultConfig {
|
||||
if (isApp) {
|
||||
applicationId = "com.github.metacubex.clash"
|
||||
val customApplicationId = queryConfigProperty("custom.application.id") as? String?
|
||||
applicationId = customApplicationId.takeIf { it?.isNotBlank() == true } ?: "com.github.metacubex.clash"
|
||||
}
|
||||
|
||||
project.name.let { name ->
|
||||
@@ -84,17 +96,22 @@ subprojects {
|
||||
productFlavors {
|
||||
flavorDimensions("feature")
|
||||
|
||||
val removeSuffix = (queryConfigProperty("remove.suffix") as? String)?.toBoolean() == true
|
||||
|
||||
create("alpha") {
|
||||
isDefault = true
|
||||
dimension = flavorDimensionList[0]
|
||||
if (!removeSuffix) {
|
||||
versionNameSuffix = ".Alpha"
|
||||
}
|
||||
|
||||
|
||||
buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"false\")")
|
||||
|
||||
resValue("string", "launch_name", "@string/launch_name_alpha")
|
||||
resValue("string", "application_name", "@string/application_name_alpha")
|
||||
|
||||
if (isApp) {
|
||||
if (isApp && !removeSuffix) {
|
||||
applicationIdSuffix = ".alpha"
|
||||
}
|
||||
}
|
||||
@@ -102,14 +119,16 @@ subprojects {
|
||||
create("meta") {
|
||||
|
||||
dimension = flavorDimensionList[0]
|
||||
if (!removeSuffix) {
|
||||
versionNameSuffix = ".Meta"
|
||||
}
|
||||
|
||||
buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"false\")")
|
||||
|
||||
resValue("string", "launch_name", "@string/launch_name_meta")
|
||||
resValue("string", "application_name", "@string/application_name_meta")
|
||||
|
||||
if (isApp) {
|
||||
if (isApp && !removeSuffix) {
|
||||
applicationIdSuffix = ".meta"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user