@@ -6,19 +6,16 @@ import com.android.build.gradle.TestPlugin
6
6
import org.gradle.api.GradleException
7
7
import org.gradle.api.Plugin
8
8
import org.gradle.api.Project
9
- import org.gradle.api.initialization.dsl.ScriptHandler
10
9
import org.gradle.api.plugins.ExtraPropertiesExtension
11
10
12
11
/**
13
12
* Created by chenenyu on 2018/7/24.
14
13
*/
15
14
class RouterPlugin implements Plugin<Project > {
16
- static final String APT_OPTION_NAME = " moduleName"
15
+ private static final String APT_OPTION_NAME = " moduleName"
17
16
18
- String DEFAULT_ROUTER_RUNTIME_VERSION = " 1.7.2"
19
- String DEFAULT_ROUTER_COMPILER_VERSION = " 1.7.2"
20
-
21
- String androidBuildGradleVersion
17
+ String DEFAULT_ROUTER_RUNTIME_VERSION = " 1.7.3"
18
+ String DEFAULT_ROUTER_COMPILER_VERSION = " 1.7.3"
22
19
23
20
@Override
24
21
void apply (Project project ) {
@@ -32,32 +29,16 @@ class RouterPlugin implements Plugin<Project> {
32
29
throw new GradleException (" android plugin required." )
33
30
}
34
31
35
- project. rootProject. buildscript. configurations. each {
36
- if (it. name == ScriptHandler . CLASSPATH_CONFIGURATION ) { // classpath
37
- it. resolvedConfiguration. firstLevelModuleDependencies. each {
38
- // println("${it.moduleGroup}:${it.moduleName}:${it.moduleVersion}")
39
- if (it. moduleGroup == " com.android.tools.build" && it. moduleName == " gradle" ) {
40
- androidBuildGradleVersion = it. moduleVersion
41
- }
42
- }
43
- }
44
- }
45
- if (! androidBuildGradleVersion) {
46
- throw new IllegalArgumentException (" Unknown android build gradle plugin version." )
47
- }
48
-
49
32
// kotlin project ?
50
- def isKotlinProject = project. plugins. hasPlugin(' kotlin-android' )
33
+ // https://github.com/JetBrains/kotlin/tree/master/libraries/tools/kotlin-gradle-plugin/src/main/resources/META-INF/gradle-plugins
34
+ def isKotlinProject = project. plugins. hasPlugin(' kotlin-android' ) || project. plugins. hasPlugin(' org.jetbrains.kotlin.android' )
51
35
if (isKotlinProject) {
52
- if (! project. plugins. hasPlugin(' kotlin-kapt' )) {
36
+ if (! project. plugins. hasPlugin(' kotlin-kapt' ) && ! project . plugins . hasPlugin( ' org.jetbrains.kotlin.kapt ' ) ) {
53
37
project. plugins. apply(' kotlin-kapt' )
54
38
}
55
39
}
56
40
57
41
String compileConf = ' implementation'
58
- if (! is3_xVersion()) {
59
- compileConf = ' compile'
60
- }
61
42
String aptConf = ' annotationProcessor'
62
43
if (isKotlinProject) {
63
44
aptConf = ' kapt'
@@ -97,11 +78,4 @@ class RouterPlugin implements Plugin<Project> {
97
78
android. registerTransform(transform)
98
79
}
99
80
}
100
-
101
- /**
102
- * Whether the android gradle plugin version is 3.x
103
- */
104
- boolean is3_xVersion () {
105
- return androidBuildGradleVersion. split(" \\ ." )[0 ]. toInteger() >= 3
106
- }
107
81
}
0 commit comments