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
|
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
|
```properties
|
||||||
keystore.path=/path/to/keystore/file
|
keystore.path=/path/to/keystore/file
|
||||||
@@ -41,7 +49,7 @@ Feature of [Clash.Meta](https://github.com/MetaCubeX/Clash.Meta)
|
|||||||
key.password=<key password>
|
key.password=<key password>
|
||||||
```
|
```
|
||||||
|
|
||||||
5. Build
|
6. Build
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./gradlew app:assembleAlphaRelease
|
./gradlew app:assembleAlphaRelease
|
||||||
|
|||||||
@@ -31,11 +31,23 @@ subprojects {
|
|||||||
|
|
||||||
apply(plugin = if (isApp) "com.android.application" else "com.android.library")
|
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> {
|
extensions.configure<BaseExtension> {
|
||||||
buildFeatures.buildConfig = true
|
buildFeatures.buildConfig = true
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
if (isApp) {
|
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 ->
|
project.name.let { name ->
|
||||||
@@ -84,17 +96,22 @@ subprojects {
|
|||||||
productFlavors {
|
productFlavors {
|
||||||
flavorDimensions("feature")
|
flavorDimensions("feature")
|
||||||
|
|
||||||
|
val removeSuffix = (queryConfigProperty("remove.suffix") as? String)?.toBoolean() == true
|
||||||
|
|
||||||
create("alpha") {
|
create("alpha") {
|
||||||
isDefault = true
|
isDefault = true
|
||||||
dimension = flavorDimensionList[0]
|
dimension = flavorDimensionList[0]
|
||||||
|
if (!removeSuffix) {
|
||||||
versionNameSuffix = ".Alpha"
|
versionNameSuffix = ".Alpha"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"false\")")
|
buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"false\")")
|
||||||
|
|
||||||
resValue("string", "launch_name", "@string/launch_name_alpha")
|
resValue("string", "launch_name", "@string/launch_name_alpha")
|
||||||
resValue("string", "application_name", "@string/application_name_alpha")
|
resValue("string", "application_name", "@string/application_name_alpha")
|
||||||
|
|
||||||
if (isApp) {
|
if (isApp && !removeSuffix) {
|
||||||
applicationIdSuffix = ".alpha"
|
applicationIdSuffix = ".alpha"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,14 +119,16 @@ subprojects {
|
|||||||
create("meta") {
|
create("meta") {
|
||||||
|
|
||||||
dimension = flavorDimensionList[0]
|
dimension = flavorDimensionList[0]
|
||||||
|
if (!removeSuffix) {
|
||||||
versionNameSuffix = ".Meta"
|
versionNameSuffix = ".Meta"
|
||||||
|
}
|
||||||
|
|
||||||
buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"false\")")
|
buildConfigField("boolean", "PREMIUM", "Boolean.parseBoolean(\"false\")")
|
||||||
|
|
||||||
resValue("string", "launch_name", "@string/launch_name_meta")
|
resValue("string", "launch_name", "@string/launch_name_meta")
|
||||||
resValue("string", "application_name", "@string/application_name_meta")
|
resValue("string", "application_name", "@string/application_name_meta")
|
||||||
|
|
||||||
if (isApp) {
|
if (isApp && !removeSuffix) {
|
||||||
applicationIdSuffix = ".meta"
|
applicationIdSuffix = ".meta"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user