Skip to content

Commit

Permalink
Merge pull request #144 from chenenyu/dev
Browse files Browse the repository at this point in the history
fix issue #143
  • Loading branch information
chenenyu committed May 6, 2020
2 parents 0a023b9 + 4c17d5e commit 0a3a252
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ import com.android.build.gradle.TestPlugin
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.initialization.dsl.ScriptHandler
import org.gradle.api.plugins.ExtraPropertiesExtension

/**
* Created by chenenyu on 2018/7/24.
*/
class RouterPlugin implements Plugin<Project> {
static final String APT_OPTION_NAME = "moduleName"
private static final String APT_OPTION_NAME = "moduleName"

String DEFAULT_ROUTER_RUNTIME_VERSION = "1.7.2"
String DEFAULT_ROUTER_COMPILER_VERSION = "1.7.2"

String androidBuildGradleVersion
String DEFAULT_ROUTER_RUNTIME_VERSION = "1.7.3"
String DEFAULT_ROUTER_COMPILER_VERSION = "1.7.3"

@Override
void apply(Project project) {
Expand All @@ -32,32 +29,16 @@ class RouterPlugin implements Plugin<Project> {
throw new GradleException("android plugin required.")
}

project.rootProject.buildscript.configurations.each {
if (it.name == ScriptHandler.CLASSPATH_CONFIGURATION) { // classpath
it.resolvedConfiguration.firstLevelModuleDependencies.each {
// println("${it.moduleGroup}:${it.moduleName}:${it.moduleVersion}")
if (it.moduleGroup == "com.android.tools.build" && it.moduleName == "gradle") {
androidBuildGradleVersion = it.moduleVersion
}
}
}
}
if (!androidBuildGradleVersion) {
throw new IllegalArgumentException("Unknown android build gradle plugin version.")
}

// kotlin project ?
def isKotlinProject = project.plugins.hasPlugin('kotlin-android')
// https://github.com/JetBrains/kotlin/tree/master/libraries/tools/kotlin-gradle-plugin/src/main/resources/META-INF/gradle-plugins
def isKotlinProject = project.plugins.hasPlugin('kotlin-android') || project.plugins.hasPlugin('org.jetbrains.kotlin.android')
if (isKotlinProject) {
if (!project.plugins.hasPlugin('kotlin-kapt')) {
if (!project.plugins.hasPlugin('kotlin-kapt') && !project.plugins.hasPlugin('org.jetbrains.kotlin.kapt')) {
project.plugins.apply('kotlin-kapt')
}
}

String compileConf = 'implementation'
if (!is3_xVersion()) {
compileConf = 'compile'
}
String aptConf = 'annotationProcessor'
if (isKotlinProject) {
aptConf = 'kapt'
Expand Down Expand Up @@ -97,11 +78,4 @@ class RouterPlugin implements Plugin<Project> {
android.registerTransform(transform)
}
}

/**
* Whether the android gradle plugin version is 3.x
*/
boolean is3_xVersion() {
return androidBuildGradleVersion.split("\\.")[0].toInteger() >= 3
}
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ android.useAndroidX=true
# apply router plugin
applyRemotePlugin=false
# router gradle plugin version
PLUGIN_VERSION=1.7.2
PLUGIN_VERSION=1.7.3
# router library version
ROUTER_VERSION=1.7.2
ROUTER_VERSION=1.7.3
# compiler library version
COMPILER_VERSION=1.7.2
COMPILER_VERSION=1.7.3
# annotation library version
ANNOTATION_VERSION=0.4.0
4 changes: 2 additions & 2 deletions release.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# annotation
./gradlew clean pBPTML -p annotation
./gradlew bintrayUpload -p annotation
#./gradlew clean pBPTML -p annotation
#./gradlew bintrayUpload -p annotation

# compiler
./gradlew clean pBPTML -p compiler
Expand Down

0 comments on commit 0a3a252

Please sign in to comment.