diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2289703bc..48d5b90fc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,22 +53,8 @@ jobs: - name: Run :check task run: ./gradlew check -Psupported.ij.version=${{ matrix.supported-ij-version }} --continue - - name: Merge SARIF reports - # Necessary because upload-sarif only takes up to 15 SARIF files and we have more - run: ./gradlew :mergeSarifReports -Psupported.ij.version=${{ matrix.supported-ij-version }} - if: ${{ always() }} - - uses: github/codeql-action/upload-sarif@v2 if: ${{ always() }} with: sarif_file: ${{ github.workspace }}/build/reports/static-analysis.sarif checkout_path: ${{ github.workspace }} - - - name: Upload reports for manual analysis - uses: actions/upload-artifact@v3 - if: failure() - with: - name: Static analysis SARIF reports - path: ${{ github.workspace }}/build/reports/*.sarif - retention-days: 7 - if-no-files-found: error diff --git a/build.gradle.kts b/build.gradle.kts index 9e10644fa..215cf0918 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,24 +1,27 @@ plugins { alias(libs.plugins.composeDesktop) apply false -} - -val sarif: Configuration by configurations.creating { - isCanBeResolved = true - attributes { - attribute(Usage.USAGE_ATTRIBUTE, objects.named("sarif")) - } + `jewel-linting` } dependencies { sarif(projects.core) sarif(projects.samples.standalone) sarif(projects.intUi.intUiStandalone) + sarif(projects.intUi.intUiDecoratedWindow) sarif(projects.intUi.intUiCore) + sarif(projects.ideLafBridge) + sarif(projects.ideLafBridge.ideLafBridge232) + sarif(projects.ideLafBridge.ideLafBridge233) + sarif(projects.decoratedWindow) + sarif(projects.samples.idePlugin) } tasks { - register("mergeSarifReports") { - source(sarif) + val mergeSarifReports by registering(MergeSarifTask::class) { + source(configurations.outgoingSarif) include { it.file.extension == "sarif" } } + register("check") { + dependsOn(mergeSarifReports) + } } diff --git a/buildSrc/src/main/kotlin/jewel-linting.gradle.kts b/buildSrc/src/main/kotlin/jewel-linting.gradle.kts new file mode 100644 index 000000000..678082029 --- /dev/null +++ b/buildSrc/src/main/kotlin/jewel-linting.gradle.kts @@ -0,0 +1,20 @@ +@file:Suppress("UnstableApiUsage") + +plugins { + id("io.gitlab.arturbosch.detekt") + id("org.jmailen.kotlinter") +} + +configurations { + val dependencies = register("sarif") { + isCanBeDeclared = true + } + register("outgoingSarif") { + isCanBeConsumed = true + isCanBeResolved = true + extendsFrom(dependencies.get()) + attributes { + attribute(Usage.USAGE_ATTRIBUTE, objects.named("sarif")) + } + } +} diff --git a/buildSrc/src/main/kotlin/jewel.gradle.kts b/buildSrc/src/main/kotlin/jewel.gradle.kts index 8e723aa65..32d408108 100644 --- a/buildSrc/src/main/kotlin/jewel.gradle.kts +++ b/buildSrc/src/main/kotlin/jewel.gradle.kts @@ -1,13 +1,10 @@ -@file:Suppress("UnstableApiUsage") - import io.gitlab.arturbosch.detekt.Detekt import org.gradle.api.attributes.Usage import org.jmailen.gradle.kotlinter.tasks.FormatTask import org.jmailen.gradle.kotlinter.tasks.LintTask plugins { - id("io.gitlab.arturbosch.detekt") - id("org.jmailen.kotlinter") + id("jewel-linting") kotlin("jvm") } @@ -49,36 +46,20 @@ detekt { buildUponDefaultConfig = true } -val sarif: Configuration by configurations.creating { - isCanBeConsumed = true - attributes { - attribute(Usage.USAGE_ATTRIBUTE, objects.named("sarif")) - } -} +val sarifReport = layout.buildDirectory.file("reports/ktlint-${project.name}.sarif") tasks { - withType { + detektMain { val sarifOutputFile = layout.buildDirectory.file("reports/detekt-${project.name}.sarif") exclude { it.file.absolutePath.startsWith(layout.buildDirectory.asFile.get().absolutePath) } reports { sarif.required = true sarif.outputLocation = sarifOutputFile } - sarif.outgoing { - artifact(sarifOutputFile) { - builtBy(this@withType) - } - } } - - withType { + lintKotlinMain { exclude { it.file.absolutePath.contains("build/generated") } - } - withType { - exclude { it.file.absolutePath.contains("build/generated") } - - val sarifReport = layout.buildDirectory.file("reports/ktlint-${project.name}.sarif") reports = provider { mapOf( "plain" to layout.buildDirectory.file("reports/ktlint-${project.name}.txt").get().asFile, @@ -86,11 +67,25 @@ tasks { "sarif" to sarifReport.get().asFile ) } + } +} - sarif.outgoing { - artifact(sarifReport) { - builtBy(this@withType) - } +configurations.named("sarif") { + outgoing { + artifact(tasks.detektMain.flatMap { it.sarifReportFile }) { + builtBy(tasks.detektMain) + } + artifact(sarifReport) { + builtBy(tasks.lintKotlinMain) } } } + +fun Task.removeAssembleDependency() { + setDependsOn(dependsOn.filter { + when { + it is Task && it.name == "assemble" -> false + else -> true + } + }) +} \ No newline at end of file diff --git a/decorated-window/build.gradle.kts b/decorated-window/build.gradle.kts index 2e7691407..f3208e4b5 100644 --- a/decorated-window/build.gradle.kts +++ b/decorated-window/build.gradle.kts @@ -7,7 +7,8 @@ plugins { alias(libs.plugins.composeDesktop) } -private val composeVersion get() = ComposeBuildConfig.composeVersion +private val composeVersion + get() = ComposeBuildConfig.composeVersion dependencies { api("org.jetbrains.compose.foundation:foundation-desktop:$composeVersion") diff --git a/settings.gradle.kts b/settings.gradle.kts index 9941b2705..6a0e22e1d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -25,6 +25,10 @@ dependencyResolutionManagement { } } +plugins { + id("com.gradle.enterprise") version "3.15.1" +} + include( ":core", ":decorated-window", @@ -37,3 +41,11 @@ include( ":int-ui:int-ui-decorated-window", ":int-ui:int-ui-standalone", ) + +gradleEnterprise { + buildScan { + publishAlwaysIf(System.getenv("CI") == "true") + termsOfServiceUrl = "https://gradle.com/terms-of-service" + termsOfServiceAgree = "yes" + } +} \ No newline at end of file