提交 8a806bc0 编写于 作者: C cgspine

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

上级 a538359e
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')
}
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"))
}
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')
}
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"))
}
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')
}
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"))
}
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import com.qmuiteam.plugin.Dep
buildscript {
ext.kotlin_version = '1.5.21'
repositories {
mavenLocal()
google()
mavenCentral()
google()
mavenLocal()
}
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'
classpath("com.android.tools.build:gradle:7.0.3")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31")
}
}
subprojects { project ->
group = GROUP
plugins {
id("qmui-dep")
}
subprojects {
group = Dep.QMUI.group
}
allprojects {
repositories {
mavenCentral()
mavenLocal()
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'
}
// 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'
// }
}
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"
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)
}
......@@ -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
apply plugin: 'java-library'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
import com.qmuiteam.plugin.Dep
plugins {
`java-library`
}
java {
sourceCompatibility = Dep.javaVersion
targetCompatibility = Dep.javaVersion
}
/build
*.iml
.DS_Store
.gradle
.gradletasknamecache
.idea
\ No newline at end of file
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
}
\ No newline at end of file
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"
}
}
\ No newline at end of file
package com.qmuiteam.plugin
import org.gradle.api.Plugin
import org.gradle.api.Project
class QMUIDepPlugin: Plugin<Project>{
override fun apply(project: Project) {
}
}
\ No newline at end of file
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')
}
\ No newline at end of file
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"))
}
\ No newline at end of file
<?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>
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
}
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()