diff --git a/buildSrc/src/main/groovy/com/iqiyi/qigsaw/buildtool/gradle/internal/entity/ComponentInfo.groovy b/buildSrc/src/main/groovy/com/iqiyi/qigsaw/buildtool/gradle/internal/entity/ComponentInfo.groovy deleted file mode 100644 index df4af566..00000000 --- a/buildSrc/src/main/groovy/com/iqiyi/qigsaw/buildtool/gradle/internal/entity/ComponentInfo.groovy +++ /dev/null @@ -1,38 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2019-present, iQIYI, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.iqiyi.qigsaw.buildtool.gradle.internal.entity - -class ComponentInfo { - - String name - - String process - - ComponentInfo(String name, String process) { - this.name = name - this.process = process - } - -} diff --git a/buildSrc/src/main/groovy/com/iqiyi/qigsaw/buildtool/gradle/internal/tool/ManifestReader.groovy b/buildSrc/src/main/groovy/com/iqiyi/qigsaw/buildtool/gradle/internal/tool/ManifestReader.groovy index 5a0dc7f9..fa3aeac2 100644 --- a/buildSrc/src/main/groovy/com/iqiyi/qigsaw/buildtool/gradle/internal/tool/ManifestReader.groovy +++ b/buildSrc/src/main/groovy/com/iqiyi/qigsaw/buildtool/gradle/internal/tool/ManifestReader.groovy @@ -25,7 +25,6 @@ package com.iqiyi.qigsaw.buildtool.gradle.internal.tool import com.google.common.collect.ImmutableSet -import com.iqiyi.qigsaw.buildtool.gradle.internal.entity.ComponentInfo class ManifestReader { @@ -76,44 +75,40 @@ class ManifestReader { return providers.build() } - Set readActivities() { - ImmutableSet.Builder activities = ImmutableSet.builder() + Set readActivityProcesses() { + Set processes = new HashSet<>() manifest.application.activity.each { - String name = it.'@android:name'.toString() String process = it.'@android:process'.toString() - activities.add(new ComponentInfo(name, process)) + processes.add(process) } - return activities.build() + return processes } - Set readServices() { - ImmutableSet.Builder services = ImmutableSet.builder() + Set readServiceProcesses() { + Set processes = new HashSet<>() manifest.application.service.each { - String name = it.'@android:name'.toString() String process = it.'@android:process'.toString() - services.add(new ComponentInfo(name, process)) + processes.add(process) } - return services.build() + return processes } - Set readReceivers() { - ImmutableSet.Builder receivers = ImmutableSet.builder() + Set readReceiverProcesses() { + Set processes = new HashSet<>() manifest.application.receiver.each { - String name = it.'@android:name'.toString() String process = it.'@android:process'.toString() - receivers.add(new ComponentInfo(name, process)) + processes.add(process) } - return receivers.build() + return processes } - Set readProviders() { - ImmutableSet.Builder providers = ImmutableSet.builder() + Set readProviderProcesses() { + Set processes = new HashSet<>() manifest.application.provider.each { - String name = it.'@android:name'.toString() String process = it.'@android:process'.toString() - providers.add(new ComponentInfo(name, process)) + processes.add(process) } - return providers.build() + return processes } boolean readOnDemand() { diff --git a/buildSrc/src/main/groovy/com/iqiyi/qigsaw/buildtool/gradle/task/ProcessSplitApkTask.groovy b/buildSrc/src/main/groovy/com/iqiyi/qigsaw/buildtool/gradle/task/ProcessSplitApkTask.groovy index b04205d7..cb26b4ea 100644 --- a/buildSrc/src/main/groovy/com/iqiyi/qigsaw/buildtool/gradle/task/ProcessSplitApkTask.groovy +++ b/buildSrc/src/main/groovy/com/iqiyi/qigsaw/buildtool/gradle/task/ProcessSplitApkTask.groovy @@ -27,7 +27,6 @@ package com.iqiyi.qigsaw.buildtool.gradle.task import com.android.SdkConstants import com.android.tools.build.bundletool.model.Aapt2Command import com.android.tools.build.bundletool.model.AndroidManifest -import com.iqiyi.qigsaw.buildtool.gradle.internal.entity.ComponentInfo import com.iqiyi.qigsaw.buildtool.gradle.internal.entity.SplitInfo import com.iqiyi.qigsaw.buildtool.gradle.internal.tool.FileUtils import com.iqiyi.qigsaw.buildtool.gradle.internal.tool.ManifestReader @@ -194,26 +193,24 @@ class ProcessSplitApkTask extends DefaultTask { } }) Set splitWorkProcesses = new HashSet<>() - Set activities = manifestReader.readActivities() - activities.each { - splitWorkProcesses.add(it.process) - } - Set services = manifestReader.readServices() - services.each { - splitWorkProcesses.add(it.process) - } - Set receivers = manifestReader.readReceivers() - receivers.each { - splitWorkProcesses.add(it.process) - } - Set providers = manifestReader.readProviders() - providers.each { - splitWorkProcesses.add(it.process) - } - if (restrictWorkProcessesForSplits != null && !restrictWorkProcessesForSplits.empty) { - if (restrictWorkProcessesForSplits.contains(project.name)) { - splitWorkProcesses = splitWorkProcesses.isEmpty() ? null : splitWorkProcesses + Set activityProcesses = manifestReader.readActivityProcesses() + splitWorkProcesses.addAll(activityProcesses) + Set serviceProcesses = manifestReader.readServiceProcesses() + splitWorkProcesses.addAll(serviceProcesses) + Set receiverProcesses = manifestReader.readReceiverProcesses() + splitWorkProcesses.addAll(receiverProcesses) + Set providerProcesses = manifestReader.readProviderProcesses() + splitWorkProcesses.addAll(providerProcesses) + + if (restrictWorkProcessesForSplits != null) { + if (!restrictWorkProcessesForSplits.contains(project.name)) { + splitWorkProcesses = null } + } else { + splitWorkProcesses = null + } + if (splitWorkProcesses != null && splitWorkProcesses.empty) { + splitWorkProcesses = null } SplitInfo splitInfo = new SplitInfo() splitInfo.splitName = project.name @@ -224,7 +221,7 @@ class ProcessSplitApkTask extends DefaultTask { splitInfo.version = splitVersion splitInfo.applicationName = splitApplicationName == "" ? null : splitApplicationName splitInfo.dependencies = dependencies.isEmpty() ? null : dependencies - splitInfo.workProcesses = splitWorkProcesses.isEmpty() ? null : splitWorkProcesses + splitInfo.workProcesses = splitWorkProcesses splitInfo.apkData = apkDataList.isEmpty() ? null : apkDataList splitInfo.libData = libDataList.isEmpty() ? null : libDataList return splitInfo