feat: 1. update gradle to AGP7; 2.use kts for gradle build.

This commit is contained in:
cgspine
2021-12-02 13:13:40 +08:00
parent a538359ed0
commit 8a806bc00f
27 changed files with 430 additions and 403 deletions
-16
View File
@@ -1,16 +0,0 @@
apply plugin: 'java-library'
version = QMUI_ARCH_VERSION
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
// deploy
File deployConfig = rootProject.file('gradle/deploy.properties')
if (deployConfig.exists()) {
apply from: rootProject.file('gradle/deploy.gradle')
}
+18
View File
@@ -0,0 +1,18 @@
import com.qmuiteam.plugin.Dep
plugins {
`java-library`
kotlin("jvm")
}
version = Dep.QMUI.archVer
java {
sourceCompatibility = Dep.javaVersion
targetCompatibility = Dep.javaVersion
}
// deploy
if(rootProject.file("gradle/deploy.properties").exists()){
apply(from = rootProject.file("gradle/deploy.gradle"))
}
-20
View File
@@ -1,20 +0,0 @@
apply plugin: 'java-library'
version = QMUI_ARCH_VERSION
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':arch-annotation')
implementation 'com.squareup:javapoet:1.10.0'
implementation 'com.google.auto.service:auto-service:1.0-rc2'
annotationProcessor 'com.google.auto.service:auto-service:1.0-rc2'
}
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
// deploy
File deployConfig = rootProject.file('gradle/deploy.properties')
if (deployConfig.exists()) {
apply from: rootProject.file('gradle/deploy.gradle')
}
+23
View File
@@ -0,0 +1,23 @@
import com.qmuiteam.plugin.Dep
plugins {
`java-library`
}
version = Dep.QMUI.archVer
dependencies {
implementation(project(":arch-annotation"))
implementation(Dep.CodeGen.javapoet)
annotationProcessor(Dep.CodeGen.autoService)
}
java {
sourceCompatibility = Dep.javaVersion
targetCompatibility = Dep.javaVersion
}
// deploy
if(rootProject.file("gradle/deploy.properties").exists()){
apply(from = rootProject.file("gradle/deploy.gradle"))
}
-38
View File
@@ -1,38 +0,0 @@
apply plugin: 'com.android.library'
version = QMUI_ARCH_VERSION
android {
compileSdkVersion parent.ext.compileSdkVersion
lintOptions {
abortOnError false
}
defaultConfig {
minSdkVersion parent.ext.minSdkVersion
targetSdkVersion parent.ext.targetSdkVersion
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
api "androidx.appcompat:appcompat:$appcompatVersion"
api "androidx.fragment:fragment:1.3.6"
api project(':arch-annotation')
compileOnly project(':qmui')
testImplementation "junit:junit:$junitVersion"
}
// deploy
File deployConfig = rootProject.file('gradle/deploy.properties')
if (deployConfig.exists()) {
apply from: rootProject.file('gradle/deploy.gradle')
}
+44
View File
@@ -0,0 +1,44 @@
import com.qmuiteam.plugin.Dep
plugins {
id("com.android.library")
kotlin("android")
}
version = Dep.QMUI.archVer
android {
compileSdk = Dep.compileSdk
defaultConfig {
minSdk = Dep.minSdk
targetSdk = Dep.targetSdk
}
buildTypes {
getByName("release"){
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = Dep.javaVersion
targetCompatibility = Dep.javaVersion
}
kotlinOptions {
jvmTarget = Dep.kotlinJvmTarget
}
}
dependencies {
api(Dep.AndroidX.appcompat)
api(Dep.AndroidX.fragment)
api(project(":arch-annotation"))
compileOnly(project(":qmui"))
}
// deploy
if(rootProject.file("gradle/deploy.properties").exists()){
apply(from = rootProject.file("gradle/deploy.gradle"))
}
-41
View File
@@ -1,41 +0,0 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.5.21'
repositories {
mavenLocal()
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// classpath 'com.qmuiteam:skin-maker-plugin:0.0.1'
}
}
subprojects { project ->
group = GROUP
}
allprojects {
repositories {
mavenCentral()
mavenLocal()
google()
}
ext {
minSdkVersion = 21
targetSdkVersion = 30
compileSdkVersion = 30
coreVersion='1.6.0'
appcompatVersion= '1.3.1'
materialVersion='1.4.0'
annotationVersion='1.2.0'
butterknifeVersion = '10.1.0'
constraintLayoutVersion = "2.1.0"
mmkvVersion = '1.0.23'
junitVersion='4.13.2'
}
}
+43
View File
@@ -0,0 +1,43 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import com.qmuiteam.plugin.Dep
buildscript {
repositories {
mavenCentral()
google()
mavenLocal()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.3")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31")
}
}
plugins {
id("qmui-dep")
}
subprojects {
group = Dep.QMUI.group
}
allprojects {
repositories {
mavenCentral()
google()
mavenLocal()
}
// ext {
// minSdkVersion = 21
// targetSdkVersion = 30
// compileSdkVersion = 30
// coreVersion='1.6.0'
// appcompatVersion= '1.3.1'
// materialVersion='1.4.0'
// annotationVersion='1.2.0'
// butterknifeVersion = '10.1.0'
// constraintLayoutVersion = "2.1.0"
// mmkvVersion = '1.0.23'
// junitVersion='4.13.2'
// }
}
-12
View File
@@ -1,12 +0,0 @@
apply plugin: 'java-library'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':lib')
implementation 'com.squareup:javapoet:1.10.0'
implementation 'com.google.auto.service:auto-service:1.0-rc2'
annotationProcessor 'com.google.auto.service:auto-service:1.0-rc2'
}
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
+15
View File
@@ -0,0 +1,15 @@
import com.qmuiteam.plugin.Dep
plugins {
`java-library`
}
java {
sourceCompatibility = Dep.javaVersion
targetCompatibility = Dep.javaVersion
}
dependencies {
implementation(project(":lib"))
implementation(Dep.CodeGen.javapoet)
annotationProcessor(Dep.CodeGen.autoService)
}
+1 -1
View File
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
-8
View File
@@ -1,8 +0,0 @@
apply plugin: 'java-library'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
+10
View File
@@ -0,0 +1,10 @@
import com.qmuiteam.plugin.Dep
plugins {
`java-library`
}
java {
sourceCompatibility = Dep.javaVersion
targetCompatibility = Dep.javaVersion
}
+6
View File
@@ -0,0 +1,6 @@
/build
*.iml
.DS_Store
.gradle
.gradletasknamecache
.idea
+33
View File
@@ -0,0 +1,33 @@
plugins {
`java-gradle-plugin`
idea
kotlin("jvm") version "1.5.31"
}
group = "com.qmuiteam.qmui.plugin"
version = "0.0.1"
gradlePlugin {
plugins {
create("qmui-dep"){
id = "qmui-dep"
implementationClass = "com.qmuiteam.plugin.QMUIDepPlugin"
}
}
}
repositories {
mavenCentral()
google()
}
dependencies {
api(gradleApi())
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
@@ -0,0 +1,45 @@
package com.qmuiteam.plugin
import org.gradle.api.JavaVersion
object Dep {
val javaVersion = JavaVersion.VERSION_11
const val kotlinJvmTarget = "11"
const val kotlinVer = "1.5.31"
const val compileSdk = 30
const val minSdk = 21
const val targetSdk = 30
object QMUI {
const val group = "com.qmuiteam"
const val qmuiVer = "2.0.1"
const val archVer = "2.0.1"
const val typeVer = "0.0.14"
}
object AndroidX {
val appcompat = "androidx.appcompat:appcompat:1.4.0"
val annotation = "androidx.annotation:annotation:1.3.0"
val coreKtx = "androidx.core:core-ktx:1.7.1"
val constraintLayout = "androidx.constraintlayout:constraintlayout:2.1.2"
val swiperefreshlayout = "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
val fragment = "androidx.fragment:fragment:1.4.0"
}
object MaterialDesign {
const val material = "com.google.android.material:material:1.4.0"
}
object CodeGen {
const val javapoet = "com.squareup:javapoet:1.13.0"
const val autoService = "com.google.auto.service:auto-service:1.0-rc2"
}
object ButterKnife {
private const val ver = "10.1.0"
const val butterknife = "com.jakewharton:butterknife:$ver"
const val compiler = "com.jakewharton:butterknife-compiler:$ver"
}
}
@@ -0,0 +1,10 @@
package com.qmuiteam.plugin
import org.gradle.api.Plugin
import org.gradle.api.Project
class QMUIDepPlugin: Plugin<Project>{
override fun apply(project: Project) {
}
}
-63
View File
@@ -1,63 +0,0 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
version = QMUI_VERSION
//noinspection GroovyMissingReturnStatement
android {
compileSdkVersion parent.ext.compileSdkVersion
lintOptions {
abortOnError false
}
defaultConfig {
minSdkVersion parent.ext.minSdkVersion
targetSdkVersion parent.ext.targetSdkVersion
// vectorDrawables.useSupportLibrary = true // 与 com.android.support:support-vector-drawable 搭配使用,禁掉 Android Studio 自动生成 png 的功能
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// libraryVariants.all{ variant ->
// variant.mergeResources.doLast {
// replaceTheme variant
// }
// }
// testVariants.all { variant ->
// variant.mergeResources.doLast {
// replaceTheme variant
// }
// }
}
//def replaceTheme(variant){
// println "dirName::${variant.dirName}"
// def output = "AppConfigTheme"
//
// File valuesFile = file("${buildDir}/intermediates/res/merged/${variant.dirName}/values/values.xml")
// String content = valuesFile.getText('UTF-8')
// content = content.replaceAll(/\$\{QMUI_PARENT_THEME\}/, output)
// valuesFile.write(content, 'UTF-8')
//}
dependencies {
api "androidx.appcompat:appcompat:$appcompatVersion"
api "androidx.annotation:annotation:$annotationVersion"
api "com.google.android.material:material:$materialVersion"
api "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"
//test
testImplementation "junit:junit:$junitVersion"
api 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
// deploy
File deployConfig = rootProject.file('gradle/deploy.properties')
if (deployConfig.exists()) {
apply from: rootProject.file('gradle/deploy.gradle')
}
+47
View File
@@ -0,0 +1,47 @@
import com.qmuiteam.plugin.Dep
plugins {
id("com.android.library")
kotlin("android")
}
version = Dep.QMUI.qmuiVer
android {
compileSdk = Dep.compileSdk
defaultConfig {
minSdk = Dep.minSdk
targetSdk = Dep.targetSdk
}
buildTypes {
getByName("release"){
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = Dep.javaVersion
targetCompatibility = Dep.javaVersion
}
kotlinOptions {
jvmTarget = Dep.kotlinJvmTarget
}
}
dependencies {
api(Dep.AndroidX.appcompat)
api(Dep.AndroidX.annotation)
api(Dep.AndroidX.constraintLayout)
api(Dep.AndroidX.swiperefreshlayout)
api(Dep.MaterialDesign.material)
}
// deploy
if(rootProject.file("gradle/deploy.properties").exists()){
apply(from = rootProject.file("gradle/deploy.gradle"))
}
-28
View File
@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Tencent is pleased to support the open source community by making QMUI_Android available.
Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
http://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing, software distributed under the License is
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific language governing permissions and
limitations under the License.
-->
<lint>
<!-- Disable the given check in this project -->
<issue id="HardcodedText" severity="ignore"/>
<issue id="SmallSp" severity="ignore"/>
<issue id="IconMissingDensityFolder" severity="ignore"/>
<issue id="RtlHardcoded" severity="ignore"/>
<issue id="Deprecated" severity="warning">
<ignore regexp="singleLine"/>
</issue>
<issue id="RtlSymmetry" severity="ignore"/>
</lint>
-93
View File
@@ -1,93 +0,0 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
def getVersion() {
def gitVersion
try {
def cmd = 'git rev-list HEAD --count'
gitVersion = cmd.execute().text.trim().toInteger()
} catch (Exception e) {
gitVersion = 1
}
return gitVersion
}
def gitVersion = getVersion()
def javaVersion = JavaVersion.VERSION_1_8
android {
signingConfigs {
Properties properties = new Properties()
File propFile = project.file('release.properties')
if (propFile.exists()) {
properties.load(propFile.newDataInputStream())
}
release {
keyAlias properties.getProperty("RELEASE_KEY_ALIAS")
keyPassword properties.getProperty("RELEASE_KEY_PASSWORD")
storeFile file('qmuidemo.keystore')
storePassword properties.getProperty("RELEASE_STORE_PASSWORD")
v2SigningEnabled false
}
}
compileSdkVersion parent.ext.compileSdkVersion
// for butterknife, see https://github.com/JakeWharton/butterknife/blob/master/CHANGELOG.md#version-900-rc2-2018-11-19
compileOptions {
sourceCompatibility javaVersion
targetCompatibility javaVersion
}
defaultConfig {
applicationId "com.qmuiteam.qmuidemo"
minSdkVersion parent.ext.minSdkVersion
targetSdkVersion parent.ext.targetSdkVersion
versionCode gitVersion
versionName QMUI_VERSION
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
// 避免 lint 检测出错时停止构建
lintOptions {
abortOnError false
}
}
// 加@aar与不加@aar的区别:
// http://stackoverflow.com/questions/30157575/why-should-i-include-a-gradle-dependency-as-aar
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:$appcompatVersion"
implementation "androidx.annotation:annotation:$annotationVersion"
implementation "com.google.android.material:material:$materialVersion"
implementation "com.jakewharton:butterknife:$butterknifeVersion"
kapt "com.jakewharton:butterknife-compiler:$butterknifeVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// implementation 'com.qmuiteam:arch:2.0.1'
// implementation 'com.qmuiteam:qmui:2.0.1'
implementation project(':lib')
implementation project(':qmui')
implementation project(':arch')
implementation project(':type')
kapt project(':compiler')
kapt project(':arch-compiler')
//leak
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
//test
testImplementation 'junit:junit:4.13.2'
// androidTestImplementation 'com.android.support.test:runner:1.0.2'
// androidTestImplementation 'com.android.support.test:rules:1.0.2' // Set this dependency to use JUnit 4 rules
// androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' // Set this dependency to build and run Espresso tests
}
+75
View File
@@ -0,0 +1,75 @@
import com.qmuiteam.plugin.Dep
import java.io.ByteArrayOutputStream
import java.util.*
plugins {
id("com.android.application")
kotlin("android")
kotlin("kapt")
}
fun runCommand(project: Project, command: String): String {
val stdout = ByteArrayOutputStream()
project.exec {
commandLine = command.split(" ")
standardOutput = stdout
}
return stdout.toString().trim()
}
val gitVersion = runCommand(project, "git rev-list HEAD --count").toIntOrNull() ?: 1
android {
signingConfigs {
val properties = Properties()
val propFile = project.file("release.properties")
if (propFile.exists()) {
properties.load(propFile.inputStream())
}
getByName("release"){
keyAlias = properties.getProperty("RELEASE_KEY_ALIAS")
keyPassword = properties.getProperty("RELEASE_KEY_PASSWORD")
storeFile = file("qmuidemo.keystore")
storePassword = properties.getProperty("RELEASE_STORE_PASSWORD")
enableV2Signing = false
}
}
compileSdk = Dep.compileSdk
compileOptions {
sourceCompatibility = Dep.javaVersion
targetCompatibility = Dep.javaVersion
}
defaultConfig {
applicationId = "com.qmuiteam.qmuidemo"
minSdk = Dep.minSdk
targetSdk = Dep.targetSdk
versionCode = gitVersion
versionName = Dep.QMUI.qmuiVer
}
buildTypes {
getByName("release") {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
signingConfig = signingConfigs.getByName("release")
}
}
}
dependencies {
implementation(Dep.AndroidX.appcompat)
implementation(Dep.AndroidX.annotation)
implementation(Dep.MaterialDesign.material)
implementation(Dep.ButterKnife.butterknife)
kapt(Dep.ButterKnife.compiler)
implementation(project(":lib"))
implementation(project(":qmui"))
implementation(project(":arch"))
implementation(project(":type"))
kapt(project(":compiler"))
kapt(project(":arch-compiler"))
}
-3
View File
@@ -1,3 +0,0 @@
include ':qmuidemo', ':qmui', ':lib', ':compiler', ':arch', ':arch-compiler',
':arch-annotation'
include ':type'
+16
View File
@@ -0,0 +1,16 @@
include(":qmuidemo")
include(":qmui")
include(":lib")
include(":compiler")
include(":arch")
include(":arch-compiler")
include(":arch-annotation")
include(":type")
includeBuild("./plugin")
pluginManagement {
repositories {
mavenCentral()
}
}
-37
View File
@@ -1,37 +0,0 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
version = QMUI_TYPE_VERSION
android {
compileSdkVersion parent.ext.compileSdkVersion
lintOptions {
abortOnError false
}
defaultConfig {
minSdkVersion parent.ext.minSdkVersion
targetSdkVersion parent.ext.targetSdkVersion
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
api "androidx.annotation:annotation:$annotationVersion"
api "androidx.core:core-ktx:$appcompatVersion"
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
// deploy
File deployConfig = rootProject.file('gradle/deploy.properties')
if (deployConfig.exists()) {
apply from: rootProject.file('gradle/deploy.gradle')
}
+44
View File
@@ -0,0 +1,44 @@
import com.qmuiteam.plugin.Dep
plugins {
id("com.android.library")
kotlin("android")
}
version = Dep.QMUI.typeVer
android {
compileSdk = Dep.compileSdk
defaultConfig {
minSdk = Dep.minSdk
targetSdk = Dep.targetSdk
}
buildTypes {
getByName("release"){
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = Dep.javaVersion
targetCompatibility = Dep.javaVersion
}
kotlinOptions {
jvmTarget = Dep.kotlinJvmTarget
}
}
dependencies {
api(Dep.AndroidX.annotation)
api(Dep.AndroidX.coreKtx)
}
// deploy
if(rootProject.file("gradle/deploy.properties").exists()){
apply(from = rootProject.file("gradle/deploy.gradle"))
}
-43
View File
@@ -1,43 +0,0 @@
# QMUI 2.x 重要变更
## 概述
1. 升级到 Androidx
2. minSdkVersion 升级到 API 19
3. 提供换肤(Dark Mode)支持
4. `QMUI.Compat` 主题改名为 `QMUI`,并移除旧的 `QMUI` 主题
5. 移除 lint 模块,不再维护
## 组件变更
### QMUITopBar
- 使用 `QMUIQQFaceView` 来承载标题和副标题
- 更改父类为 `QMUIRelativeLayout`,使用 QMUILayout 的分割线实现,移除配置项:`qmui_topbar_need_separator`,`qmui_topbar_separator_height`, `qmui_topbar_separator_color`。
- 移除配置项 `qmui_topbar_bg_color`, 使用官方实现`android:background` 替代。
### QMUIQQFaceView
- 可以通过 `QMUIQQFaceCompiler.setDefaultQQFaceManager()` 设置 QQFaceManager, App 不再需要定义一个子类。
### QMUITabSegment
- 完全重构,与旧版本完全不兼容
### QMUIPopup
- 完全重构,与旧版本完全不兼容
### QMUIEmptyView
- 父类更改为 ConstraintLayout
- theme 中 添加间距、颜色、字号
### QMUIGroupListView
- 配置项改名:
- qmui_commonList_titleColor -> qmui_common_list_title_color
- qmui_commonList_detailColor -> qmui_common_list_detail_color
- QMUICommonListItemView 父类更换为 ConstraintLayout, 布局重写
- 移除 separatorStyle 的配置,使用 QMUILayout 相关的设置