Skip to content

Commit

Permalink
change api
Browse files Browse the repository at this point in the history
  • Loading branch information
typ0520 committed Oct 20, 2017
1 parent 3bc53a0 commit 03ae8bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 38 deletions.
24 changes: 2 additions & 22 deletions fastdex-gradle/src/main/groovy/fastdex/build/FastdexPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ class FastdexPlugin implements Plugin<Project> {
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
Expand Down Expand Up @@ -241,7 +240,7 @@ class FastdexPlugin implements Plugin<Project> {
collectMultiDexComponentsTask.enabled = false
}

Task mergeAssetsTask = getMergeAssetsTask(project, variantName)
Task mergeAssetsTask = variant.mergeAssets
mergeAssetsTask.doLast {
fastdexVariant.fastdexInstantRun.onAssetsChanged()
}
Expand Down Expand Up @@ -370,16 +369,6 @@ class FastdexPlugin implements Plugin<Project> {
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 {
Expand Down Expand Up @@ -425,15 +414,6 @@ class FastdexPlugin implements Plugin<Project> {
}
}

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand All @@ -33,8 +32,6 @@ public class FastdexVariant {
final ProjectSnapshoot projectSnapshoot
final Set<LibDependency> libraryDependencies

String originPackageName
String mergedPackageName
boolean hasDexCache
boolean firstPatchBuild
boolean initialized
Expand Down Expand Up @@ -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")
}
}

Expand Down Expand Up @@ -213,24 +210,15 @@ 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()
}

/**
* 获取合并以后的manifest文件的package节点的值
* @return
*/
public String getMergedPackageName() {
if (mergedPackageName != null) {
return mergedPackageName
}
mergedPackageName = GradleUtils.getPackageName(manifestPath)
return mergedPackageName
return androidVariant.getVariantData().getVariantConfiguration().getApplicationId()
}

/**
Expand Down

0 comments on commit 03ae8bb

Please sign in to comment.