Skip to content

Commit

Permalink
Merge main for 0.24.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
#	build.gradle.kts
#	buildSrc/settings.gradle.kts
#	buildSrc/src/main/kotlin/icon-keys-generator.gradle.kts
#	buildSrc/src/main/kotlin/jewel.gradle.kts
#	buildSrc/src/main/kotlin/org/jetbrains/jewel/buildlogic/ideversion/CheckIdeaVersionTask.kt
#	buildSrc/src/main/kotlin/org/jetbrains/jewel/buildlogic/theme/IntUiThemeDescriptorReader.kt
#	decorated-window/src/main/kotlin/org/jetbrains/jewel/window/TitleBar.Linux.kt
#	foundation/build.gradle.kts
#	gradle.properties
#	gradle/libs.versions.toml
#	ide-laf-bridge-tests/build.gradle.kts
#	ide-laf-bridge-tests/src/test/kotlin/org/jetbrains/jewel/bridge/actionSystem/ProvideDataTest.kt
#	ide-laf-bridge-tests/src/test/kotlin/org/jetbrains/jewel/bridge/actionSystem/TestDataSink.kt
#	ide-laf-bridge/build.gradle.kts
#	ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/BridgePainterHintsProvider.kt
#	ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/JewelComposePanel.kt
#	ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/ScrollbarHelper.kt
#	ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/actionSystem/ComponentDataProviderBridge.kt
#	ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/actionSystem/DataProviderDataSinkContext.kt
#	ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridge.kt
#	int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/StandalonePainterHintsProvider.kt
#	markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/processing/ProcessingUtil.kt
#	markdown/extension/gfm-alerts/src/main/kotlin/org/jetbrains/jewel/markdown/extensions/github/alerts/GitHubAlertBlockRenderer.kt
#	markdown/ide-laf-bridge-styling/build.gradle.kts
#	samples/ide-plugin/build.gradle.kts
#	samples/ide-plugin/src/main/kotlin/org/jetbrains/jewel/samples/ideplugin/ComponentShowcaseTab.kt
#	samples/ide-plugin/src/main/kotlin/org/jetbrains/jewel/samples/ideplugin/releasessample/ReleasesSampleCompose.kt
#	samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component/Buttons.kt
#	samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component/Dropdowns.kt
#	samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/component/TextFields.kt
#	samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/markdown/JewelReadme.kt
#	samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/viewmodel/ComponentsViewModel.kt
#	ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Checkbox.kt
#	ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Icon.kt
#	ui/src/main/kotlin/org/jetbrains/jewel/ui/component/Menu.kt
#	ui/src/main/kotlin/org/jetbrains/jewel/ui/component/RadioButton.kt
#	ui/src/main/kotlin/org/jetbrains/jewel/ui/component/SplitLayout.kt
#	ui/src/main/kotlin/org/jetbrains/jewel/ui/component/styling/CheckboxStyling.kt
#	ui/src/main/kotlin/org/jetbrains/jewel/ui/component/styling/RadioButtonStyling.kt
#	ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/PainterHintsProvider.kt
#	ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/PalettePainterHintsProvider.kt
#	ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/KeyBasedPaletteReplacement.kt
  • Loading branch information
rock3r committed Sep 6, 2024
2 parents 1492ef5 + 58213f4 commit c6eec8c
Show file tree
Hide file tree
Showing 49 changed files with 1,187 additions and 633 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- name: Run :check task
run: ./gradlew check --continue --no-daemon

- uses: github/codeql-action/upload-sarif@v3
if: ${{ always() }}
with:
sarif_file: ${{ github.workspace }}/build/reports/static-analysis.sarif
checkout_path: ${{ github.workspace }}
# - uses: github/codeql-action/upload-sarif@v3
# if: ${{ always() }}
# with:
# sarif_file: ${{ github.workspace }}/build/reports/static-analysis.sarif
# checkout_path: ${{ github.workspace }}
5 changes: 3 additions & 2 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions .idea/ktlint.xml

This file was deleted.

