Skip to content

Commit

Permalink
Migrate to intellij-platform gradle plugin 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Undin committed Dec 3, 2024
1 parent b31a4a8 commit 9614851
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 23 deletions.
67 changes: 44 additions & 23 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import org.jetbrains.intellij.platform.gradle.extensions.IntelliJPlatformDependenciesExtension
import org.jetbrains.intellij.platform.gradle.extensions.IntelliJPlatformExtension
import org.jetbrains.intellij.platform.gradle.extensions.IntelliJPlatformRepositoriesExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

fun gradleProperties(key: String) = providers.gradleProperty(key)

group = gradleProperties("courseGroup").get()
version = gradleProperties("courseVersion").get()

val ideaVersion: String by project

plugins {
java
val kotlinVersion = "1.9.21"
id("org.jetbrains.kotlin.jvm") version kotlinVersion apply false
id("io.gitlab.arturbosch.detekt") version "1.23.1"
id("org.jetbrains.intellij") version "1.16.1"
}

intellij {
version.set("2023.1.2")
type.set("IC")
plugins.set(listOf("com.intellij.java", "org.jetbrains.kotlin"))
downloadSources.set(true)
updateSinceUntilBuild.set(true)
id("org.jetbrains.intellij.platform") version "2.1.0" apply false
}

val detektReportMerge by tasks.registering(io.gitlab.arturbosch.detekt.report.ReportMergeTask::class) {
Expand Down Expand Up @@ -49,15 +46,6 @@ configure(subprojects) {
apply {
plugin("java")
plugin("kotlin")
plugin("org.jetbrains.intellij")
}

intellij {
version.set("2023.1.2")
type.set("IC")
plugins.set(listOf("com.intellij.java", "org.jetbrains.kotlin"))
downloadSources.set(true)
updateSinceUntilBuild.set(true)
}

// Configure detekt
Expand Down Expand Up @@ -124,6 +112,26 @@ configure(subprojects) {

// We have to store tests inside test folder directly
configure(subprojects.filter { it.name != "common" }) {
apply {
plugin("org.jetbrains.intellij.platform")
}

repositories {
intellijPlatform {
defaultRepositories()
jetbrainsRuntime()
}
}

intellijPlatform {
projectName = "IDEDevelopmentCourseDemo"
pluginConfiguration {
id = "jetbrains.academy.plugin.course.dev.ui.demo"
name = "IDE Development Course Demo"
}
instrumentCode = false
buildSearchableOptions = false
}

val jvmVersion = gradleProperties("jvmVersion").get()
tasks {
Expand All @@ -137,9 +145,6 @@ configure(subprojects.filter { it.name != "common" }) {
sourceCompatibility = jvmVersion
targetCompatibility = jvmVersion
}

withType<org.jetbrains.intellij.tasks.BuildSearchableOptionsTask>()
.forEach { it.enabled = false }
}

sourceSets {
Expand All @@ -148,6 +153,12 @@ configure(subprojects.filter { it.name != "common" }) {
}

dependencies {
intellijPlatform {
intellijIdeaCommunity(ideaVersion, useInstaller = false)
jetbrainsRuntime()
bundledPlugins("com.intellij.java", "org.jetbrains.kotlin")
}

implementation(project(":common"))
}

Expand All @@ -157,9 +168,19 @@ configure(subprojects.filter { it.name != "common" }) {
}

tasks {
runIde {
"runIde" {
dependsOn("restoreOriginalFiles")
}
}

}

// Gradle doesn't generate type-safe accessors since `org.jetbrains.intellij.platform` plugin is not applied in the root project.
// Let's create them manually
fun Project.intellijPlatform(configure: Action<IntelliJPlatformExtension>) =
(this as ExtensionAware).extensions.configure("intellijPlatform", configure)

fun RepositoryHandler.intellijPlatform(configure: Action<IntelliJPlatformRepositoriesExtension>) =
(this as ExtensionAware).extensions.configure("intellijPlatform", configure)

fun DependencyHandler.intellijPlatform(configure: Action<IntelliJPlatformDependenciesExtension>) =
(this as ExtensionAware).extensions.configure("intellijPlatform", configure)
25 changes: 25 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
group = rootProject.group
version = rootProject.version

val ideaVersion: String by project

plugins {
id("org.jetbrains.intellij.platform.module")
}

intellijPlatform {
instrumentCode = false
}

repositories {
intellijPlatform {
defaultRepositories()
jetbrainsRuntime()
}
}

dependencies {
intellijPlatform {
intellijIdeaCommunity(ideaVersion, useInstaller = false)
jetbrainsRuntime()
bundledPlugins("com.intellij.java", "org.jetbrains.kotlin")
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ courseVersion=1.1.0

gradleVersion=8.3
jvmVersion=17
ideaVersion=2023.1.2

kotlin.code.style=official
org.gradle.jvmargs=-Xmx2048m

0 comments on commit 9614851

Please sign in to comment.