Skip to content

Commit

Permalink
feat: compat gradle 7.xx
Browse files Browse the repository at this point in the history
  • Loading branch information
chaojiong1zhang20230913 committed Sep 15, 2022
1 parent c6bd887 commit d37af1f
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 17 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ android {
openLog = true
//剔除模块不打成 aar
excludeModule = [":xxx"]
dexMergeIncremental = true
}
}

Expand Down
9 changes: 4 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ apply from: "config.gradle"
buildscript {
repositories {
// mavenLocal {url "${rootDir.absolutePath}/repos"}
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
mavenCentral()
google()
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20'
classpath 'com.alibaba:arouter-register:1.0.2'
//
Expand Down
13 changes: 8 additions & 5 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ plugins {
dependencies {
implementation gradleApi()
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.20"
implementation 'com.android.tools.build:gradle:4.0.2'
implementation 'com.android.tools.build:gradle:7.2.2'
compile 'com.android.tools.ddms:ddmlib:30.0.2'
compile 'com.google.code.gson:gson:2.8.5'

}

repositories {
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
google()
mavenCentral()
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/central' }
// google()
// mavenCentral()
gradlePluginPortal()

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ class RocketXBuildListener(
stringBuilder.append("构建开始时间:" + dateFormat.format(Calendar.getInstance().time) + "\n")
}

override fun buildStarted(gradle: Gradle) {
fun buildStarted(gradle: Gradle) {
}


override fun settingsEvaluated(settings: Settings) {

}

override fun projectsLoaded(gradle: Gradle) {
Expand Down
21 changes: 17 additions & 4 deletions buildSrc/src/main/kotlin/plugin/utils/InstallApkByAdb.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package plugin.utils


import com.android.build.gradle.AppExtension
import com.android.ddmlib.AndroidDebugBridge
import org.gradle.api.DefaultTask
Expand All @@ -9,6 +10,7 @@ import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.TaskProvider
import plugin.RocketXPlugin
import java.util.concurrent.TimeUnit

/**
* description:
Expand Down Expand Up @@ -53,9 +55,10 @@ class InstallApkByAdb(val appProject: Project) {
val adb = android.adbExecutable.absolutePath

try {

AndroidDebugBridge.initIfNeeded(false)
val bridge = AndroidDebugBridge.createBridge(android.adbExecutable.path, false)
val bridge = AndroidDebugBridge.createBridge(android.adbExecutable.path, false,
Long.MAX_VALUE,
TimeUnit.MILLISECONDS)
var firstLocalDeviceSerinum = ""
run loop@{
bridge?.devices?.forEach {
Expand All @@ -73,13 +76,23 @@ class InstallApkByAdb(val appProject: Project) {
// adb -s <ip:port> install -r <app.apk>
// adb -s <ip:port> shell monkey -p <包名> -c android.intent.category.LAUNCHER 1
project.exec {
it.commandLine(adb, "-s", firstLocalDeviceSerinum, "shell", "monkey", "-p", android.defaultConfig.applicationId, "-c", "android.intent.category.LAUNCHER", "1")
it.commandLine(
adb,
"-s",
firstLocalDeviceSerinum,
"shell",
"monkey",
"-p",
android.defaultConfig.applicationId,
"-c",
"android.intent.category.LAUNCHER",
"1"
)
}
}
} catch (e: Exception) {
LogUtil.d("install fail:" + e.toString())
}

}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Oct 20 18:00:29 CST 2021
#Wed Sep 14 15:07:08 CST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

0 comments on commit d37af1f

Please sign in to comment.