diff --git a/.github/workflows/build-alpha.yml b/.github/workflows/build-alpha.yml deleted file mode 100644 index 25e0df7..0000000 --- a/.github/workflows/build-alpha.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Assemble Alpha - -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-20.04 - - steps: - - name: Checkout - uses: actions/checkout@v3.1.0 - with: - token: ${{ secrets.TOKEN }} - submodules: 'recursive' - - - - name: Initialization environment - env: - DEBIAN_FRONTEND: noninteractive - run: | - sudo timedatectl set-timezone "Asia/Shanghai" - sudo mkdir -p /workdir - sudo chown $USER:$GROUPS /workdir - - - name: Setup JDK 17 - uses: oracle-actions/setup-java@v1 - with: - website: oracle.com - release: 17 - version: 17 - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - - name: Setup Android SDK - uses: android-actions/setup-android@v2 - - - name: Setup aapt - run: | - sudo apt install aapt -y - - - name: Build with Gradle - run: | - bash ./gradlew assembleAlphaAndLocate - - - name: Organize files - run: | - cp ./build/assemble/*.apk /workdir/ - - - name: Generate release tag - id: tag - run: | - release_tag=v$(aapt dump badging /workdir/*.apk | grep -P "versionName='(.*?)'" -o | cut -d \' -f 2) - echo "::set-output name=release_tag::$release_tag" - - - name: Upload to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ steps.tag.outputs.release_tag }} - file: "/workdir/*" - overwrite: true - file_glob: true - prerelease: true - - - name: Delete workflow runs - uses: GitRML/delete-workflow-runs@main - with: - token: ${{ secrets.TOKEN }} - retain_days: 1 - keep_minimum_runs: 1 - - - name: Remove old release - uses: sgpublic/delete-release-action@v1.1 - env: - GITHUB_TOKEN: ${{ secrets.TOKEN }} - with: - release-drop: false - pre-release-drop: true - pre-release-keep-count: 0 - pre-release-drop-tag: true - draft-drop: true diff --git a/.github/workflows/build-beta.yml b/.github/workflows/build-beta.yml deleted file mode 100644 index d1b10f1..0000000 --- a/.github/workflows/build-beta.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Assemble Beta - -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-20.04 - - steps: - - name: Checkout - uses: actions/checkout@v3.1.0 - with: - token: ${{ secrets.TOKEN }} - submodules: 'recursive' - - - - name: Initialization environment - env: - DEBIAN_FRONTEND: noninteractive - run: | - sudo timedatectl set-timezone "Asia/Shanghai" - sudo mkdir -p /workdir - sudo chown $USER:$GROUPS /workdir - - - name: Setup JDK 17 - uses: oracle-actions/setup-java@v1 - with: - website: oracle.com - release: 17 - version: 17 - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - - name: Setup Android SDK - uses: android-actions/setup-android@v2 - - - name: Setup aapt - run: | - sudo apt install aapt -y - - - name: Build with Gradle - run: | - bash ./gradlew assembleBetaAndLocate - - - name: Organize files - run: | - cp ./build/assemble/*.apk /workdir/ - - - name: Generate release tag - id: tag - run: | - release_tag=v$(aapt dump badging /workdir/*.apk | grep -P "versionName='(.*?)'" -o | cut -d \' -f 2) - echo "::set-output name=release_tag::$release_tag" - - - name: Upload to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ steps.tag.outputs.release_tag }} - file: "/workdir/*" - overwrite: true - file_glob: true - prerelease: true - - - name: Delete workflow runs - uses: GitRML/delete-workflow-runs@main - with: - token: ${{ secrets.TOKEN }} - retain_days: 1 - keep_minimum_runs: 1 - - - name: Remove old release - uses: sgpublic/delete-release-action@v1.1 - env: - GITHUB_TOKEN: ${{ secrets.TOKEN }} - with: - release-drop: false - pre-release-drop: true - pre-release-keep-count: 0 - pre-release-drop-tag: true - draft-drop: true diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml deleted file mode 100644 index bf9b2b9..0000000 --- a/.github/workflows/build-release.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: Assemble Release - -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-20.04 - - steps: - - name: Checkout - uses: actions/checkout@v3.1.0 - with: - token: ${{ secrets.TOKEN }} - submodules: 'recursive' - - - name: Initialization environment - env: - DEBIAN_FRONTEND: noninteractive - run: | - sudo timedatectl set-timezone "Asia/Shanghai" - sudo mkdir -p /workdir - sudo chown $USER:$GROUPS /workdir - - - name: Setup JDK 17 - uses: oracle-actions/setup-java@v1 - with: - website: oracle.com - release: 17 - version: 17 - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - - name: Setup Android SDK - uses: android-actions/setup-android@v2 - - - name: Setup aapt - run: | - sudo apt install aapt -y - - - name: Build with Gradle - run: | - bash ./gradlew assembleReleaseAndLocate - - - name: Organize files - run: | - cp ./build/assemble/*.apk /workdir/ - - - name: Generate release tag - id: tag - run: | - release_tag=v$(aapt dump badging /workdir/*.apk | grep -P "versionName='(.*?)'" -o | cut -d \' -f 2) - echo "::set-output name=release_tag::$release_tag" - - - name: Upload to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ steps.tag.outputs.release_tag }} - file: "/workdir/*" - overwrite: true - file_glob: true - - - name: Delete workflow runs - uses: GitRML/delete-workflow-runs@main - with: - token: ${{ secrets.TOKEN }} - retain_days: 1 - keep_minimum_runs: 1 - - - name: Remove old release - uses: sgpublic/delete-release-action@v1.1 - env: - GITHUB_TOKEN: ${{ secrets.TOKEN }} - with: - release-drop: false - pre-release-drop: true - pre-release-keep-count: -1 - pre-release-drop-tag: true - draft-drop: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..181e3e3 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,43 @@ +name: Assemble Release + +on: + push: + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout + uses: actions/checkout@v3.1.0 + with: + token: ${{ secrets.PUBLISHING_GITHUB_TOKEN }} + submodules: 'recursive' + + - name: Initialization environment + env: + DEBIAN_FRONTEND: noninteractive + run: | + sudo timedatectl set-timezone "Asia/Shanghai" + + - name: Setup JDK 17 + uses: oracle-actions/setup-java@v1 + with: + website: oracle.com + release: 17 + version: 17 + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + + - name: Setup Android SDK + uses: android-actions/setup-android@v2 + + - name: Build with Gradle + env: + PUBLISHING_GITHUB_TOKEN: ${{ secrets.PUBLISHING_GITHUB_TOKEN }} + run: | + bash ./gradlew assembleReleaseAndLocate + bash ./gradlew githubRelease diff --git a/.gitignore b/.gitignore index 6d8f764..407726e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ local.properties version.properties buildSrc/build/ -.kotlin/ \ No newline at end of file +.kotlin/ +assemble/ \ No newline at end of file diff --git a/README.md b/README.md index 8c20778..615ffc8 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ ![GitHub all releases](https://img.shields.io/github/downloads/sgpublic/BiliBangumiDownloader/total) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/sgpublic/BiliBangumiDownloader) ![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/sgpublic/BiliBangumiDownloader?include_prereleases) +此仓库虽然没有积极更新,但作者仍愿意继续维护,若您发现了这个软件,希望作者继续更新,请点个 star 让我知道有人在关注这个软件,也可以进入我的主页加入我的社群直接催更,谢谢您! + 哔哩番剧正在迁移至Kotlin,Java实现项目地址:[BiliBangumiDownloader_Java](https://github.com/SGPublic/BiliBangumiDownloader_Java) ## 申明 diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 9d804ea..cf80a14 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,35 +1,26 @@ @file:Suppress("PropertyName") -import com.android.build.api.dsl.VariantDimension -import com.android.build.gradle.internal.api.BaseVariantOutputImpl import com.google.protobuf.gradle.proto -import io.github.sgpublic.gradle.Dep -import io.github.sgpublic.gradle.core.BuildTypes -import io.github.sgpublic.gradle.core.SignConfig -import io.github.sgpublic.gradle.core.VersionGen -import io.github.sgpublic.gradle.util.ApkUtil +import io.github.sgpublic.androidassemble.core.renameRule +import io.github.sgpublic.androidassemble.util.VersionGen +import io.github.sgpublic.androidassemble.util.buildConfigField import java.util.* plugins { - id("bilidl-version") + alias(bilidl.plugins.android.application) - id("com.android.application") - id("org.jetbrains.kotlin.android") - id("org.jetbrains.kotlin.plugin.parcelize") - id("org.jetbrains.kotlin.kapt") + alias(bilidl.plugins.kotlin.android) + alias(bilidl.plugins.kotlin.plugin.parcelize) + alias(bilidl.plugins.kotlin.kapt) + alias(bilidl.plugins.kotlin.plugin.lombok) - id("org.jetbrains.kotlin.plugin.lombok") - id("io.freefair.lombok") version "5.3.0" - - id("com.google.protobuf") + alias(bilidl.plugins.protobuf) + alias(bilidl.plugins.lombok) + alias(bilidl.plugins.github.release) + alias(bilidl.plugins.android.assemble) } -fun VariantDimension.buildConfigField(name: String, value: String) { - buildConfigField("String", name, "\"$value\"") -} -fun VariantDimension.buildConfigField(name: String, value: Int) { - buildConfigField("int", name, value.toString()) -} +val mVersion = findProperty("bilidl.version")!!.toString() android { compileSdk = 34 @@ -42,7 +33,7 @@ android { val keyProps = Properties() keyProps.load(properties.inputStream()) signingConfigs { - create(SignConfig.NAME) { + create("release") { val SIGN_DIR: String by keyProps val SIGN_PASSWORD_STORE: String by keyProps val SIGN_ALIAS: String by keyProps @@ -56,6 +47,7 @@ android { } buildFeatures { + buildConfig = true viewBinding = true } @@ -76,10 +68,8 @@ android { applicationId = "io.github.sgpublic.bilidownload" minSdk = 29 targetSdk = 34 - versionCode = VersionGen.COMMIT_VERSION - versionName = "3.5.0".also { - buildConfigField("ORIGIN_VERSION_NAME", it) - } + versionCode = VersionGen.COMMIT_COUNT_VERSION + versionName = mVersion testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" @@ -90,61 +80,36 @@ android { buildConfigField("GITHUB_REPO_NAME", repo[1]) } buildConfigField("PROJECT_NAME", rootProject.name) - buildConfigField("TYPE_RELEASE", BuildTypes.TYPE_RELEASE) - buildConfigField("LEVEL_RELEASE", BuildTypes.LEVEL_RELEASE) - buildConfigField("TYPE_BETA", BuildTypes.TYPE_BETA) - buildConfigField("LEVEL_BETA", BuildTypes.LEVEL_BETA) - buildConfigField("TYPE_ALPHA", BuildTypes.TYPE_ALPHA) - buildConfigField("LEVEL_ALPHA", BuildTypes.LEVEL_ALPHA) - buildConfigField("TYPE_DEBUG", BuildTypes.TYPE_DEBUG) - buildConfigField("LEVEL_DEBUG", BuildTypes.LEVEL_DEBUG) } buildTypes { all { isMinifyEnabled = false if (signInfoExit) { - signingConfig = signingConfigs.getByName(SignConfig.NAME) + signingConfig = signingConfigs.getByName("release") } } /** 自动化版本命名 */ - named(BuildTypes.TYPE_RELEASE) { - versionNameSuffix = "-$name" - buildConfigField("VERSION_SUFFIX", "") - buildConfigField("BUILD_LEVEL", BuildTypes.LEVEL_RELEASE) + release { + renameRule(project) { + "${rootProject.name} V${versionName}(${versionCode})" + } } - named(BuildTypes.TYPE_DEBUG) { - defaultConfig.versionCode = VersionGen.DATED_VERSION + debug { isDebuggable = true - versionNameSuffix = "-$name" - buildConfigField("VERSION_SUFFIX", "") - buildConfigField("BUILD_LEVEL", BuildTypes.LEVEL_DEBUG) - } - if (signInfoExit) { - register(BuildTypes.TYPE_BETA) { - val suffix = VersionGen.GIT_HEAD - versionNameSuffix = "-$suffix-$name" - isDebuggable = true - buildConfigField("VERSION_SUFFIX", suffix) - buildConfigField("BUILD_LEVEL", BuildTypes.LEVEL_BETA) - } - register(BuildTypes.TYPE_ALPHA) { - val suffix = VersionGen.TIME_MD5 - defaultConfig.versionCode = VersionGen.DATED_VERSION - isDebuggable = true - versionNameSuffix = "-$suffix-$name" - buildConfigField("VERSION_SUFFIX", suffix) - buildConfigField("BUILD_LEVEL", BuildTypes.LEVEL_ALPHA) + + renameRule(project) { + "${rootProject.name}_${versionName}_${versionCode}" } } } compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = "11" + jvmTarget = "17" } buildFeatures { buildConfig = true @@ -163,22 +128,22 @@ android { protobuf { protoc { - artifact = "com.google.protobuf:protoc:${Dep.Proto}" + artifact = "com.google.protobuf:protoc:${bilidl.versions.protobuf.asProvider().get()}" } plugins { register("grpc") { - artifact = "io.grpc:protoc-gen-grpc-java:${Dep.GrpcJava}" + artifact = "io.grpc:protoc-gen-grpc-java:${bilidl.versions.grpc.get()}" } } generateProtoTasks { for(task in all()) { task.builtins { - register("java") { + val java by creating { option("lite") } } task.plugins { - register("grpc") { + val grpc by creating { option("lite") } } @@ -191,99 +156,97 @@ kapt { } dependencies { - implementation("androidx.test.ext:junit-ktx:1.2.1") - testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.2.1") - androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1") - androidTestImplementation("androidx.test:runner:1.6.2") - androidTestImplementation("androidx.test:rules:1.6.1") - implementation(kotlin("reflect")) - - implementation("androidx.core:core-ktx:1.13.1") - implementation("androidx.appcompat:appcompat:1.7.0") - implementation("com.google.android.material:material:1.12.0") - implementation("androidx.constraintlayout:constraintlayout:2.1.4") - implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") - implementation("androidx.navigation:navigation-fragment-ktx:2.7.7") + testImplementation(bilidl.junit) + androidTestImplementation(bilidl.androidx.test.ext) + androidTestImplementation(bilidl.androidx.test.espresso) + androidTestImplementation(bilidl.androidx.test.runner) + androidTestImplementation(bilidl.androidx.test.rules) + implementation(bilidl.kotlin.reflect) + + implementation(bilidl.androidx.core) + implementation(bilidl.androidx.appcompat) + implementation(bilidl.google.material) + implementation(bilidl.androidx.constraintlayout) + implementation(bilidl.androidx.swiperefreshlayout) + implementation(bilidl.androidx.navigation) /* https://github.com/zhpanvip/BannerViewPager */ - implementation("com.github.zhpanvip:BannerViewPager:3.5.7") + implementation(bilidl.bannerviewpager) /* https://github.com/yanzhenjie/Sofia */ - implementation("com.yanzhenjie:sofia:1.0.5") + implementation(bilidl.sofia) /* https://github.com/scwang90/MultiWaveHeader */ - implementation("io.github.sgpublic:MultiWaveHeader:1.0.2") + implementation(bilidl.multiwaveheader) /* https://github.com/li-xiaojun/XPopup */ - implementation("com.github.li-xiaojun:XPopup:2.9.1") + implementation(bilidl.xpopup) /* https://github.com/zxing/zxing qrcode */ - implementation("com.google.zxing:core:3.5.0") + implementation(bilidl.zxing) // /* https://github.com/KwaiAppTeam/AkDanmaku */ -// implementation("com.kuaishou:akdanmaku:1.0.3") - /* https://docs.geetest.com/sensebot/deploy/client/android */ - implementation("com.geetest.sensebot:sensebot:4.4.2.1") +// implementation(bilidl.akdanmaku) + implementation(bilidl.geetest) /* https://github.com/sgpublic/ExSharedPreference */ - implementation("io.github.sgpublic:exsp-runtime:${Dep.EXSP}") - kapt("io.github.sgpublic:exsp-compiler:${Dep.EXSP}") + implementation(bilidl.exsp.runtime) + kapt(bilidl.exsp.compiler) - compileOnly("org.projectlombok:lombok:${Dep.Lombok}") - annotationProcessor("org.projectlombok:lombok:${Dep.Lombok}") - testCompileOnly("org.projectlombok:lombok:${Dep.Lombok}") - testAnnotationProcessor("org.projectlombok:lombok:${Dep.Lombok}") - androidTestCompileOnly("org.projectlombok:lombok:${Dep.Lombok}") - androidTestAnnotationProcessor("org.projectlombok:lombok:${Dep.Lombok}") + compileOnly(bilidl.lombok) + annotationProcessor(bilidl.lombok) + testCompileOnly(bilidl.lombok) + testAnnotationProcessor(bilidl.lombok) + androidTestCompileOnly(bilidl.lombok) + androidTestAnnotationProcessor(bilidl.lombok) - implementation("androidx.room:room-runtime:${Dep.Room}") - annotationProcessor("androidx.room:room-compiler:${Dep.Room}") + implementation(bilidl.androidx.room.runtime) + annotationProcessor(bilidl.androidx.room.compiler) /* https://github.com/google/protobuf-gradle-plugin */ - implementation("com.google.protobuf:protobuf-java:${Dep.Proto}") + implementation(bilidl.protobuf) // 阿b用的 cronet,如果用 okhttp 会导致 io.grpc.StatusRuntimeException: INTERNAL: Received unexpected EOS on DATA frame from server. - implementation("io.grpc:grpc-cronet:${Dep.GrpcJava}") - implementation("com.google.android.gms:play-services-cronet:18.1.0") - implementation("org.chromium.net:cronet-fallback:119.6045.31") - implementation("io.grpc:grpc-android:${Dep.GrpcJava}") - implementation("io.grpc:grpc-protobuf:${Dep.GrpcJava}") - implementation("io.grpc:grpc-stub:${Dep.GrpcJava}") - implementation("org.apache.tomcat:annotations-api:6.0.53") + implementation(bilidl.grpc.cronet) + implementation(bilidl.google.play.cronet) + implementation(bilidl.cronet.fallback) + implementation(bilidl.grpc.android) + implementation(bilidl.grpc.protobuf) + implementation(bilidl.grpc.stub) + implementation(bilidl.tomcat.annotations) /* https://github.com/bumptech/glide */ - implementation("com.github.bumptech.glide:glide:${Dep.Glide}") - kapt("com.github.bumptech.glide:compiler:${Dep.Glide}") - implementation("jp.wasabeef:glide-transformations:4.3.0") + implementation(bilidl.glide) + kapt(bilidl.glide.compiler) + implementation(bilidl.glide.transformations) /* https://github.com/google/ExoPlayer */ - implementation("com.google.android.exoplayer:exoplayer-core:${Dep.ExoPlayer}") - implementation("com.google.android.exoplayer:exoplayer-dash:${Dep.ExoPlayer}") - implementation("com.google.android.exoplayer:exoplayer-ui:${Dep.ExoPlayer}") + implementation(bilidl.exoplayer.core) + implementation(bilidl.exoplayer.dash) + implementation(bilidl.exoplayer.ui) /* https://github.com/AriaLyy/Aria */ - implementation("me.laoyuyu.aria:core:${Dep.Aria}") - kapt("me.laoyuyu.aria:compiler:${Dep.Aria}") + implementation(bilidl.aria.core) + kapt(bilidl.aria.compiler) /* https://github.com/tony19/logback-android */ - implementation("com.github.tony19:logback-android:3.0.0") - implementation("org.slf4j:slf4j-api:2.0.13") + implementation(bilidl.logback.android) + implementation(bilidl.slf4j.api) /* https://github.com/dromara/forest */ - implementation("com.dtflys.forest:forest-core:1.5.26") - implementation("com.google.code.gson:gson:2.10.1") - implementation("com.squareup.okhttp3:okhttp:4.12.0") + implementation(bilidl.forest) + implementation(bilidl.gson) + implementation(bilidl.okhttp3) } -/** 自动修改输出文件名并定位文件 */ -android.applicationVariants.all { - for (output in outputs) { - if (output !is BaseVariantOutputImpl) { - continue - } - val name = output.name.split("-") - .joinToString("") { it.capitalize() } - val taskName = "assemble${name}AndLocate" - tasks.register(taskName) { - dependsOn("assemble${name}") - doLast { - ApkUtil.assembleAndLocate(output.name, output.outputFile, "./build/assemble") - } - } - } +fun findEnv(name: String) = provider { + findProperty(name)?.toString()?.takeIf { it.isNotBlank() } + ?: System.getenv(name.replace(".", "_").uppercase()) +} + +githubRelease { + token(findEnv("publishing.github.token")) + owner = "sgpublic" + repo = "BiliBangumiDownloader" + tagName = "v${mVersion}" + releaseName = "v${mVersion}" + overwrite = true + + releaseAssets( + "${rootDir}/assemble/${rootProject.name} V${mVersion}(${VersionGen.COMMIT_COUNT_VERSION}).apk" + ) } diff --git a/app/src/main/java/io/github/sgpublic/bilidownload/core/logback/FileFilter.kt b/app/src/main/java/io/github/sgpublic/bilidownload/core/logback/FileFilter.kt index ba3d535..38a2354 100644 --- a/app/src/main/java/io/github/sgpublic/bilidownload/core/logback/FileFilter.kt +++ b/app/src/main/java/io/github/sgpublic/bilidownload/core/logback/FileFilter.kt @@ -5,5 +5,5 @@ import io.github.sgpublic.bilidownload.BuildConfig import io.github.sgpublic.bilidownload.core.util.take class FileFilter: AutoLevelFilter( - (BuildConfig.BUILD_LEVEL < BuildConfig.LEVEL_RELEASE).take(Level.DEBUG, Level.INFO) + (BuildConfig.BUILD_TYPE != "release").take(Level.DEBUG, Level.INFO) ) \ No newline at end of file diff --git a/app/src/main/java/io/github/sgpublic/bilidownload/core/util/_String.kt b/app/src/main/java/io/github/sgpublic/bilidownload/core/util/_String.kt index 3fe7fb2..88bd15a 100644 --- a/app/src/main/java/io/github/sgpublic/bilidownload/core/util/_String.kt +++ b/app/src/main/java/io/github/sgpublic/bilidownload/core/util/_String.kt @@ -152,23 +152,3 @@ fun Pattern.matchString(target: CharSequence, def: String): String { fun String.countLine(): Int { return split("\n").size } - -/** 比较版本号 */ -fun String.isHigherThanCurrent(): Boolean { - val origin = split("-")[0].split(".").map { - it.toIntOrNull() ?: return false - } - val target = BuildConfig.ORIGIN_VERSION_NAME.split(".").map { - it.toIntOrNull() ?: return false - } - val length = max(origin.size, target.size) - for (i in 0 until length) { - val originNum = origin.getOrElse(i) { 0 } - val targetNum = target.getOrElse(i) { 0 } - if (originNum == targetNum) { - continue - } - return originNum > targetNum - } - return false -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 22309c3..1b676b6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,14 +1,14 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - val androidVer = "8.5.2" - id("com.android.application") version androidVer apply false - id("com.android.library") version androidVer apply false + alias(bilidl.plugins.android.application) apply false - val kotlinVer = "2.0.10" - id("org.jetbrains.kotlin.android") version kotlinVer apply false - id("org.jetbrains.kotlin.plugin.parcelize") version kotlinVer apply false - id("org.jetbrains.kotlin.kapt") version kotlinVer apply false - id("org.jetbrains.kotlin.plugin.lombok") version kotlinVer apply false + alias(bilidl.plugins.kotlin.android) apply false + alias(bilidl.plugins.kotlin.plugin.parcelize) apply false + alias(bilidl.plugins.kotlin.kapt) apply false + alias(bilidl.plugins.kotlin.plugin.lombok) apply false - id("com.google.protobuf") version "0.9.4" apply false + alias(bilidl.plugins.protobuf) apply false + alias(bilidl.plugins.lombok) apply false + alias(bilidl.plugins.github.release) apply false + alias(bilidl.plugins.android.assemble) apply false } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index b74c1c6..0000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,14 +0,0 @@ -plugins { - `kotlin-dsl` -} - -repositories { - gradlePluginPortal() - google() - mavenCentral() -} - -dependencies { - // https://mvnrepository.com/artifact/net.dongliu/apk-parser - implementation("net.dongliu:apk-parser:2.6.10") -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/ApkPlugin.kt b/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/ApkPlugin.kt deleted file mode 100644 index 37f0347..0000000 --- a/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/ApkPlugin.kt +++ /dev/null @@ -1,17 +0,0 @@ -package io.github.sgpublic.gradle - -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.logging.Logger - -class ApkPlugin: Plugin { - override fun apply(project: Project) { - rootProject = project.rootProject - logger = project.logger - } - - companion object { - lateinit var rootProject: Project private set - lateinit var logger: Logger private set - } -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/Dep.kt b/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/Dep.kt deleted file mode 100644 index 0ed5fa6..0000000 --- a/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/Dep.kt +++ /dev/null @@ -1,18 +0,0 @@ -package io.github.sgpublic.gradle - -/** - * - * @author Madray Haven - * @date 2022/10/24 15:13 - */ -object Dep { - const val Proto = "3.22.3" - const val GrpcJava = "1.57.0" - - const val EXSP = "1.0.0-alpha04" - const val Lombok = "1.18.24" - const val Room = "2.6.1" - const val Glide = "4.14.2" - const val ExoPlayer = "2.19.1" - const val Aria = "3.8.16" -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/core/BuildTypes.kt b/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/core/BuildTypes.kt deleted file mode 100644 index 66953ae..0000000 --- a/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/core/BuildTypes.kt +++ /dev/null @@ -1,12 +0,0 @@ -package io.github.sgpublic.gradle.core - -object BuildTypes { - const val TYPE_RELEASE = "release" - const val LEVEL_RELEASE = 3 - const val TYPE_BETA = "beta" - const val LEVEL_BETA = 2 - const val TYPE_ALPHA = "alpha" - const val LEVEL_ALPHA = 1 - const val TYPE_DEBUG = "debug" - const val LEVEL_DEBUG = -1 -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/core/FlavorTypes.kt b/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/core/FlavorTypes.kt deleted file mode 100644 index 876786c..0000000 --- a/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/core/FlavorTypes.kt +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.sgpublic.gradle.core - -object FlavorTypes { - const val DIMENSIONS = "target" - - const val COMMON = "common" - const val MEETING_CONTROL = "meetingControl" -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/core/SignConfig.kt b/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/core/SignConfig.kt deleted file mode 100644 index 6fc00c6..0000000 --- a/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/core/SignConfig.kt +++ /dev/null @@ -1,5 +0,0 @@ -package io.github.sgpublic.gradle.core - -object SignConfig { - const val NAME = "sign" -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/core/VersionGen.kt b/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/core/VersionGen.kt deleted file mode 100644 index 142457b..0000000 --- a/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/core/VersionGen.kt +++ /dev/null @@ -1,41 +0,0 @@ -package io.github.sgpublic.gradle.core - -import java.math.BigInteger -import java.security.MessageDigest -import java.text.SimpleDateFormat -import java.util.* - -object VersionGen { - val GIT_HEAD: String get() { - val lines = Runtime.getRuntime() - .exec("git rev-parse --short HEAD") - .inputStream.reader() - .readLines() - if (lines.isEmpty()) { - return TIME_MD5 - } - return lines[0] - } - - val DATED_VERSION: Int @Suppress("SimpleDateFormat") get() { - return Integer.parseInt(SimpleDateFormat("yyMMdd").format(Date())) - } - - val COMMIT_VERSION: Int get() { - val lines = Runtime.getRuntime() - .exec("git log -n 1 --pretty=format:%cd --date=format:%y%m%d") - .inputStream.reader() - .readLines() - if (lines.isEmpty()) { - return DATED_VERSION - } - return Integer.parseInt(lines[0]) - } - - val TIME_MD5: String get() { - val digest = MessageDigest.getInstance("MD5") - .digest(System.currentTimeMillis().toString().toByteArray()) - val pre = BigInteger(1, digest) - return pre.toString(16).padStart(32, '0').substring(8, 18) - } -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/util/ApkUtil.kt b/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/util/ApkUtil.kt deleted file mode 100644 index 20cf623..0000000 --- a/buildSrc/src/main/kotlin/io/github/sgpublic/gradle/util/ApkUtil.kt +++ /dev/null @@ -1,78 +0,0 @@ -package io.github.sgpublic.gradle.util - -import io.github.sgpublic.gradle.ApkPlugin -import io.github.sgpublic.gradle.core.BuildTypes -import net.dongliu.apk.parser.ApkFile -import org.gradle.internal.os.OperatingSystem -import java.io.File -import java.io.InputStream -import java.io.OutputStream - -object ApkUtil { - fun assembleAndLocate(name: String, outputFile: File, targetPath: String) { - if (!outputFile.exists() || outputFile.extension != "apk") { - return - } - val assemble = ApkPlugin.rootProject.file(targetPath) - if (assemble.exists()) { - assemble.deleteRecursively() - } - - val apkName = ApkPlugin.rootProject.name + ApkFile(outputFile).use { - it.apkMeta.let { meta -> - if (name.contains(BuildTypes.TYPE_RELEASE)) { - return@let " V${meta.versionName}(${meta.versionCode})" - } else if (name.contains(BuildTypes.TYPE_BETA)) { - return@let "_${meta.versionName}" - } else if (name.contains(BuildTypes.TYPE_ALPHA)) { - return@let "_${meta.versionName}" - } else { - return - } - } - } - - val copy = copy(outputFile, File(assemble, "$apkName.apk")) - outputFile.delete() - ApkPlugin.logger.info("Output apk file: $copy") - val currentOs = OperatingSystem.current() - val runtime = Runtime.getRuntime() - if (currentOs.isWindows) { - runtime.exec("explorer.exe /select, $copy") - } - } - - private fun copy(origin: File, target: File): File { - if (!origin.exists()) { - throw NoSuchFileException(origin) - } - if (target.exists() && !target.delete()) { - throw FileAlreadyExistsException(origin, target, "Tried to overwrite the destination, but failed to delete it.") - } - if (origin.isDirectory) { - throw IllegalStateException("Copy a directory not support!") - } - - if (target.parentFile != null) { - target.parentFile.mkdirs() - } - - copy(origin.inputStream(), target.outputStream()) - return target - } - - private val buffer = ByteArray(8 * 1024) - private fun copy(origin: InputStream, target: OutputStream): Long { - var bytesCopied = 0L - var bytes = origin.read(buffer) - while(bytes >= 0) { - target.write(buffer, 0, bytes) - bytesCopied += bytes - bytes = origin.read(buffer) - } - origin.close() - target.flush() - target.close() - return bytesCopied - } -} \ No newline at end of file diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/bilidl-version.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/bilidl-version.properties deleted file mode 100644 index 4b66423..0000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/bilidl-version.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=io.github.sgpublic.gradle.ApkPlugin \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index cac7c68..8e9bc65 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,3 +19,5 @@ android.useAndroidX=true android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official + +bilidl.version=3.6.0-alpha01 diff --git a/gradle/bilidl.versions.toml b/gradle/bilidl.versions.toml new file mode 100644 index 0000000..756be97 --- /dev/null +++ b/gradle/bilidl.versions.toml @@ -0,0 +1,141 @@ +[versions] +kotlin = "2.0.10" +agp = "8.5.2" +protobuf-plugin = "0.9.4" +lombok-plugin = "5.3.0" +github-release = "2.5.2" +android-assemble = "2.0.0" + +junit = "4.13.2" +androidx-test-ext = "1.2.1" +androidx-test-espresso = "3.6.1" +androidx-test-runner = "1.6.2" +androidx-test-rules = "1.6.1" + +androidx-core = "1.13.1" +androidx-appcompat = "1.7.0" +androidx-constraintlayout = "2.1.4" +androidx-swiperefreshlayout = "1.1.0" +androidx-navigation = "2.7.7" +androidx-room = "2.4.3" + +google-material = "1.12.0" +google-play-cronet = "18.1.0" + +bannerviewpager = "3.5.7" +sofia = "1.0.5" +multiwaveheader = "1.0.2" +xpopup = "2.9.1" +zxing = "3.5.0" +akdanmaku = "1.0.3" +geetest = "4.4.2.1" +exsp = "1.0.0-alpha04" +lombok = "1.18.24" +protobuf = "3.21.8" +grpc = "1.50.2" +cronet-fallback = "119.6045.31" +tomcat-annotations = "6.0.53" +glide = "4.14.2" +glide-transformations = "4.3.0" +exoplayer = "2.18.1" +aria = "3.8.16" +logback-android = "3.0.0" +slf4j-api = "2.0.13" +forest = "1.5.26" +gson = "2.10.1" +okhttp3 = "4.12.0" + + +[libraries] +junit = { group = "junit", name = "junit", version.ref = "junit" } +kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" } +androidx-test-ext = { group = "androidx.test.ext", name = "junit-ktx", version.ref = "androidx-test-ext" } +androidx-test-espresso = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidx-test-espresso" } +androidx-test-runner = { group = "androidx.test", name = "runner", version.ref = "androidx-test-runner" } +androidx-test-rules = { group = "androidx.test", name = "rules", version.ref = "androidx-test-rules" } + +androidx-core = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core" } +androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" } +androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "androidx-constraintlayout" } +androidx-swiperefreshlayout = { group = "androidx.swiperefreshlayout", name = "swiperefreshlayout", version.ref = "androidx-swiperefreshlayout" } +androidx-navigation = { group = "androidx.navigation", name = "navigation-fragment-ktx", version.ref = "androidx-navigation" } + +google-material = { group = "com.google.android.material", name = "material", version.ref = "google-material" } +google-play-cronet = { group = "com.google.android.gms", name = "play-services-cronet", version.ref = "google-play-cronet" } + +# https://github.com/zhpanvip/BannerViewPager +bannerviewpager = { group = "com.github.zhpanvip", name = "BannerViewPager", version.ref = "bannerviewpager" } +# https://github.com/yanzhenjie/Sofia +sofia = { group = "com.yanzhenjie", name = "sofia", version.ref = "sofia" } +# https://github.com/sgpublic-forks/MultiWaveHeader +multiwaveheader = { group = "io.github.sgpublic", name = "MultiWaveHeader", version.ref = "multiwaveheader" } +# https://github.com/li-xiaojun/XPopup +xpopup = { group = "com.github.li-xiaojun", name = "XPopup", version.ref = "xpopup" } +# https://github.com/zxing/zxing +zxing = { group = "com.google.zxing", name = "core", version.ref = "zxing" } +# https://github.com/KwaiAppTeam/AkDanmaku +akdanmaku = { group = "com.kuaishou", name = "akdanmaku", version.ref = "akdanmaku" } +# https://docs.geetest.com/sensebot/deploy/client/android +geetest = { group = "com.geetest.sensebot", name = "sensebot", version.ref = "geetest" } + +# https://github.com/sgpublic/ExSharedPreference +exsp-runtime = { group = "io.github.sgpublic", name = "exsp-runtime", version.ref = "exsp" } +exsp-compiler = { group = "io.github.sgpublic", name = "exsp-compiler", version.ref = "exsp" } + +lombok = { group = "org.projectlombok", name = "lombok", version.ref = "lombok" } + +androidx-room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "androidx-room" } +androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "androidx-room" } + +# https://github.com/google/protobuf-gradle-plugin +protobuf = { group = "com.google.protobuf", name = "protobuf-java", version.ref = "protobuf" } +grpc-cronet = { group = "io.grpc", name = "grpc-cronet", version.ref = "grpc" } +grpc-android = { group = "io.grpc", name = "grpc-android", version.ref = "grpc" } +grpc-protobuf = { group = "io.grpc", name = "grpc-protobuf", version.ref = "grpc" } +grpc-stub = { group = "io.grpc", name = "grpc-stub", version.ref = "grpc" } +cronet-fallback = { group = "org.chromium.net", name = "cronet-fallback", version.ref = "cronet-fallback" } +tomcat-annotations = { group = "org.apache.tomcat", name = "annotations-api", version.ref = "tomcat-annotations" } + +# https://github.com/bumptech/glide +glide = { group = "com.github.bumptech.glide", name = "glide", version.ref = "glide" } +glide-compiler = { group = "com.github.bumptech.glide", name = "compiler", version.ref = "glide" } +glide-transformations = { group = "jp.wasabeef", name = "glide-transformations", version.ref = "glide-transformations" } + +# https://github.com/google/ExoPlayer +exoplayer-core = { group = "com.google.android.exoplayer", name = "exoplayer-core", version.ref = "exoplayer" } +exoplayer-dash = { group = "com.google.android.exoplayer", name = "exoplayer-dash", version.ref = "exoplayer" } +exoplayer-ui = { group = "com.google.android.exoplayer", name = "exoplayer-ui", version.ref = "exoplayer" } + +# https://github.com/AriaLyy/Aria +aria-core = { group = "me.laoyuyu.aria", name = "core", version.ref = "aria" } +aria-compiler = { group = "me.laoyuyu.aria", name = "compiler", version.ref = "aria" } + +# https://github.com/tony19/logback-android +logback-android = { group = "com.github.tony19", name = "logback-android", version.ref = "logback-android" } +slf4j-api = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j-api" } + +# https://github.com/dromara/forest +forest = { group = "com.dtflys.forest", name = "forest-core", version.ref = "forest" } +gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" } +okhttp3 = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp3" } + + +[plugins] +android-library = { id = "com.android.library", version.ref = "agp" } +android-application = { id = "com.android.application", version.ref = "agp" } + +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } +kotlin-plugin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +kotlin-plugin-lombok = { id = "org.jetbrains.kotlin.plugin.lombok", version.ref = "kotlin" } +kotlin-plugin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" } + +protobuf = { id = "com.google.protobuf", version.ref = "protobuf-plugin" } +lombok = { id = "io.freefair.lombok", version.ref = "lombok-plugin" } +github-release = { id = "com.github.breadmoirai.github-release", version.ref = "github-release" } +android-assemble = { id = "io.github.sgpublic.android-assemble", version.ref = "android-assemble" } + + + +[bundles] + diff --git a/settings.gradle.kts b/settings.gradle.kts index dfe6e33..e0d873a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -18,6 +18,12 @@ dependencyResolutionManagement { mavenLocal() jcenter() } + + versionCatalogs { + val bilidl by creating { + from(files(File(rootDir, "./gradle/bilidl.versions.toml"))) + } + } } include(":app")