Skip to content

Commit

Permalink
Align gradle-plugin's formatting with the rest of the project
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnatBeresnev committed Oct 19, 2023
1 parent e7565b4 commit 0beee0e
Show file tree
Hide file tree
Showing 145 changed files with 7,271 additions and 6,811 deletions.
328 changes: 166 additions & 162 deletions dokka-runners/gradle-plugin/build.gradle.kts

Large diffs are not rendered by default.

22 changes: 13 additions & 9 deletions dokka-runners/gradle-plugin/buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
/*
* Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

import org.gradle.kotlin.dsl.support.expectedKotlinDslPluginsVersion

plugins {
`kotlin-dsl`
`kotlin-dsl`
}

dependencies {
implementation("org.gradle.kotlin:gradle-kotlin-dsl-plugins:$expectedKotlinDslPluginsVersion")
implementation(libs.gradlePlugin.bcvMu)
implementation(libs.gradlePlugin.dokkatoo)
implementation(libs.gradlePlugin.gradlePublishPlugin)
implementation("org.jetbrains.kotlin:kotlin-serialization:$embeddedKotlinVersion")
implementation("org.gradle.kotlin:gradle-kotlin-dsl-plugins:$expectedKotlinDslPluginsVersion")
implementation(libs.gradlePlugin.bcvMu)
implementation(libs.gradlePlugin.dokkatoo)
implementation(libs.gradlePlugin.gradlePublishPlugin)
implementation("org.jetbrains.kotlin:kotlin-serialization:$embeddedKotlinVersion")
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
30 changes: 15 additions & 15 deletions dokka-runners/gradle-plugin/buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@
rootProject.name = "buildSrc"

pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
google()
}
repositories {
mavenCentral()
gradlePluginPortal()
google()
}
}

@Suppress("UnstableApiUsage")
dependencyResolutionManagement {

repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)

repositories {
mavenCentral()
gradlePluginPortal()
google()
}
repositories {
mavenCentral()
gradlePluginPortal()
google()
}

versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

package buildsrc.conventions

import org.jetbrains.kotlin.util.suffixIfNot
Expand All @@ -8,71 +12,71 @@ import org.jetbrains.kotlin.util.suffixIfNot
*/

plugins {
base
id("buildsrc.conventions.base")
base
id("buildsrc.conventions.base")
}


val androidSdkDirPath: Provider<String> = providers
// first try getting the SDK installed on via GitHub step setup-android
.environmentVariable("ANDROID_SDK_ROOT").map(::File)
// else get the project-local SDK
.orElse(layout.projectDirectory.file("projects/ANDROID_SDK").asFile)
.map { it.invariantSeparatorsPath }
// first try getting the SDK installed on via GitHub step setup-android
.environmentVariable("ANDROID_SDK_ROOT").map(::File)
// else get the project-local SDK
.orElse(layout.projectDirectory.file("projects/ANDROID_SDK").asFile)
.map { it.invariantSeparatorsPath }


