Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to intellij-platform gradle plugin 2.1 #26

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 49 additions & 23 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
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
`java-test-fixtures`
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 +48,7 @@ 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)
plugin("java-test-fixtures")
}

// Configure detekt
Expand Down Expand Up @@ -124,6 +115,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 +148,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,7 +156,15 @@ configure(subprojects.filter { it.name != "common" }) {
}

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

implementation(project(":common"))
testImplementation(testFixtures(project(":common")))
}

tasks.register<Copy>("restoreOriginalFiles") {
Expand All @@ -157,9 +173,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)
30 changes: 30 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
import org.jetbrains.intellij.platform.gradle.TestFrameworkType

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")
testFramework(TestFrameworkType.Bundled)
}
Comment on lines +12 to +29
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I don't know a proper way how not to duplicate these lines if do everything as expected, i.e., not apply org.jetbrains.intellij.platform at the top-level where it's unnecessary, and use org.jetbrains.intellij.platform.module plugin for common module since common is not a plugin itself but just a part of it


testFixturesApi("junit:junit:4.13.2")
}
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
Loading