Use simple property assignment

This commit is contained in:
LoveSy 2024-07-10 22:32:38 +08:00 committed by John Wu
parent 0185ddf577
commit ea4cabdfc5
2 changed files with 11 additions and 10 deletions

View File

@ -25,6 +25,7 @@ import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.StopExecutionException import org.gradle.api.tasks.StopExecutionException
import org.gradle.api.tasks.Sync import org.gradle.api.tasks.Sync
import org.gradle.api.tasks.TaskAction import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.assign
import org.gradle.kotlin.dsl.exclude import org.gradle.kotlin.dsl.exclude
import org.gradle.kotlin.dsl.filter import org.gradle.kotlin.dsl.filter
import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.get
@ -103,7 +104,7 @@ fun Project.setupCommon() {
tasks.withType<KotlinCompile> { tasks.withType<KotlinCompile> {
compilerOptions { compilerOptions {
jvmTarget.set(JvmTarget.JVM_17) jvmTarget = JvmTarget.JVM_17
} }
} }
} }
@ -302,12 +303,12 @@ fun Project.setupAppCommon() {
.toTransformMany(SingleArtifact.APK) .toTransformMany(SingleArtifact.APK)
val signingConfig = androidApp.buildTypes.getByName(variant.buildType!!).signingConfig val signingConfig = androidApp.buildTypes.getByName(variant.buildType!!).signingConfig
commentTask.configure { commentTask.configure {
this.transformationRequest.set(transformationRequest) this.transformationRequest = transformationRequest
this.signingConfig.set(signingConfig) this.signingConfig = signingConfig
this.comment.set("version=${Config.version}\n" + this.comment = "version=${Config.version}\n" +
"versionCode=${Config.versionCode}\n" + "versionCode=${Config.versionCode}\n" +
"stubVersion=${Config.stubVersion}\n") "stubVersion=${Config.stubVersion}\n"
this.outFolder.set(layout.buildDirectory.dir("outputs/apk/${variant.name}")) this.outFolder = layout.buildDirectory.dir("outputs/apk/${variant.name}")
} }
} }
} }
@ -321,9 +322,9 @@ fun Project.setupStub() {
val manifestUpdater = val manifestUpdater =
project.tasks.register("${variantName}ManifestProducer", ManifestUpdater::class.java) { project.tasks.register("${variantName}ManifestProducer", ManifestUpdater::class.java) {
dependsOn("generate${variantCapped}ObfuscatedClass") dependsOn("generate${variantCapped}ObfuscatedClass")
applicationId.set(variant.applicationId) applicationId = variant.applicationId
appClassDir.set(layout.buildDirectory.dir("generated/source/app/$variantName")) appClassDir = layout.buildDirectory.dir("generated/source/app/$variantName")
factoryClassDir.set(layout.buildDirectory.dir("generated/source/factory/$variantName")) factoryClassDir = layout.buildDirectory.dir("generated/source/factory/$variantName")
} }
variant.artifacts.use(manifestUpdater) variant.artifacts.use(manifestUpdater)
.wiredWithFiles( .wiredWithFiles(

View File

@ -1,6 +1,6 @@
@Suppress("UnstableApiUsage") @Suppress("UnstableApiUsage")
dependencyResolutionManagement { dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
repositories { repositories {
google() google()
mavenCentral() mavenCentral()