buildSrc: remove code superseded by convention plugins

This commit is contained in:
Harsh Shandilya 2021-11-16 00:09:19 +05:30
parent 0fad4d24b5
commit 40e65e1a8b
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
6 changed files with 0 additions and 111 deletions

View file

@ -41,5 +41,4 @@ dependencies {
implementation("de.undercouch:gradle-download-task:4.1.2")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.5.31")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31")
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.6.0")
}

View file

@ -7,47 +7,8 @@ import com.android.build.gradle.TestedExtension
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.tasks.testing.Test
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.gradle.api.tasks.wrapper.Wrapper
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.withType
import org.gradle.language.nativeplatform.internal.BuildType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
/**
* Configure root project. Note that classpath dependencies still need to be defined in the
* `buildscript` block in the top-level build.gradle.kts file.
*/
internal fun Project.configureForRootProject() {
tasks.withType<Wrapper> {
gradleVersion = "7.3"
distributionSha256Sum = "de8f52ad49bdc759164f72439a3bf56ddb1589c4cde802d3cec7d6ad0e0ee410"
}
configureBinaryCompatibilityValidator()
tasks.register<GitHooks>("installGitHooks") {
val projectDirectory = layout.projectDirectory
hookScript.set(projectDirectory.file("scripts/pre-push-hook.sh").asFile.readText())
hookOutput.set(projectDirectory.file(".git/hooks/pre-push").asFile)
}
}
/** Configure all projects including the root project */
internal fun Project.configureForAllProjects() {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
allWarningsAsErrors = true
jvmTarget = JavaVersion.VERSION_11.toString()
freeCompilerArgs = freeCompilerArgs + additionalCompilerArgs
languageVersion = "1.5"
}
}
tasks.withType<Test>().configureEach {
maxParallelForks = Runtime.getRuntime().availableProcessors() * 2
testLogging { events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED) }
outputs.upToDateWhen { false }
}
}
/** Checks if we're building a snapshot */
@Suppress("UnstableApiUsage")

View file

@ -1,12 +0,0 @@
/*
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
import kotlinx.validation.ApiValidationExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
internal fun Project.configureBinaryCompatibilityValidator() {
extensions.configure<ApiValidationExtension> { ignoredProjects = mutableSetOf("app") }
}

View file

@ -1,44 +0,0 @@
/*
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
import java.io.File
import java.nio.file.Files
import java.nio.file.attribute.PosixFilePermission.GROUP_EXECUTE
import java.nio.file.attribute.PosixFilePermission.GROUP_READ
import java.nio.file.attribute.PosixFilePermission.OTHERS_EXECUTE
import java.nio.file.attribute.PosixFilePermission.OTHERS_READ
import java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE
import java.nio.file.attribute.PosixFilePermission.OWNER_READ
import java.nio.file.attribute.PosixFilePermission.OWNER_WRITE
import org.gradle.api.DefaultTask
import org.gradle.api.provider.Property
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
@CacheableTask
abstract class GitHooks : DefaultTask() {
@get:Input abstract val hookScript: Property<String>
@get:OutputFile abstract val hookOutput: Property<File>
@TaskAction
fun install() {
hookOutput.get().writeText(hookScript.get())
Files.setPosixFilePermissions(
hookOutput.get().toPath(),
setOf(
OWNER_READ,
OWNER_WRITE,
OWNER_EXECUTE,
GROUP_READ,
GROUP_EXECUTE,
OTHERS_READ,
OTHERS_EXECUTE,
)
)
}
}

View file

@ -1,6 +0,0 @@
/*
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
internal val additionalCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn")

View file

@ -25,12 +25,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
class PasswordStorePlugin : Plugin<Project> {
override fun apply(project: Project) {
project.configureForAllProjects()
if (project.isRoot) {
project.configureForRootProject()
}
project.plugins.all {
when (this) {
is JavaPlugin, is JavaLibraryPlugin -> {
@ -77,6 +71,3 @@ class PasswordStorePlugin : Plugin<Project> {
}
}
}
private val Project.isRoot
get() = this == this.rootProject