From a438b2b55c2735b375bcea8d39ae1aa76e8332fc Mon Sep 17 00:00:00 2001 From: puboe <8038503+puboe@users.noreply.github.com> Date: Wed, 9 Sep 2020 19:33:51 +0200 Subject: [PATCH] Improve incremental build --- .../com/kezong/fataar/RProcessor.groovy | 6 ++-- .../com/kezong/fataar/VariantProcessor.groovy | 32 +++++++++++-------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/source/src/main/groovy/com/kezong/fataar/RProcessor.groovy b/source/src/main/groovy/com/kezong/fataar/RProcessor.groovy index 2da936cd..f1022ad3 100644 --- a/source/src/main/groovy/com/kezong/fataar/RProcessor.groovy +++ b/source/src/main/groovy/com/kezong/fataar/RProcessor.groovy @@ -71,8 +71,6 @@ class RProcessor { if (f.exists()) { f.delete() } - mJarDir.getParentFile().deleteDir() - mJarDir.mkdirs() } bundleTask.doLast { @@ -170,7 +168,9 @@ class RProcessor { } private Task createRFileTask(final File destFolder) { - def task = mProject.tasks.create(name: 'createRsFile' + mVariant.name) + def task = mProject.tasks.create(name: 'createRsFile' + mVariant.name) { + outputs.dir(destFolder) + } task.doLast { if (destFolder.exists()) { destFolder.deleteDir() diff --git a/source/src/main/groovy/com/kezong/fataar/VariantProcessor.groovy b/source/src/main/groovy/com/kezong/fataar/VariantProcessor.groovy index 0a21d09f..8dd11c42 100644 --- a/source/src/main/groovy/com/kezong/fataar/VariantProcessor.groovy +++ b/source/src/main/groovy/com/kezong/fataar/VariantProcessor.groovy @@ -147,7 +147,6 @@ class VariantProcessor { dependencies = context.queue.getFirst().getDependencies() } } - archiveLibrary.getRootFolder().deleteDir() final def zipFolder = archiveLibrary.getRootFolder() zipFolder.mkdirs() def group = artifact.getModuleVersion().id.group.capitalize() @@ -222,25 +221,30 @@ class VariantProcessor { } private Task handleClassesMergeTask(final boolean isMinifyEnabled) { - final Task task = mProject.tasks.create(name: 'mergeClasses' - + mVariant.name.capitalize()) - task.doFirst { - def dustDir = mVersionAdapter.getClassPathDirFiles().first() - if (isMinifyEnabled) { - ExplodedHelper.processClassesJarInfoClasses(mProject, mAndroidArchiveLibraries, dustDir) - ExplodedHelper.processLibsIntoClasses(mProject, mAndroidArchiveLibraries, mJarFiles, dustDir) - } else { - ExplodedHelper.processClassesJarInfoClasses(mProject, mAndroidArchiveLibraries, dustDir) + final Task task = mProject.tasks.create(name: 'mergeClasses' + mVariant.name.capitalize()) { + def outputDir = mVersionAdapter.getClassPathDirFiles().first() + outputs.dir(outputDir) + + doFirst { + if (isMinifyEnabled) { + ExplodedHelper.processClassesJarInfoClasses(mProject, mAndroidArchiveLibraries, outputDir) + ExplodedHelper.processLibsIntoClasses(mProject, mAndroidArchiveLibraries, mJarFiles, outputDir) + } else { + ExplodedHelper.processClassesJarInfoClasses(mProject, mAndroidArchiveLibraries, outputDir) + } } } return task } private Task handleJarMergeTask() { - final Task task = mProject.tasks.create(name: 'mergeJars' - + mVariant.name.capitalize()) - task.doFirst { - ExplodedHelper.processLibsIntoLibs(mProject, mAndroidArchiveLibraries, mJarFiles, mVersionAdapter.getLibsDirFile()) + final Task task = mProject.tasks.create(name: 'mergeJars' + mVariant.name.capitalize()) { + def outputDir = mVersionAdapter.getLibsDirFile() + outputs.dir(outputDir) + + doFirst { + ExplodedHelper.processLibsIntoLibs(mProject, mAndroidArchiveLibraries, mJarFiles, outputDir) + } } return task }