From 735f028722e45c024b3f159d6ac55d8f2031a918 Mon Sep 17 00:00:00 2001 From: Matthew Haughton <3flex@users.noreply.github.com> Date: Sat, 20 Jan 2024 22:49:25 +1100 Subject: [PATCH] Remove buildSrc (#301) * Remove redundant extensions * Remove redundant receiver parameter * Simplify call chain * Apply idea-ext plugin in root build file * Migrate buildSrc to build file --- build.gradle.kts | 9 ++++- buildSrc/build.gradle.kts | 11 ------ buildSrc/settings.gradle.kts | 0 buildSrc/src/main/kotlin/IdeaExtExtensions.kt | 36 ------------------- 4 files changed, 8 insertions(+), 48 deletions(-) delete mode 100644 buildSrc/build.gradle.kts delete mode 100644 buildSrc/settings.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/IdeaExtExtensions.kt diff --git a/build.gradle.kts b/build.gradle.kts index 1a018e0d..abc21a8e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,14 +1,17 @@ import org.gradle.initialization.IGradlePropertiesLoader.ENV_PROJECT_PROPERTIES_PREFIX import org.gradle.initialization.IGradlePropertiesLoader.SYSTEM_PROJECT_PROPERTIES_PREFIX import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.gradle.ext.copyright +import org.jetbrains.gradle.ext.settings import org.jetbrains.kotlin.gradle.dsl.KotlinVersion +import kotlin.math.min plugins { id("org.jetbrains.kotlin.jvm") version "1.8.22" id("com.gradle.plugin-publish") version "1.2.1" id("com.diffplug.spotless") version "6.24.0" id("com.github.johnrengelman.shadow") version "8.1.1" - id("org.jetbrains.gradle.plugin.idea-ext") + id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7" id("com.github.ben-manes.versions") version "0.50.0" id("org.ajoberstar.stutter") version "0.7.3" } @@ -41,6 +44,10 @@ repositories { } val licenseHeaderFile = file("gradle/license-header.txt") +fun readCopyrightHeader(licenseHeaderFile: File) = + licenseHeaderFile.readLines() + .joinToString("\n") { line -> line.substring(min(line.length, 3)) } + .trim() spotless { lineEndings = com.diffplug.spotless.LineEnding.UNIX kotlin { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index e5a0a81d..00000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,11 +0,0 @@ -plugins { - `kotlin-dsl` -} - -repositories { - gradlePluginPortal() -} - -dependencies { - implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:1.1.7") -} diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts deleted file mode 100644 index e69de29b..00000000 diff --git a/buildSrc/src/main/kotlin/IdeaExtExtensions.kt b/buildSrc/src/main/kotlin/IdeaExtExtensions.kt deleted file mode 100644 index d6cd9d40..00000000 --- a/buildSrc/src/main/kotlin/IdeaExtExtensions.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.gradle.api.Project -import org.gradle.api.plugins.ExtensionAware -import org.gradle.kotlin.dsl.configure -import org.gradle.plugins.ide.idea.model.IdeaProject -import org.jetbrains.gradle.ext.CopyrightConfiguration -import org.jetbrains.gradle.ext.ProjectSettings -import java.io.File -import kotlin.math.min - -fun IdeaProject.settings(configuration: ProjectSettings.() -> kotlin.Unit) = - (this as ExtensionAware).configure(configuration) - -fun ProjectSettings.copyright(configuration: CopyrightConfiguration.() -> kotlin.Unit) = - (this as ExtensionAware).configure(configuration) - -fun Project.readCopyrightHeader(licenseHeaderFile: File) = - licenseHeaderFile.readLines() - .map { line -> line.substring(min(line.length, 3)) } - .joinToString("\n") - .trim()