|
| 1 | +import org.jetbrains.changelog.markdownToHTML |
| 2 | +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
| 3 | + |
| 4 | +fun properties(key: String) = project.findProperty(key).toString() |
| 5 | + |
| 6 | +plugins { |
| 7 | + // Java support |
| 8 | + id("java") |
| 9 | + // Kotlin support |
| 10 | + id("org.jetbrains.kotlin.jvm") version "1.6.10" |
| 11 | + // Gradle IntelliJ Plugin |
| 12 | + id("org.jetbrains.intellij") version "1.4.0" |
| 13 | + // Gradle Changelog Plugin |
| 14 | + id("org.jetbrains.changelog") version "1.3.1" |
| 15 | +} |
| 16 | + |
| 17 | +group = properties("pluginGroup") |
| 18 | +version = properties("pluginVersion") |
| 19 | + |
| 20 | +// Configure project's dependencies |
| 21 | +repositories { |
| 22 | + mavenCentral() |
| 23 | +} |
| 24 | + |
| 25 | +// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin |
| 26 | +intellij { |
| 27 | + pluginName.set(properties("pluginName")) |
| 28 | + version.set(properties("platformVersion")) |
| 29 | + type.set(properties("platformType")) |
| 30 | + |
| 31 | + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. |
| 32 | + plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty)) |
| 33 | +} |
| 34 | + |
| 35 | +// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin |
| 36 | +changelog { |
| 37 | + version.set(properties("pluginVersion")) |
| 38 | + groups.set(emptyList()) |
| 39 | +} |
| 40 | + |
| 41 | +tasks { |
| 42 | + // Set the JVM compatibility versions |
| 43 | + properties("javaVersion").let { |
| 44 | + withType<JavaCompile> { |
| 45 | + sourceCompatibility = it |
| 46 | + targetCompatibility = it |
| 47 | + } |
| 48 | + withType<KotlinCompile> { |
| 49 | + kotlinOptions.jvmTarget = it |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + wrapper { |
| 54 | + gradleVersion = properties("gradleVersion") |
| 55 | + } |
| 56 | + |
| 57 | + patchPluginXml { |
| 58 | + version.set(properties("pluginVersion")) |
| 59 | + sinceBuild.set(properties("pluginSinceBuild")) |
| 60 | + untilBuild.set(properties("pluginUntilBuild")) |
| 61 | + |
| 62 | + // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest |
| 63 | + pluginDescription.set( |
| 64 | + projectDir.resolve("README.md").readText().lines().run { |
| 65 | + val start = "<!-- Plugin description -->" |
| 66 | + val end = "<!-- Plugin description end -->" |
| 67 | + |
| 68 | + if (!containsAll(listOf(start, end))) { |
| 69 | + throw GradleException("Plugin description section not found in README.md:\n$start ... $end") |
| 70 | + } |
| 71 | + subList(indexOf(start) + 1, indexOf(end)) |
| 72 | + }.joinToString("\n").run { markdownToHTML(this) } |
| 73 | + ) |
| 74 | + |
| 75 | + // Get the latest available change notes from the changelog file |
| 76 | + changeNotes.set(provider { |
| 77 | + changelog.run { |
| 78 | + getOrNull(properties("pluginVersion")) ?: getLatest() |
| 79 | + }.toHTML() |
| 80 | + }) |
| 81 | + } |
| 82 | + |
| 83 | + // Configure UI tests plugin |
| 84 | + // Read more: https://github.com/JetBrains/intellij-ui-test-robot |
| 85 | + runIdeForUiTests { |
| 86 | + systemProperty("robot-server.port", "8082") |
| 87 | + systemProperty("ide.mac.message.dialogs.as.sheets", "false") |
| 88 | + systemProperty("jb.privacy.policy.text", "<!--999.999-->") |
| 89 | + systemProperty("jb.consents.confirmation.enabled", "false") |
| 90 | + } |
| 91 | +} |
0 commit comments