16 changes: 8 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ dependencies {
}

tasks {
val mergeSarifReports by
registering(MergeSarifTask::class) {
source(configurations.outgoingSarif)
include { it.file.extension == "sarif" }
}

register("check") { dependsOn(mergeSarifReports) }
}
// val mergeSarifReports by
// registering(MergeSarifTask::class) {
// source(configurations.outgoingSarif)
// include { it.file.extension == "sarif" }
// }
//
// register("check") { dependsOn(mergeSarifReports) }
}
2 changes: 1 addition & 1 deletion buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ dependencyResolutionManagement {
}

versionCatalogs { create("libs") { from(files("../gradle/libs.versions.toml")) } }
}
}
43 changes: 22 additions & 21 deletions buildSrc/src/main/kotlin/MergeSarifTask.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import io.github.detekt.sarif4k.Run
import io.github.detekt.sarif4k.SarifSchema210
import io.github.detekt.sarif4k.Tool
import io.github.detekt.sarif4k.ToolComponent
import io.github.detekt.sarif4k.Version
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.decodeFromStream
Expand All @@ -21,38 +24,36 @@ open class MergeSarifTask : SourceTask() {

@get:OutputFile
val mergedSarifPath: RegularFileProperty =
project.objects
.fileProperty()
.convention(project.layout.buildDirectory.file("reports/static-analysis.sarif"))
project.objects.fileProperty().convention(project.layout.buildDirectory.file("reports/static-analysis.sarif"))

@TaskAction
fun merge() {
val json = Json { prettyPrint = true }

logger.lifecycle("Merging ${source.files.size} SARIF file(s)...")
logger.lifecycle(
source.files.joinToString("\n") { " * ~${it.path.removePrefix(project.rootDir.path)}" }
)
logger.lifecycle(source.files.joinToString("\n") { " * ~${it.path.removePrefix(project.rootDir.path)}" })

val merged =
SarifSchema210(
schema = SARIF_SCHEMA,
version = Version.The210,
runs = source.files
.asSequence()
.filter { it.extension == "sarif" }
.map { file ->
file.inputStream().use { json.decodeFromStream<SarifSchema210>(it) }
}
.flatMap { report -> report.runs }
.groupBy { run -> run.tool.driver.guid ?: run.tool.driver.name }
.values
.asSequence()
.filter { it.isNotEmpty() }
.map { run ->
run.first().copy(results = run.flatMap { it.results ?: emptyList() })
}
.toList()
runs =
source.files
.asSequence()
.filter { it.extension == "sarif" }
.map { file -> file.inputStream().use { json.decodeFromStream<SarifSchema210>(it) } }
.flatMap { report -> report.runs }
.groupBy { run -> run.tool.driver.guid ?: run.tool.driver.name }
.values
.asSequence()
.filter { it.isNotEmpty() }
.map { runs ->
Run(
results = runs.flatMap { it.results.orEmpty() },
tool = Tool(driver = ToolComponent(name = "Jewel static analysis")),
)
}
.toList(),
)

logger.lifecycle("Merged SARIF file contains ${merged.runs.size} run(s)")
Expand Down
4 changes: 1 addition & 3 deletions buildSrc/src/main/kotlin/PublishConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ internal fun PublishingExtension.configureJewelRepositories(project: Project) {
}
}

maven(project.rootProject.layout.buildDirectory.dir("maven-test")) {
name = "LocalTest"
}
maven(project.rootProject.layout.buildDirectory.dir("maven-test")) { name = "LocalTest" }
}
}

Expand Down
47 changes: 23 additions & 24 deletions buildSrc/src/main/kotlin/ValidatePublicApiTask.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import java.io.File
import java.util.Stack
import java.util.regex.PatternSyntaxException
import org.gradle.api.GradleException
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.SourceTask
import org.gradle.api.tasks.TaskAction
import java.io.File
import java.util.Stack
import java.util.regex.PatternSyntaxException

