mirror of
				https://github.com/topjohnwu/Magisk.git
				synced 2025-10-31 21:01:18 +00:00 
			
		
		
		
	Move several stuff into buildSrc
This commit is contained in:
		| @@ -1,6 +1,3 @@ | ||||
| import com.android.build.api.instrumentation.FramesComputationMode.COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS | ||||
| import com.android.build.api.instrumentation.InstrumentationScope | ||||
|  | ||||
| plugins { | ||||
|     id("com.android.application") | ||||
|     kotlin("android") | ||||
| @@ -9,7 +6,7 @@ plugins { | ||||
|     id("androidx.navigation.safeargs.kotlin") | ||||
| } | ||||
|  | ||||
| setupAppCommon() | ||||
| setupMainApk() | ||||
|  | ||||
| kapt { | ||||
|     correctErrorTypes = true | ||||
| @@ -21,27 +18,6 @@ kapt { | ||||
| } | ||||
|  | ||||
| android { | ||||
|     namespace = "com.topjohnwu.magisk" | ||||
|  | ||||
|     defaultConfig { | ||||
|         applicationId = "com.topjohnwu.magisk" | ||||
|         vectorDrawables.useSupportLibrary = true | ||||
|         versionName = Config.version | ||||
|         versionCode = Config.versionCode | ||||
|         ndk { | ||||
|             abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64", "riscv64") | ||||
|             debugSymbolLevel = "FULL" | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     buildTypes { | ||||
|         release { | ||||
|             isMinifyEnabled = true | ||||
|             isShrinkResources = true | ||||
|             proguardFiles("proguard-rules.pro") | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     buildFeatures { | ||||
|         dataBinding = true | ||||
|     } | ||||
| @@ -49,14 +25,6 @@ android { | ||||
|     compileOptions { | ||||
|         isCoreLibraryDesugaringEnabled = true | ||||
|     } | ||||
|  | ||||
|     androidComponents { | ||||
|         onVariants { | ||||
|             it.instrumentation.setAsmFramesComputationMode(COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS) | ||||
|             it.instrumentation.transformClassesWith( | ||||
|                 DesugarClassVisitorFactory::class.java, InstrumentationScope.ALL) {} | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| dependencies { | ||||
|   | ||||
| @@ -19,6 +19,7 @@ android { | ||||
|         buildConfigField("int", "APP_VERSION_CODE", "${Config.versionCode}") | ||||
|         buildConfigField("String", "APP_VERSION_NAME", "\"${Config.version}\"") | ||||
|         buildConfigField("int", "STUB_VERSION", Config.stubVersion) | ||||
|         consumerProguardFile("proguard-rules.pro") | ||||
|     } | ||||
|  | ||||
|     buildFeatures { | ||||
|   | ||||
| @@ -22,28 +22,17 @@ | ||||
|   int mActivityHandlesConfigFlags; | ||||
| } | ||||
| 
 | ||||
| # main | ||||
| -keep,allowoptimization public class com.topjohnwu.magisk.signing.SignBoot { | ||||
|     public static void main(java.lang.String[]); | ||||
| } | ||||
| 
 | ||||
| # Strip Timber verbose and debug logging | ||||
| -assumenosideeffects class timber.log.Timber$Tree { | ||||
|   public void v(**); | ||||
|   public void d(**); | ||||
| } | ||||
| 
 | ||||
| # https://github.com/square/retrofit/issues/3751#issuecomment-1192043644 | ||||
| # Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items). | ||||
| -keep,allowobfuscation,allowshrinking interface retrofit2.Call | ||||
| -keep,allowobfuscation,allowshrinking class retrofit2.Response | ||||
| 
 | ||||
| # With R8 full mode generic signatures are stripped for classes that are not | ||||
| # kept. Suspend functions are wrapped in continuations where the type argument | ||||
| # is used. | ||||
| -keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation | ||||
| 
 | ||||
| 
 | ||||
| # Excessive obfuscation | ||||
| -repackageclasses 'a' | ||||
| -allowaccessmodification | ||||
| @@ -27,8 +27,6 @@ android { | ||||
|  | ||||
|     buildTypes { | ||||
|         release { | ||||
|             isMinifyEnabled = true | ||||
|             isShrinkResources = false | ||||
|             proguardFiles("proguard-rules.pro") | ||||
|         } | ||||
|     } | ||||
| @@ -38,7 +36,7 @@ android { | ||||
|     } | ||||
| } | ||||
|  | ||||
| setupStub() | ||||
| setupStubApk() | ||||
|  | ||||
| dependencies { | ||||
|     implementation(project(":app:shared")) | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| import com.android.build.api.artifact.ArtifactTransformationRequest | ||||
| import com.android.build.api.artifact.SingleArtifact | ||||
| import com.android.build.api.dsl.ApkSigningConfig | ||||
| import com.android.build.api.instrumentation.FramesComputationMode.COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS | ||||
| import com.android.build.api.instrumentation.InstrumentationScope | ||||
| import com.android.build.api.variant.ApplicationAndroidComponentsExtension | ||||
| import com.android.build.gradle.BaseExtension | ||||
| import com.android.build.gradle.LibraryExtension | ||||
| @@ -15,6 +17,8 @@ import org.gradle.api.Action | ||||
| import org.gradle.api.DefaultTask | ||||
| import org.gradle.api.JavaVersion | ||||
| import org.gradle.api.Project | ||||
| import org.gradle.api.artifacts.Dependency | ||||
| import org.gradle.api.artifacts.dsl.DependencyHandler | ||||
| import org.gradle.api.file.DirectoryProperty | ||||
| import org.gradle.api.provider.Property | ||||
| import org.gradle.api.tasks.Copy | ||||
| @@ -27,6 +31,7 @@ import org.gradle.api.tasks.StopExecutionException | ||||
| import org.gradle.api.tasks.Sync | ||||
| import org.gradle.api.tasks.TaskAction | ||||
| import org.gradle.kotlin.dsl.assign | ||||
| import org.gradle.kotlin.dsl.dependencies | ||||
| import org.gradle.kotlin.dsl.exclude | ||||
| import org.gradle.kotlin.dsl.filter | ||||
| import org.gradle.kotlin.dsl.get | ||||
| @@ -310,6 +315,10 @@ fun Project.setupAppCommon() { | ||||
|                     else signingConfigs["debug"] | ||||
|                 } | ||||
|             } | ||||
|             release { | ||||
|                 isMinifyEnabled = true | ||||
|                 isShrinkResources = true | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         lint { | ||||
| @@ -348,7 +357,34 @@ fun Project.setupAppCommon() { | ||||
|     } | ||||
| } | ||||
|  | ||||
| fun Project.setupStub() { | ||||
| fun Project.setupMainApk() { | ||||
|     setupAppCommon() | ||||
|  | ||||
|     android { | ||||
|         namespace = "com.topjohnwu.magisk" | ||||
|  | ||||
|         defaultConfig { | ||||
|             applicationId = "com.topjohnwu.magisk" | ||||
|             vectorDrawables.useSupportLibrary = true | ||||
|             versionName = Config.version | ||||
|             versionCode = Config.versionCode | ||||
|             ndk { | ||||
|                 abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64", "riscv64") | ||||
|                 debugSymbolLevel = "FULL" | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         androidComponents.onVariants { variant -> | ||||
|             variant.instrumentation.apply { | ||||
|                 setAsmFramesComputationMode(COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS) | ||||
|                 transformClassesWith( | ||||
|                     DesugarClassVisitorFactory::class.java, InstrumentationScope.ALL) {} | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| fun Project.setupStubApk() { | ||||
|     setupAppCommon() | ||||
|  | ||||
|     androidComponents.onVariants { variant -> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 topjohnwu
					topjohnwu