|
| 1 | +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
| 2 | + |
| 3 | +fun properties(key: String) = project.findProperty(key).toString() |
| 4 | + |
| 5 | +plugins { |
| 6 | + // Java support |
| 7 | + id("java") |
| 8 | + // Kotlin support |
| 9 | + id("org.jetbrains.kotlin.jvm") version "1.8.10" |
| 10 | + // Gradle IntelliJ Plugin |
| 11 | + id("org.jetbrains.intellij") version "1.13.3" |
| 12 | + // Gradle Changelog Plugin |
| 13 | + id("org.jetbrains.changelog") version "1.3.1" |
| 14 | + // Gradle Qodana Plugin |
| 15 | + id("org.jetbrains.qodana") version "0.1.13" |
| 16 | +} |
| 17 | + |
| 18 | +group = properties("pluginGroup") |
| 19 | +version = properties("pluginVersion") |
| 20 | + |
| 21 | +// Configure project's dependencies |
| 22 | +repositories { |
| 23 | + mavenCentral() |
| 24 | +} |
| 25 | + |
| 26 | +dependencies { |
| 27 | + implementation("org.junit.jupiter:junit-jupiter:5.8.2") |
| 28 | + testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.8.2") |
| 29 | +} |
| 30 | + |
| 31 | +// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin |
| 32 | +intellij { |
| 33 | + pluginName.set(properties("pluginName")) |
| 34 | + version.set(properties("platformVersion")) |
| 35 | + type.set(properties("platformType")) |
| 36 | + |
| 37 | + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. |
| 38 | + plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty)) |
| 39 | +} |
| 40 | + |
| 41 | +// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin |
| 42 | +changelog { |
| 43 | + version.set(properties("pluginVersion")) |
| 44 | + groups.set(emptyList()) |
| 45 | +} |
| 46 | + |
| 47 | +// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin |
| 48 | +qodana { |
| 49 | + cachePath.set(projectDir.resolve(".qodana").canonicalPath) |
| 50 | + reportPath.set(projectDir.resolve("build/reports/inspections").canonicalPath) |
| 51 | + saveReport.set(true) |
| 52 | + showReport.set(System.getenv("QODANA_SHOW_REPORT")?.toBoolean() ?: false) |
| 53 | +} |
| 54 | + |
| 55 | +tasks { |
| 56 | + // Set the JVM compatibility versions |
| 57 | + properties("javaVersion").let { |
| 58 | + withType<JavaCompile> { |
| 59 | + sourceCompatibility = it |
| 60 | + targetCompatibility = it |
| 61 | + } |
| 62 | + withType<KotlinCompile> { |
| 63 | + kotlinOptions.jvmTarget = it |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + wrapper { |
| 68 | + gradleVersion = properties("gradleVersion") |
| 69 | + } |
| 70 | + |
| 71 | + patchPluginXml { |
| 72 | + version.set(properties("pluginVersion")) |
| 73 | + sinceBuild.set(properties("pluginSinceBuild")) |
| 74 | + untilBuild.set(properties("pluginUntilBuild")) |
| 75 | + changeNotes.set(file("src/main/resources/META-INF/change-notes.html").readText().replace("<html>", "").replace("</html>", "")) |
| 76 | + |
| 77 | + // Get the latest available change notes from the changelog file |
| 78 | + // changeNotes.set(provider { |
| 79 | + // changelog.run { |
| 80 | + // getOrNull(properties("pluginVersion")) ?: getLatest() |
| 81 | + // }.toHTML() |
| 82 | + // }) |
| 83 | + } |
| 84 | + |
| 85 | + // Configure UI tests plugin |
| 86 | + // Read more: https://github.com/JetBrains/intellij-ui-test-robot |
| 87 | + runIdeForUiTests { |
| 88 | + systemProperty("robot-server.port", "8082") |
| 89 | + systemProperty("ide.mac.message.dialogs.as.sheets", "false") |
| 90 | + systemProperty("jb.privacy.policy.text", "<!--999.999-->") |
| 91 | + systemProperty("jb.consents.confirmation.enabled", "false") |
| 92 | + } |
| 93 | + |
| 94 | + signPlugin { |
| 95 | + certificateChain.set(System.getenv("CERTIFICATE_CHAIN")) |
| 96 | + privateKey.set(System.getenv("PRIVATE_KEY")) |
| 97 | + password.set(System.getenv("PRIVATE_KEY_PASSWORD")) |
| 98 | + } |
| 99 | + |
| 100 | + publishPlugin { |
| 101 | + // dependsOn("patchChangelog") |
| 102 | + token.set(System.getenv("PUBLISH_TOKEN")) |
| 103 | + // pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 |
| 104 | + // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: |
| 105 | + // https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel |
| 106 | + channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first())) |
| 107 | + } |
| 108 | + |
| 109 | + test { |
| 110 | + // Support "setUp" like "BasePlatformTestCase::setUp" as valid test structure |
| 111 | + useJUnitPlatform { |
| 112 | + includeEngines("junit-vintage") |
| 113 | + } |
| 114 | + } |
| 115 | +} |
0 commit comments