diff --git a/README.md b/README.md index e378451a..4aff657d 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ androidJunkCode { } ``` -**注:从1.3.0开始本库已经上传到Gradle Plugin Portal 可直接这样使用** +**注:从1.3.1开始本库已经上传到Gradle Plugin Portal 可直接这样使用** ```groovy plugins { @@ -83,7 +83,7 @@ androidJunkCode { } ``` -如果APP开启了混淆,需要在混淆文件里配置 (1.3.0之后不需求配置) +如果APP开启了混淆,需要在混淆文件里配置 (1.3.1之后不需求配置) ``` #cn.hx.plugin.ui为前面配置的packageBase diff --git a/build.gradle b/build.gradle index 617aba19..55690735 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "com.getkeepsafe.dexcount:dexcount-gradle-plugin:3.0.1" if (PLUGIN_ENABLE.toBoolean()) { - classpath "com.github.qq549631030:android-junk-code:1.3.1" + classpath "com.github.qq549631030:android-junk-code:1.3.2" } // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/library/gradle.properties b/library/gradle.properties index d771665c..d88520c4 100644 --- a/library/gradle.properties +++ b/library/gradle.properties @@ -1,7 +1,7 @@ #project GROUP=com.github.qq549631030 POM_ARTIFACT_ID=android-junk-code -VERSION_NAME=1.3.1 +VERSION_NAME=1.3.2 POM_PACKAGING=jar POM_NAME=AndroidJunkCode diff --git a/library/src/main/groovy/cn/hx/plugin/junkcode/plugin/NewVariantApiPlugin.groovy b/library/src/main/groovy/cn/hx/plugin/junkcode/plugin/NewVariantApiPlugin.groovy index 897214e7..f93bf4ca 100644 --- a/library/src/main/groovy/cn/hx/plugin/junkcode/plugin/NewVariantApiPlugin.groovy +++ b/library/src/main/groovy/cn/hx/plugin/junkcode/plugin/NewVariantApiPlugin.groovy @@ -30,10 +30,7 @@ class NewVariantApiPlugin implements Plugin { def generateJunkCodeTaskProvider = project.tasks.register("generate${variantName.capitalize()}JunkCode", GenerateJunkCodeTask) { config = junkCodeConfig namespace = variant.namespace - javaOutputFolder.set(junkCodeOutDir.map { it.dir("java") }) - resOutputFolder.set(junkCodeOutDir.map { it.dir("res") }) - manifestOutputFile.set(junkCodeOutDir.map { it.file("AndroidManifest.xml") }) - proguardOutputFile.set(junkCodeOutDir.map { it.file("proguard-rules.pro") }) + outputFolder.set(junkCodeOutDir) } if (JunkUtil.isAGP7_4_0(project)) { if (variant.sources.java) { @@ -68,12 +65,9 @@ class NewVariantApiPlugin implements Plugin { def junkCodeConfig = generateJunkCodeExt.variantConfig.findByName(variantName) if (junkCodeConfig) { def generateJunkCodeTaskProvider = project.tasks.named("generate${variantName.capitalize()}JunkCode", GenerateJunkCodeTask) - variant.registerJavaGeneratingTask(generateJunkCodeTaskProvider, generateJunkCodeTaskProvider.get().javaOutputFolder.get().asFile) - - variant.registerGeneratedResFolders(project.files(generateJunkCodeTaskProvider.map { - it.resOutputFolder.asFile - }).builtBy(generateJunkCodeTaskProvider)) - variant.mergeResourcesProvider.configure { dependsOn(generateJunkCodeTaskProvider.get()) } + def junkCodeOutDir = project.layout.buildDirectory.dir("generated/source/junk/${variantName}") + variant.registerJavaGeneratingTask(generateJunkCodeTaskProvider, junkCodeOutDir.map { it.dir("java") }.get().asFile) + variant.registerGeneratedResFolders(project.files(junkCodeOutDir.map { it.dir("res") }.get().asFile).builtBy(generateJunkCodeTaskProvider)) } } } diff --git a/library/src/main/groovy/cn/hx/plugin/junkcode/task/GenerateJunkCodeTask.groovy b/library/src/main/groovy/cn/hx/plugin/junkcode/task/GenerateJunkCodeTask.groovy index 7315d1f7..1aad65b6 100644 --- a/library/src/main/groovy/cn/hx/plugin/junkcode/task/GenerateJunkCodeTask.groovy +++ b/library/src/main/groovy/cn/hx/plugin/junkcode/task/GenerateJunkCodeTask.groovy @@ -16,6 +16,9 @@ abstract class GenerateJunkCodeTask extends DefaultTask { @Input abstract Property getNamespace() + @OutputDirectory + abstract DirectoryProperty getOutputFolder() + @OutputDirectory abstract DirectoryProperty getJavaOutputFolder() @@ -32,6 +35,13 @@ abstract class GenerateJunkCodeTask extends DefaultTask { private List packageList = new ArrayList<>() private List activityList = new ArrayList<>() + GenerateJunkCodeTask() { + getJavaOutputFolder().convention(getOutputFolder().dir("java")) + getResOutputFolder().convention(getOutputFolder().dir("res")) + getManifestOutputFile().convention(getOutputFolder().file("AndroidManifest.xml")) + getProguardOutputFile().convention(getOutputFolder().file("proguard-rules.pro")) + } + @TaskAction void taskAction() { def javaDir = getJavaOutputFolder().get().asFile diff --git a/library/src/main/groovy/cn/hx/plugin/junkcode/utils/JunkUtil.groovy b/library/src/main/groovy/cn/hx/plugin/junkcode/utils/JunkUtil.groovy index d8298687..e30d1bd9 100644 --- a/library/src/main/groovy/cn/hx/plugin/junkcode/utils/JunkUtil.groovy +++ b/library/src/main/groovy/cn/hx/plugin/junkcode/utils/JunkUtil.groovy @@ -355,7 +355,7 @@ class JunkUtil { static void generateProguard(File proguardFile, List packageList) { StringBuilder sb = new StringBuilder() for (i in 0..