11package plugin.utils
22
3+ import com.android.build.gradle.AppExtension
34import org.gradle.api.Project
45import plugin.RocketXPlugin
56import java.io.File
@@ -35,8 +36,7 @@ fun isRunAssembleTask(curProject: Project): Boolean {
3536
3637
3738fun isEnable (curProject : Project ): Boolean {
38- val enableFile =
39- File (curProject.rootProject.rootDir.absolutePath + File .separator + " .gradle" + File .separator + " rocketXEnable" )
39+ val enableFile = File (curProject.rootProject.rootDir.absolutePath + File .separator + " .gradle" + File .separator + " rocketXEnable" )
4040 return enableFile.exists()
4141}
4242
@@ -50,8 +50,7 @@ fun getFlavorBuildType(appProject: Project): String {
5050 flavorBuildType = arg.substring(index, arg.length)
5151 }
5252 if (flavorBuildType.isNotEmpty()) {
53- flavorBuildType =
54- flavorBuildType.substring(0 , 1 ).toLowerCase(Locale .ROOT ) + flavorBuildType.substring(1 )
53+ flavorBuildType = flavorBuildType.substring(0 , 1 ).toLowerCase(Locale .ROOT ) + flavorBuildType.substring(1 )
5554 }
5655 return flavorBuildType
5756}
@@ -81,4 +80,57 @@ fun isCurProjectRun(appProject: Project): Boolean {
8180
8281
8382 return ret
83+ }
84+
85+
86+ fun boostGradleOption (appProject : Project ) {
87+ // 并行运行task
88+
89+ if (! appProject.hasProperty(" org.gradle.daemon" )) {
90+ appProject.rootProject.extensions.extraProperties.set(" org.gradle.daemon" , " true" )
91+ }
92+ if (! appProject.hasProperty(" kotlin.incremental" )) {
93+ appProject.rootProject.extensions.extraProperties.set(" kotlin.incremental" , true )
94+ }
95+ if (! appProject.hasProperty(" kotlin.incremental.java" )) {
96+ appProject.rootProject.extensions.extraProperties.set(" kotlin.incremental.java" , " true" )
97+ }
98+ if (! appProject.hasProperty(" kotlin.incremental.js" )) {
99+ appProject.rootProject.extensions.extraProperties.set(" kotlin.incremental.js" , " true" )
100+ }
101+ if (! appProject.hasProperty(" kotlin.caching.enabled" )) {
102+ appProject.rootProject.extensions.extraProperties.set(" kotlin.caching.enabled" , " true" )
103+ }
104+
105+ if (! appProject.hasProperty(" org.gradle.parallel" )) {
106+ appProject.rootProject.extensions.extraProperties.set(" org.gradle.parallel" , " true" )
107+ }
108+ if (! appProject.hasProperty(" kotlin.parallel.tasks.in.project" )) {
109+ appProject.rootProject.extensions.extraProperties.set(" kotlin.parallel.tasks.in.project" , " true" )
110+ }
111+ if (! appProject.hasProperty(" kapt.use.worker.api" )) {
112+ appProject.rootProject.extensions.extraProperties.set(" kapt.use.worker.api" , " true" )
113+ }
114+ if (! appProject.hasProperty(" kapt.incremental.apt" )) {
115+ appProject.rootProject.extensions.extraProperties.set(" kapt.incremental.apt" , " true" )
116+ }
117+ if (! appProject.hasProperty(" kapt.classloaders.cache.size" )) {
118+ appProject.rootProject.extensions.extraProperties.set(" kapt.classloaders.cache.size" , " 5" )
119+ }
120+ if (! appProject.hasProperty(" kapt.include.compile.classpath" )) {
121+ appProject.rootProject.extensions.extraProperties.set(" kapt.include.compile.classpath" , " false" )
122+ }
123+ if (! appProject.hasProperty(" org.gradle.caching" )) {
124+ appProject.rootProject.extensions.extraProperties.set(" org.gradle.caching" , " true" )
125+ }
126+ if (! appProject.hasProperty(" android.enableBuildCache" )) {
127+ appProject.rootProject.extensions.extraProperties.set(" android.enableBuildCache" , " true" )
128+ }
129+
130+ appProject.gradle.startParameter.isParallelProjectExecutionEnabled = true
131+ appProject.gradle.startParameter.maxWorkerCount + = 4
132+ var android = appProject.extensions.getByType(AppExtension ::class .java)
133+ android.aaptOptions.cruncherEnabled = false
134+ android.aaptOptions.cruncherProcesses = 0
135+
84136}
0 commit comments