val createAndroidLocalPropertiesFile by tasks.registering {

val localPropertiesFile = temporaryDir.resolve("local.properties")
outputs.file(localPropertiesFile).withPropertyName("localPropertiesFile")
val localPropertiesFile = temporaryDir.resolve("local.properties")
outputs.file(localPropertiesFile).withPropertyName("localPropertiesFile")

val androidSdkDirPath = androidSdkDirPath
inputs.property("androidSdkDirPath", androidSdkDirPath)
val androidSdkDirPath = androidSdkDirPath
inputs.property("androidSdkDirPath", androidSdkDirPath)

doLast {
localPropertiesFile.apply {
parentFile.mkdirs()
createNewFile()
writeText(
"""
doLast {
localPropertiesFile.apply {
parentFile.mkdirs()
createNewFile()
writeText(
"""
|# DO NOT EDIT - Generated by $path
|
|sdk.dir=${androidSdkDirPath.get()}
|
""".trimMargin()
)
)
}
}
}
}


val updateAndroidLocalProperties by tasks.registering {

// find all local.properties files
val localPropertiesFiles = layout.projectDirectory.dir("projects")
.asFileTree
.matching { include("**/local.properties") }
.files

outputs.files(localPropertiesFiles).withPropertyName("localPropertiesFiles")

val androidSdkDirPath = androidSdkDirPath
inputs.property("androidSdkDirPath", androidSdkDirPath)

doLast {
localPropertiesFiles
.filter { it.exists() }
.forEach { file ->
file.writeText(
file.useLines { lines ->
lines.joinToString("\n") { line ->
when {
line.startsWith("sdk.dir=") -> "sdk.dir=${androidSdkDirPath.get()}"
else -> line
}
}.suffixIfNot("\n")
}
)
}
}
// find all local.properties files
val localPropertiesFiles = layout.projectDirectory.dir("projects")
.asFileTree
.matching { include("**/local.properties") }
.files

outputs.files(localPropertiesFiles).withPropertyName("localPropertiesFiles")

val androidSdkDirPath = androidSdkDirPath
inputs.property("androidSdkDirPath", androidSdkDirPath)

doLast {
localPropertiesFiles
.filter { it.exists() }
.forEach { file ->
file.writeText(
file.useLines { lines ->
lines.joinToString("\n") { line ->
when {
line.startsWith("sdk.dir=") -> "sdk.dir=${androidSdkDirPath.get()}"
else -> line
}
}.suffixIfNot("\n")
}
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

package buildsrc.conventions

import java.time.Duration
Expand All @@ -8,67 +12,67 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
*/

plugins {
base
base
}

if (project != rootProject) {
project.version = rootProject.version
project.group = rootProject.group
project.version = rootProject.version
project.group = rootProject.group
}

tasks.withType<AbstractArchiveTask>().configureEach {
// https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
// https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}

tasks.withType<AbstractTestTask>().configureEach {
timeout.set(Duration.ofMinutes(60))

testLogging {
showCauses = true
showExceptions = true
showStackTraces = true
showStandardStreams = true
events(
TestLogEvent.PASSED,
TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.STARTED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT,
)
}
timeout.set(Duration.ofMinutes(60))

testLogging {
showCauses = true
showExceptions = true
showStackTraces = true
showStandardStreams = true
events(
TestLogEvent.PASSED,
TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.STARTED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT,
)
}
}

tasks.withType<AbstractCopyTask>().configureEach {
includeEmptyDirs = false
includeEmptyDirs = false
}

val updateTestReportCss by tasks.registering {
description = "Hack so the Gradle test reports have dark mode"
// the CSS is based on https://github.com/gradle/gradle/pull/12177
description = "Hack so the Gradle test reports have dark mode"
// the CSS is based on https://github.com/gradle/gradle/pull/12177

mustRunAfter(tasks.withType<Test>())
mustRunAfter(tasks.withType<TestReport>())
mustRunAfter(tasks.withType<Test>())
mustRunAfter(tasks.withType<TestReport>())

val cssFiles = layout.buildDirectory.asFileTree.matching {
include("reports/**/css/base-style.css")
include("reports/**/css/style.css")
}
val cssFiles = layout.buildDirectory.asFileTree.matching {
include("reports/**/css/base-style.css")
include("reports/**/css/style.css")
}

outputs.files(cssFiles.files)
outputs.files(cssFiles.files)

doLast {
cssFiles.forEach { cssFile ->
val fileContent = cssFile.readText()
doLast {
cssFiles.forEach { cssFile ->
val fileContent = cssFile.readText()

if ("/* Dark mode */" in fileContent) {
return@forEach
} else {
when (cssFile.name) {
"base-style.css" -> cssFile.writeText(
fileContent + """
if ("/* Dark mode */" in fileContent) {
return@forEach
} else {
when (cssFile.name) {
"base-style.css" -> cssFile.writeText(
fileContent + """
/* Dark mode */
@media (prefers-color-scheme: dark) {
Expand Down Expand Up @@ -101,10 +105,10 @@ val updateTestReportCss by tasks.registering {
}
}
""".trimIndent()
)
)

"style.css" -> cssFile.writeText(
fileContent + """
"style.css" -> cssFile.writeText(
fileContent + """
/* Dark mode */
@media (prefers-color-scheme: dark) {
Expand Down Expand Up @@ -133,23 +137,23 @@ val updateTestReportCss by tasks.registering {
}
}
""".trimIndent()
)
)
}
}
}
}
}
}
}

tasks.withType<Test>().configureEach {
finalizedBy(updateTestReportCss)
finalizedBy(updateTestReportCss)
}

tasks.withType<TestReport>().configureEach {
finalizedBy(updateTestReportCss)
finalizedBy(updateTestReportCss)
}

tasks.matching { it.name == "validatePlugins" }.configureEach {
// prevent warning
// Task ':validatePlugins' uses this output of task ':updateTestReportCss' without declaring an explicit or implicit dependency.
mustRunAfter(updateTestReportCss)
// prevent warning
// Task ':validatePlugins' uses this output of task ':updateTestReportCss' without declaring an explicit or implicit dependency.
mustRunAfter(updateTestReportCss)
}
Loading

0 comments on commit 0beee0e

Please sign in to comment.