apply plugin: 'com.android.application' android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "org.fox.epube" minSdkVersion 26 //noinspection ExpiredTargetSdkVersion targetSdkVersion 33 compileSdk 35 versionCode getGitVersionCode() versionName getVersion() buildConfigField "String", "EPUBE_BASE_URL", "\"https://epube-dev.fakecake.org\"" manifestPlaceholders = [ appIcon: "@mipmap/ic_launcher" ] } signingConfigs { signed { if (project.hasProperty("SIGNING_STORE_FILE")) { storeFile file(SIGNING_STORE_FILE) storePassword SIGNING_STORE_PASSWORD keyAlias SIGNING_KEY_ALIAS keyPassword SIGNING_KEY_PASSWORD } } } lintOptions { abortOnError false checkReleaseBuilds false disable 'MissingTranslation' enable 'SuspiciousIndentation' } buildTypes { debug { minifyEnabled false versionNameSuffix "-debug" applicationIdSuffix ".debug" resValue "string", "app_name", "The Epube (debug)" manifestPlaceholders = [ appIcon: "@mipmap/ic_launcher_variant" ] } release { minifyEnabled false versionNameSuffix "-unsigned" proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt' } signed { minifyEnabled false versionNameSuffix "-signed" proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' signingConfig signingConfigs.signed buildConfigField "String", "EPUBE_BASE_URL", "\"https://books.fakecake.org\"" matchingFallbacks = ['release'] } branch { minifyEnabled false versionNameSuffix "-signed-branch" proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' signingConfig signingConfigs.signed applicationIdSuffix ".branch" resValue "string", "app_name", "The Epube (dev)" manifestPlaceholders = [ appIcon: "@mipmap/ic_launcher_variant" ] matchingFallbacks = ['release'] } } namespace 'org.fox.epube' buildFeatures { buildConfig true } } def getGitVersionCode() { return new Date(getGitTimestamp()).format('yyyyMMdd').toInteger() } def getGitTimestampFormatted() { return new Date(getGitTimestamp()).format('YY.MM') } def getGitTimestamp() { // gitlab CI iso-8601 timestamp if (System.getenv("CI_COMMIT_TIMESTAMP")) { return Date.parse("yyyy-MM-dd'T'HH:mm:ssXXX", System.getenv("CI_COMMIT_TIMESTAMP")).getTime(); } // try to get version from git repo in current dir try { def stdout = new ByteArrayOutputStream() exec { commandLine 'git', '--no-pager', 'log', '--pretty=%ct', '-n1', 'HEAD' standardOutput = stdout } return stdout.toString().trim().toLong() * 1000; } catch (ignored) { return 0; } } def getGitCommitHash() { // gitlab CI if (System.getenv("CI_COMMIT_SHORT_SHA")) return System.getenv("CI_COMMIT_SHORT_SHA"); // try to get version from git repo in current dir try { def stdout = new ByteArrayOutputStream() exec { commandLine 'git', '--no-pager', 'log', '--pretty=%h', '-n1', 'HEAD' standardOutput = stdout } return stdout.toString().trim() } catch (ignored) { return 'UNKNOWN'; } } def getVersion() { return getGitTimestampFormatted() + '-' + getGitCommitHash(); } dependencies { // https://issuetracker.google.com/issues/272973596 implementation platform("org.jetbrains.kotlin:kotlin-bom:1.8.22") implementation 'androidx.appcompat:appcompat:1.7.1' implementation 'androidx.appcompat:appcompat-resources:1.7.1' implementation 'com.google.android.material:material:1.13.0' implementation 'androidx.webkit:webkit:1.15.0' } java { toolchain { languageVersion = JavaLanguageVersion.of(17) } }