build.gradle.kts (228 lines of code) (raw):

import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.kotlin.dsl.testImplementation import org.jetbrains.changelog.Changelog import org.jetbrains.changelog.markdownToHTML import org.jetbrains.intellij.platform.gradle.Constants import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType import org.jetbrains.intellij.platform.gradle.TestFrameworkType import org.jetbrains.intellij.platform.gradle.tasks.PrepareSandboxTask import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import kotlin.io.path.absolute import kotlin.io.path.isDirectory import kotlin.io.path.isRegularFile plugins { alias(libs.plugins.kotlin) alias(libs.plugins.serialization) alias(libs.plugins.intelliJPlatform) alias(libs.plugins.changelog) } group = providers.gradleProperty("pluginGroup").get() version = providers.gradleProperty("pluginVersion").get() val dotnetBuildConfiguration = providers.gradleProperty("dotnetBuildConfiguration").get() val riderSdkPath by lazy { val path = intellijPlatform.platformPath.resolve("lib/DotNetSdkForRdPlugins").absolute() if (!path.isDirectory()) error("$path does not exist or not a directory") println("Rider SDK path: $path") return@lazy path } // Set the JVM language level used to build the project. kotlin { jvmToolchain(21) compilerOptions { freeCompilerArgs.add("-Xcontext-parameters") } } // Configure project's dependencies repositories { mavenCentral() // IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html intellijPlatform { defaultRepositories() jetbrainsRuntime() } } // Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/version_catalogs.html dependencies { // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html intellijPlatform { rider(providers.gradleProperty("platformVersion")) { useInstaller = false useCache = true } jetbrainsRuntime() pluginModule(implementation(project(":core"))) pluginModule(implementation(project(":diagram"))) pluginModule(implementation(project(":docker"))) pluginModule(implementation(project(":database"))) pluginModule(implementation(project(":rider"))) testFramework(TestFrameworkType.Bundled) testBundledPlugins("tanvd.grazi") } implementation(libs.serializationJson) testImplementation(libs.opentest4j) testImplementation(libs.junit) testImplementation(libs.testng) testImplementation(libs.kotlin.test) } // Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html intellijPlatform { instrumentCode = false pluginConfiguration { name = providers.gradleProperty("pluginName") version = providers.gradleProperty("pluginVersion") // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { val start = "<!-- Plugin description -->" val end = "<!-- Plugin description end -->" with(it.lines()) { if (!containsAll(listOf(start, end))) { throw GradleException("Plugin description section not found in README.md:\n$start ... $end") } subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML) } } val changelog = project.changelog // local variable for configuration cache compatibility // Get the latest available change notes from the changelog file changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion -> with(changelog) { renderItem( (getOrNull(pluginVersion) ?: getUnreleased()) .withHeader(false) .withEmptySections(false), Changelog.OutputType.HTML, ) } } ideaVersion { sinceBuild = providers.gradleProperty("pluginSinceBuild") } } signing { certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN") privateKey = providers.environmentVariable("PRIVATE_KEY") password = providers.environmentVariable("PRIVATE_KEY_PASSWORD") } publishing { token = providers.environmentVariable("PUBLISH_TOKEN") // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: // https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html#specifying-a-release-channel channels = providers.gradleProperty("pluginVersion") .map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) } hidden = true } pluginVerification { ides { create( IntelliJPlatformType.Rider, providers.gradleProperty("pluginVerificationIdeVersion").get() ) { useInstaller = false } } } } // Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin changelog { groups.empty() repositoryUrl = providers.gradleProperty("pluginRepositoryUrl") } tasks { wrapper { gradleVersion = providers.gradleProperty("gradleVersion").get() } val generateDotNetSdkProperties by registering { val dotNetSdkGeneratedPropsFile = projectDir.resolve("build/DotNetSdkPath.Generated.props") doLast { dotNetSdkGeneratedPropsFile.writeTextIfChanged(""" <Project> <PropertyGroup> <DotNetSdkPath>$riderSdkPath</DotNetSdkPath> </PropertyGroup> </Project> """.trimIndent()) } } val generateNuGetConfig by registering { val nuGetConfigFile = projectDir.resolve("nuget.config") doLast { nuGetConfigFile.writeTextIfChanged(""" <?xml version="1.0" encoding="utf-8"?> <!-- Auto-generated from 'generateNuGetConfig' task of old.build_gradle.kts --> <!-- Run `gradlew :prepare` to regenerate --> <configuration> <packageSources> <add key="rider-sdk" value="$riderSdkPath" /> </packageSources> </configuration> """.trimIndent()) } } val rdGen = ":protocol:rdgen" val prepareDotNetPart by registering { dependsOn(rdGen, generateDotNetSdkProperties, generateNuGetConfig) } val compileDotNet by registering(Exec::class) { dependsOn(prepareDotNetPart) inputs.property("dotnetBuildConfiguration", dotnetBuildConfiguration) executable("./dotnet.cmd") args("build", "-consoleLoggerParameters:ErrorsOnly", "-c", dotnetBuildConfiguration, "AspirePlugin.slnx") } withType<KotlinCompile> { dependsOn(rdGen) } val publishAspireWorker by registering(Exec::class) { dependsOn(compileDotNet) inputs.property("dotnetBuildConfiguration", dotnetBuildConfiguration) executable("./dotnet.cmd") args( "publish", "src/dotnet/AspireWorker/AspireWorker.csproj", "--configuration", dotnetBuildConfiguration ) } buildPlugin { dependsOn(publishAspireWorker) archiveBaseName.set("aspire-plugin") } withType<PrepareSandboxTask> { dependsOn(publishAspireWorker) val outputFolder = file("$projectDir/src/dotnet/AspirePlugin/bin/$dotnetBuildConfiguration") val pluginFiles = listOf( "$outputFolder/AspirePlugin.dll", "$outputFolder/AspirePlugin.pdb" ) for (f in pluginFiles) { from(f) { into("${rootProject.name}/dotnet") } } doLast { for (f in pluginFiles) { val file = file(f) if (!file.exists()) throw RuntimeException("File \"$file\" does not exist") } } from("$projectDir/src/dotnet/AspireWorker/bin/$dotnetBuildConfiguration/publish") { into("${rootProject.name}/AspireWorker") } } publishPlugin { dependsOn(patchChangelog) } test { useTestNG() testLogging { showStandardStreams = true exceptionFormat = TestExceptionFormat.FULL } environment["LOCAL_ENV_RUN"] = "true" } } val riderModel: Configuration by configurations.creating { isCanBeConsumed = true isCanBeResolved = false } artifacts { add(riderModel.name, provider { intellijPlatform.platformPath.resolve("lib/rd/rider-model.jar").also { check(it.isRegularFile()) { "rider-model.jar is not found at \"$it\"." } } }) { builtBy(Constants.Tasks.INITIALIZE_INTELLIJ_PLATFORM_PLUGIN) } } fun File.writeTextIfChanged(content: String) { val bytes = content.toByteArray() if (!exists() || !readBytes().contentEquals(bytes)) { println("Writing $path") parentFile.mkdirs() writeBytes(bytes) } }