OSDN Git Service

6940dd8506f62ac11232b9fe8f9724d7f27d55e2
[android-x86/packages-apps-Taskbar.git] / app / build.gradle
1 plugins {
2     id "com.diffplug.spotless" version "5.15.2"
3 }
4 apply from: '../dependencies.gradle'
5 apply plugin: 'com.android.application'
6 apply plugin: 'kotlin-android'
7 apply plugin: 'jacoco'
8
9 repositories {
10     google()
11     maven { url "https://jitpack.io" }
12 }
13
14 spotless {
15     kotlin {
16         target '**/*.kt'
17         ktlint()userData(['max_line_length': '100'])
18     }
19 }
20
21 android {
22     compileSdkVersion COMPILE_SDK_VERSION
23     buildToolsVersion BUILD_TOOLS_VERSION
24
25     defaultConfig {
26         applicationId "com.farmerbb.taskbar"
27
28         minSdkVersion MIN_SDK_VERSION
29         targetSdkVersion TARGET_SDK_VERSION
30         versionCode VERSION_CODE
31         versionName VERSION_NAME
32
33         resConfigs "en", "es", "ja", "ru", "de", "zh-rCN", "tr", "nl", "pl"
34         vectorDrawables.generatedDensities = []
35
36         buildConfigField "String", "BASE_APPLICATION_ID", "\"com.farmerbb.taskbar\""
37         buildConfigField "String", "PAID_APPLICATION_ID", "\"com.farmerbb.taskbar.paid\""
38         buildConfigField "String", "SUPPORT_APPLICATION_ID", "\"com.farmerbb.taskbar.support\""
39         buildConfigField "String", "ANDROIDX86_APPLICATION_ID", "\"com.farmerbb.taskbar.androidx86\""
40
41         buildConfigField "long", "TIMESTAMP", "${System.currentTimeMillis()}L"
42     }
43
44     compileOptions {
45         sourceCompatibility JavaVersion.VERSION_1_8
46         targetCompatibility JavaVersion.VERSION_1_8
47     }
48
49     kotlinOptions {
50         jvmTarget = '1.8'
51     }
52
53     signingConfigs {
54         release {
55             if(System.getenv("KSTOREFILE") != null)
56                 storeFile file(System.getenv("KSTOREFILE"))
57
58             storePassword System.getenv("KSTOREPWD")
59             keyAlias System.getenv("KEYALIAS")
60             keyPassword System.getenv("KEYPWD")
61         }
62     }
63
64     buildTypes {
65         debug {
66             applicationIdSuffix ".debug"
67             manifestPlaceholders = [appName: "@string/tb_app_name_debug"]
68         }
69
70         release {
71             minifyEnabled true
72             shrinkResources true
73             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
74             signingConfig signingConfigs.release
75             manifestPlaceholders = [appName: "@string/tb_app_name"]
76
77             applicationVariants.all { variant ->
78                 variant.outputs.all {
79                     outputFileName = "${project.parent.name}-${defaultConfig.versionName}.apk"
80                 }
81             }
82         }
83
84         jacoco {
85             initWith buildTypes.debug
86             testCoverageEnabled true
87         }
88     }
89
90     flavorDimensions "default"
91
92     productFlavors {
93         paid { applicationId "com.farmerbb.taskbar.paid" }
94         free { applicationId "com.farmerbb.taskbar" }
95     }
96
97     sourceSets {
98         main {
99             java { srcDirs('src/main/java', 'src/playstore/java', 'src/nonlib/java', "src/compat-$COMPILE_SDK_VERSION/java") }
100             res { srcDirs('src/main/res', 'src/playstore/res', 'src/nonlib/res') }
101             manifest.srcFile 'src/playstore/AndroidManifest.xml'
102         }
103     }
104     
105     lintOptions {
106         abortOnError false
107     }
108
109     testOptions {
110         unitTests {
111             all {
112                 testLogging {
113                     events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
114
115                     outputs.upToDateWhen {
116                         false
117                     }
118
119                     showStandardStreams = false
120                     exceptionFormat = 'full'
121                 }
122
123                 //noinspection GrDeprecatedAPIUsage
124                 jacoco {
125                     includeNoLocationClasses = true
126                     excludes = ['jdk.internal.*']
127                 }
128             }
129             
130             includeAndroidResources = true
131         }
132     }
133 }
134
135 dependencies {
136     implementation "androidx.legacy:legacy-support-v4:$SUPPORT_V4_VERSION"
137     implementation "androidx.appcompat:appcompat:$APPCOMPAT_VERSION"
138     //noinspection GradleDependency
139     implementation "androidx.browser:browser:$BROWSER_VERSION"
140     implementation "com.google.android.material:material:$MATERIAL_VERSION"
141     //noinspection GradleDependency
142     implementation 'com.mikepenz:iconics-core:3.2.5'
143     implementation 'com.mikepenz:foundation-icons-typeface:3.0.0.5'
144     implementation 'moe.banana:toast-compat:1.0.5'
145     implementation group:'com.twofortyfouram', name:'android-plugin-api-for-locale', version:'[1.0.2,2.0['
146     debugImplementation "org.lsposed.hiddenapibypass:hiddenapibypass:$HIDDEN_API_BYPASS_VERSION"
147     releaseImplementation "org.lsposed.hiddenapibypass:hiddenapibypass:$HIDDEN_API_BYPASS_VERSION"
148
149     testImplementation "com.google.truth:truth:1.1.3"
150     testImplementation 'junit:junit:4.13.2'
151     testImplementation 'androidx.test:core:1.4.0'
152     testImplementation "org.robolectric:robolectric:4.6.1"
153     testImplementation "org.powermock:powermock-module-junit4:$POWERMOCK_VERSION"
154     testImplementation "org.powermock:powermock-module-junit4-rule:$POWERMOCK_VERSION"
155     testImplementation "org.powermock:powermock-api-mockito2:$POWERMOCK_VERSION"
156     testImplementation "org.powermock:powermock-classloading-xstream:$POWERMOCK_VERSION"
157     testImplementation 'org.apache.commons:commons-lang3:3.12.0'
158 }
159
160 task jacocoTestReport(type: JacocoReport, dependsOn: ['testFreeJacocoUnitTest']) {
161     reports {
162         xml.enabled = true
163         html.enabled = true
164         csv.enabled = true
165     }
166
167     def fileFilter = [
168             '**/R.class',
169             '**/R$*.class',
170             '**/BuildConfig.class'
171     ]
172
173     def jacocoTree = fileTree(dir: "$buildDir/intermediates/javac/freeJacoco/classes", excludes: fileFilter)
174     def mainSrc = "${project.projectDir}/src/main/java"
175
176     sourceDirectories.from = [mainSrc]
177     classDirectories.from = [jacocoTree]
178     executionData.from = "$buildDir/jacoco/testFreeJacocoUnitTest.exec"
179
180     doLast {
181         println "Test report link: file://$buildDir/reports/jacoco/jacocoTestReport/html/index.html"
182     }
183 }