From 03ae8bb4ad6a679a09d26435d958ce68ddaf5133 Mon Sep 17 00:00:00 2001 From: typ0520 Date: Fri, 20 Oct 2017 23:08:59 +0800 Subject: [PATCH] change api --- .../groovy/fastdex/build/FastdexPlugin.groovy | 24 ++----------------- .../build/variant/FastdexVariant.groovy | 20 ++++------------ 2 files changed, 6 insertions(+), 38 deletions(-) diff --git a/fastdex-gradle/src/main/groovy/fastdex/build/FastdexPlugin.groovy b/fastdex-gradle/src/main/groovy/fastdex/build/FastdexPlugin.groovy index ca4ffb44..163b653d 100644 --- a/fastdex-gradle/src/main/groovy/fastdex/build/FastdexPlugin.groovy +++ b/fastdex-gradle/src/main/groovy/fastdex/build/FastdexPlugin.groovy @@ -146,8 +146,7 @@ class FastdexPlugin implements Plugin { FastdexCleanTask cleanTask = project.tasks.create("fastdexCleanFor${variantName}", FastdexCleanTask) cleanTask.fastdexVariant = fastdexVariant - //TODO change api - variantOutput.processManifest.dependsOn getMergeResources(project,variantName) + variantOutput.processManifest.dependsOn variant.mergeResources //替换项目的Application为fastdex.runtime.FastdexApplication FastdexManifestTask manifestTask = project.tasks.create("fastdexProcess${variantName}Manifest", FastdexManifestTask) manifestTask.fastdexVariant = fastdexVariant @@ -241,7 +240,7 @@ class FastdexPlugin implements Plugin { collectMultiDexComponentsTask.enabled = false } - Task mergeAssetsTask = getMergeAssetsTask(project, variantName) + Task mergeAssetsTask = variant.mergeAssets mergeAssetsTask.doLast { fastdexVariant.fastdexInstantRun.onAssetsChanged() } @@ -370,16 +369,6 @@ class FastdexPlugin implements Plugin { javaCompile.options.compilerArgs.addAll(compilerArgs) } - Task getMergeAssetsTask(Project project, String variantName) { - String taskName = "merge${variantName}Assets" - try { - return project.tasks.getByName(taskName) - } catch (Throwable e) { - return null - } - } - - Task getPackageTask(Project project, String variantName) { String taskName = "package${variantName}" try { @@ -425,15 +414,6 @@ class FastdexPlugin implements Plugin { } } - Task getMergeResources(Project project, String variantName) { - String taskName = "merge${variantName}Resources" - try { - return project.tasks.getByName(taskName) - } catch (Throwable e) { - return null - } - } - Task getTransformClassesWithMultidexlistTask(Project project, String variantName) { String taskName = "transformClassesWithMultidexlistFor${variantName}" try { diff --git a/fastdex-gradle/src/main/groovy/fastdex/build/variant/FastdexVariant.groovy b/fastdex-gradle/src/main/groovy/fastdex/build/variant/FastdexVariant.groovy index ff903c91..d85e927d 100755 --- a/fastdex-gradle/src/main/groovy/fastdex/build/variant/FastdexVariant.groovy +++ b/fastdex-gradle/src/main/groovy/fastdex/build/variant/FastdexVariant.groovy @@ -16,7 +16,6 @@ import fastdex.build.util.MetaInfo import fastdex.build.util.ProjectSnapshoot import fastdex.build.util.FastdexUtils import fastdex.common.utils.FileUtils -import fastdex.build.util.GradleUtils import org.gradle.api.Project /** @@ -33,8 +32,6 @@ public class FastdexVariant { final ProjectSnapshoot projectSnapshoot final Set libraryDependencies - String originPackageName - String mergedPackageName boolean hasDexCache boolean firstPatchBuild boolean initialized @@ -177,11 +174,11 @@ public class FastdexVariant { if (!(e instanceof JumpException) && configuration.debug) { e.printStackTrace() } + project.logger.error("==fastdex ${e.getMessage()}") + project.logger.error("==fastdex we will remove ${variantName.toLowerCase()} cache") project.logger.error("==fastdex delete ${classesDir}") project.logger.error("==fastdex delete ${transformsDir}") project.logger.error("==fastdex delete ${apkLocationDir}") - project.logger.error("==fastdex ${e.getMessage()}") - project.logger.error("==fastdex we will remove ${variantName.toLowerCase()} cache") } } @@ -213,12 +210,7 @@ public class FastdexVariant { * @return */ public String getOriginPackageName() { - if (originPackageName != null) { - return originPackageName - } - String path = project.android.sourceSets.main.manifest.srcFile.absolutePath - originPackageName = GradleUtils.getPackageName(path) - return originPackageName + return androidVariant.getVariantData().getVariantConfiguration().getOriginalApplicationId() } /** @@ -226,11 +218,7 @@ public class FastdexVariant { * @return */ public String getMergedPackageName() { - if (mergedPackageName != null) { - return mergedPackageName - } - mergedPackageName = GradleUtils.getPackageName(manifestPath) - return mergedPackageName + return androidVariant.getVariantData().getVariantConfiguration().getApplicationId() } /**