@@ -6,19 +6,16 @@ import com.android.build.gradle.TestPlugin
66import org.gradle.api.GradleException
77import org.gradle.api.Plugin
88import org.gradle.api.Project
9- import org.gradle.api.initialization.dsl.ScriptHandler
109import org.gradle.api.plugins.ExtraPropertiesExtension
1110
1211/**
1312 * Created by chenenyu on 2018/7/24.
1413 */
1514class RouterPlugin implements Plugin<Project > {
16- static final String APT_OPTION_NAME = " moduleName"
15+ private static final String APT_OPTION_NAME = " moduleName"
1716
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"
2219
2320 @Override
2421 void apply (Project project ) {
@@ -32,32 +29,16 @@ class RouterPlugin implements Plugin<Project> {
3229 throw new GradleException (" android plugin required." )
3330 }
3431
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-
4932 // 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' )
5135 if (isKotlinProject) {
52- if (! project. plugins. hasPlugin(' kotlin-kapt' )) {
36+ if (! project. plugins. hasPlugin(' kotlin-kapt' ) && ! project . plugins . hasPlugin( ' org.jetbrains.kotlin.kapt ' ) ) {
5337 project. plugins. apply(' kotlin-kapt' )
5438 }
5539 }
5640
5741 String compileConf = ' implementation'
58- if (! is3_xVersion()) {
59- compileConf = ' compile'
60- }
6142 String aptConf = ' annotationProcessor'
6243 if (isKotlinProject) {
6344 aptConf = ' kapt'
@@ -97,11 +78,4 @@ class RouterPlugin implements Plugin<Project> {
9778 android. registerTransform(transform)
9879 }
9980 }
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- }
10781}
0 commit comments