@CacheableTask
open class ValidatePublicApiTask : SourceTask() {

@Input
var excludedClassRegexes: Set<String> = emptySet()
@Input var excludedClassRegexes: Set<String> = emptySet()

init {
group = "verification"
Expand All @@ -23,28 +22,29 @@ open class ValidatePublicApiTask : SourceTask() {
private val classFqnRegex = "public (?:\\w+ )*class (\\S+)\\b".toRegex()

@Suppress("ConvertToStringTemplate") // The odd concatenation is needed because of $; escapes get confused
private val copyMethodRegex =
("public static synthetic fun copy(-\\w+)?" + "\\$" + "default\\b").toRegex()
private val copyMethodRegex = ("public static synthetic fun copy(-\\w+)?" + "\\$" + "default\\b").toRegex()

@TaskAction
fun validatePublicApi() {
logger.info("Validating ${source.files.size} API file(s)...")

val violations = mutableMapOf<File, Set<String>>()
val excludedRegexes = excludedClassRegexes.map {
try {
it.toRegex()
} catch (ignored: PatternSyntaxException) {
throw GradleException("Invalid data exclusion regex: '$it'")
}
}.toSet()
val excludedRegexes =
excludedClassRegexes
.map {
try {
it.toRegex()
} catch (ignored: PatternSyntaxException) {
throw GradleException("Invalid data exclusion regex: '$it'")
}
}
.toSet()

inputs.files.forEach { apiFile ->
logger.lifecycle("Validating public API from file ${apiFile.path}")

apiFile.useLines { lines ->
val actualDataClasses = findDataClasses(lines)
.filterExclusions(excludedRegexes)
val actualDataClasses = findDataClasses(lines).filterExclusions(excludedRegexes)

if (actualDataClasses.isNotEmpty()) {
violations[apiFile] = actualDataClasses
Expand Down Expand Up @@ -101,23 +101,22 @@ open class ValidatePublicApiTask : SourceTask() {
}
}

val actualDataClasses =
dataClasses.filterValues { it.hasCopyMethod && !it.isLikelyValueClass }
.keys
val actualDataClasses = dataClasses.filterValues { it.hasCopyMethod && !it.isLikelyValueClass }.keys
return actualDataClasses
}

private fun Set<String>.filterExclusions(excludedRegexes: Set<Regex>): Set<String> {
if (excludedRegexes.isEmpty()) return this

return filterNot { dataClassFqn ->
val isExcluded = excludedRegexes.any { it.matchEntire(dataClassFqn) != null }
val isExcluded = excludedRegexes.any { it.matchEntire(dataClassFqn) != null }

if (isExcluded) {
logger.info(" Ignoring excluded data class $dataClassFqn")
if (isExcluded) {
logger.info(" Ignoring excluded data class $dataClassFqn")
}
isExcluded
}
isExcluded
}.toSet()
.toSet()
}
}

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/icon-keys-generator.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,4 @@ private data class IconKeyHolder(
val keys: MutableList<IconKey> = mutableListOf(),
)

private data class IconKey(val name: String, val oldPath: String, val newPath: String?)
private data class IconKey(val name: String, val oldPath: String, val newPath: String?)
8 changes: 7 additions & 1 deletion buildSrc/src/main/kotlin/jewel.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import com.ncorti.ktfmt.gradle.tasks.KtfmtBaseTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("jewel-linting")
kotlin("jvm")
Expand Down Expand Up @@ -37,6 +40,8 @@ val jdkLevel = project.property("jdk.level") as String
kotlin {
jvmToolchain { languageVersion = JavaLanguageVersion.of(jdkLevel) }

compilerOptions.jvmTarget.set(JvmTarget.fromTarget(jdkLevel))

target {
compilations.all { kotlinOptions { freeCompilerArgs += "-Xcontext-receivers" } }
sourceSets.all {
Expand Down Expand Up @@ -70,6 +75,7 @@ tasks {
}

formatKotlinMain { exclude { it.file.absolutePath.replace('\\', '/').contains("build/generated") } }
withType<KtfmtBaseTask> { exclude { it.file.absolutePath.contains("build/generated") } }

lintKotlinMain {
exclude { it.file.absolutePath.replace('\\', '/').contains("build/generated") }
Expand All @@ -89,4 +95,4 @@ configurations.named("sarif") {
artifact(tasks.detektMain.flatMap { it.sarifReportFile }) { builtBy(tasks.detektMain) }
artifact(sarifReport) { builtBy(tasks.lintKotlinMain) }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package org.jetbrains.jewel.buildlogic.demodata
import com.squareup.kotlinpoet.ClassName
import gradle.kotlin.dsl.accessors._34fcf23848cfa0f534eebf6913e08a53.kotlin
import gradle.kotlin.dsl.accessors._34fcf23848cfa0f534eebf6913e08a53.sourceSets
import java.io.File
import java.net.URI
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.decodeFromStream
import org.gradle.api.DefaultTask
Expand All @@ -19,52 +21,44 @@ import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.property
import org.gradle.kotlin.dsl.setProperty
import java.io.File
import java.net.URI

open class StudioVersionsGenerationExtension(project: Project) {

val targetDir: DirectoryProperty =
project.objects
.directoryProperty()
.convention(
project.layout.dir(
project.provider { project.sourceSets.named("main").get().kotlin.srcDirs.first() }
)
project.layout.dir(project.provider { project.sourceSets.named("main").get().kotlin.srcDirs.first() })
)

val resourcesDirs: SetProperty<File> =
project.objects
.setProperty<File>()
.convention(project.provider {
when {
project.plugins.hasPlugin("org.gradle.jvm-ecosystem") ->
project.extensions.getByType<SourceSetContainer>()["main"]
.resources.srcDirs
.convention(
project.provider {
when {
project.plugins.hasPlugin("org.gradle.jvm-ecosystem") ->
project.extensions.getByType<SourceSetContainer>()["main"].resources.srcDirs

else -> emptySet()
else -> emptySet()
}
}
})
)

val dataUrl: Property<String> =
project.objects
.property<String>()
.convention("https://jb.gg/android-studio-releases-list.json")
project.objects.property<String>().convention("https://jb.gg/android-studio-releases-list.json")
}

internal const val STUDIO_RELEASES_OUTPUT_CLASS_NAME =
"org.jetbrains.jewel.samples.ideplugin.releasessample.AndroidStudioReleases"

open class AndroidStudioReleasesGeneratorTask : DefaultTask() {

@get:OutputFile
val outputFile: RegularFileProperty = project.objects.fileProperty()
@get:OutputFile val outputFile: RegularFileProperty = project.objects.fileProperty()

@get:Input
val dataUrl = project.objects.property<String>()
@get:Input val dataUrl = project.objects.property<String>()

@get:Input
val resourcesDirs = project.objects.setProperty<File>()
@get:Input val resourcesDirs = project.objects.setProperty<File>()

init {
group = "jewel"
Expand All @@ -80,12 +74,8 @@ open class AndroidStudioReleasesGeneratorTask : DefaultTask() {
val lookupDirs = resourcesDirs.get()

logger.lifecycle("Fetching Android Studio releases list from $url...")
logger.debug(
"Registered resources directories:\n" +
lookupDirs.joinToString("\n") { " * ${it.absolutePath}" }
)
val releases = URI.create(url).toURL().openStream()
.use { json.decodeFromStream<ApiAndroidStudioReleases>(it) }
logger.debug("Registered resources directories:\n" + lookupDirs.joinToString("\n") { " * ${it.absolutePath}" })
val releases = URI.create(url).toURL().openStream().use { json.decodeFromStream<ApiAndroidStudioReleases>(it) }

val className = ClassName.bestGuess(STUDIO_RELEASES_OUTPUT_CLASS_NAME)
val file = AndroidStudioReleasesReader.readFrom(releases, className, url, lookupDirs)
Expand Down
Loading

0 comments on commit c6eec8c

Please sign in to comment.