Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
29 changes: 24 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down Expand Up @@ -84,32 +96,39 @@ subprojects {
productFlavors {
flavorDimensions("feature")

val removeSuffix = (queryConfigProperty("remove.suffix") as? String)?.toBoolean() == true

create("alpha") {
isDefault = true
dimension = flavorDimensionList[0]
versionNameSuffix = ".Alpha"
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"
}
}

create("meta") {

dimension = flavorDimensionList[0]
versionNameSuffix = ".Meta"
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"
}
}
Expand Down
Loading