Skip to content

Commit dda2898

Browse files
committed
fix: upgrade to IntelliJ Gradle Plugin 2.0
1 parent 799278c commit dda2898

File tree

6 files changed

+93
-90
lines changed

6 files changed

+93
-90
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
- name: Test
2222
run: gradle clean test --info
2323
- name: Plugin verification
24-
run: gradle clean runPluginVerifier
24+
run: gradle clean verifyPlugin

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ build/
44
.gradle/
55
/gradle/
66
*.bak
7+
.intellijPlatform
File renamed without changes.

bin/gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.gradle-7.6.1.pkg
1+
.gradle-8.2.pkg

build.gradle.kts

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,32 @@
1-
import org.jetbrains.intellij.tasks.RunPluginVerifierTask
2-
import java.util.EnumSet
1+
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
2+
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
3+
import kotlin.math.sin
34

45
group = "com.squareup.cash.hermit"
56
version = project.properties["version"] ?: "1.0-SNAPSHOT"
67

78
plugins {
8-
id("idea")
99
id("java")
10-
kotlin("kapt") version "1.8.10"
11-
id("org.jetbrains.intellij") version "1.15.0"
12-
id("org.jetbrains.kotlin.jvm") version "1.8.10"
10+
kotlin("kapt") version "1.9.25"
11+
id("org.jetbrains.intellij.platform") version "2.0.0"
12+
13+
id("org.jetbrains.kotlin.jvm") version "1.9.25"
1314
id("org.jetbrains.kotlin.plugin.serialization") version "1.4.32"
1415
}
1516

1617
// region Build, dependencies
1718

1819
java {
1920
sourceCompatibility = JavaVersion.VERSION_17
20-
targetCompatibility = JavaVersion.VERSION_11
21+
targetCompatibility = JavaVersion.VERSION_17
2122
}
2223

2324
repositories {
2425
mavenCentral()
25-
}
26-
27-
val kotlinVersion = "1.8.10"
28-
val arrowVersion = "0.11.0"
29-
30-
dependencies {
31-
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
32-
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
33-
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0")
34-
implementation("io.arrow-kt:arrow-core:$arrowVersion")
35-
implementation("io.arrow-kt:arrow-syntax:$arrowVersion")
36-
kapt("io.arrow-kt:arrow-meta:$arrowVersion")
37-
}
38-
39-
tasks {
40-
compileKotlin {
41-
kotlinOptions.jvmTarget = "11"
42-
kotlinOptions.freeCompilerArgs = listOf("-Xjvm-default=enable")
43-
}
44-
45-
test {
46-
systemProperty("idea.force.use.core.classloader", "true")
26+
intellijPlatform {
27+
defaultRepositories()
4728
}
4829
}
49-
// endregion
50-
51-
// region IJ Plugin setup
5230

5331
data class Product(
5432
val releaseType: String, // identifier for this product
@@ -77,73 +55,95 @@ val products = listOf(
7755
)
7856
val product = products.first { it.releaseType == (System.getenv("RELEASE_TYPE") ?: "release") }
7957

80-
intellij {
81-
version.set(product.sdkVersion)
82-
type.set("IU")
83-
plugins.set(
84-
listOf(
85-
"gradle",
86-
"java",
87-
"terminal",
58+
val kotlinVersion = "1.9.25"
59+
val arrowVersion = "0.11.0"
60+
61+
dependencies {
62+
intellijPlatform {
63+
intellijIdeaUltimate(product.sdkVersion, useInstaller = false)
64+
pluginVerifier("1.371")
65+
plugins(
66+
"org.jetbrains.plugins.go:${product.goPluginVersion}"
67+
)
68+
bundledPlugins(
69+
"com.intellij.gradle",
70+
"com.intellij.java",
8871
"com.intellij.properties",
89-
"org.jetbrains.plugins.go:${product.goPluginVersion}",
9072
// Needed by Go plugin. See https://github.com/JetBrains/gradle-intellij-plugin/issues/1056
9173
"org.intellij.intelliLang"
9274
)
93-
)
75+
testFramework(TestFrameworkType.Bundled, product.sdkVersion)
76+
}
77+
78+
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
79+
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
80+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0")
81+
implementation("io.arrow-kt:arrow-core:$arrowVersion")
82+
implementation("io.arrow-kt:arrow-syntax:$arrowVersion")
83+
kapt("io.arrow-kt:arrow-meta:$arrowVersion")
84+
85+
testImplementation("junit:junit:4.13.2")
86+
testImplementation("org.junit.jupiter:junit-jupiter-api:5.4.2")
9487
}
88+
9589
tasks {
96-
runIde {
97-
// Uncomment this, and set your path accordingly, if you want to debug on GoLand
98-
// ideDirectory "/Users/juho/Library/Application Support/JetBrains/Toolbox/apps/Goland/ch-0/203.6682.164/GoLand.app/Contents"
90+
compileKotlin {
91+
kotlinOptions.jvmTarget = "17"
92+
kotlinOptions.freeCompilerArgs = listOf("-Xjvm-default=all-compatibility")
93+
}
94+
95+
test {
96+
systemProperty("idea.force.use.core.classloader", "true")
97+
}
98+
}
99+
100+
intellijPlatform {
101+
version = version
102+
projectName = project.name
103+
104+
instrumentCode = false // We don't need to scan codebase for jetbrains annotations
105+
106+
//type.set("IU")
107+
108+
pluginVerification {
109+
// These need to match the versions from
110+
// https://data.services.jetbrains.com/products?fields=code,name,releases.downloads,releases.version,releases.build,releases.type&code=IIC,IIE,GO
111+
ides {
112+
select {
113+
types = listOf(IntelliJPlatformType.IntellijIdeaUltimate)
114+
sinceBuild = project.properties["IIC.from.version"] as String
115+
untilBuild = project.properties["IIC.from.version"] as String
116+
}
117+
select {
118+
types = listOf(IntelliJPlatformType.IntellijIdeaUltimate)
119+
sinceBuild = product.intellijVersion
120+
untilBuild = product.intellijVersion
121+
}
122+
select {
123+
types = listOf(IntelliJPlatformType.GoLand)
124+
sinceBuild = project.properties["GO.from.version"] as String
125+
untilBuild = project.properties["GO.from.version"] as String
126+
}
127+
select {
128+
types = listOf(IntelliJPlatformType.GoLand)
129+
sinceBuild = product.golandVersion
130+
untilBuild = product.golandVersion
131+
}
132+
}
99133
}
134+
}
100135

136+
tasks {
101137
patchPluginXml {
102138
sinceBuild.set(project.properties["IIC.from.version"] as String)
103139
val versionSuffix = when(product.releaseType) {
104140
"release" -> ""
105141
else -> "-${product.releaseType}"
106142
}
107-
version.set("${System.getenv("IJ_PLUGIN_VERSION")}${versionSuffix}") // IJ_PLUGIN_VERSION env var available in CI
108-
}
109-
110-
runPluginVerifier {
111-
// These need to match the versions from
112-
// https://data.services.jetbrains.com/products?fields=code,name,releases.downloads,releases.version,releases.build,releases.type&code=IIC,IIE,GO
113-
ideVersions.set(
114-
listOf(
115-
"IIC-${project.properties["IIC.from.version"] as String}",
116-
"GO-${project.properties["GO.from.version"] as String}",
117-
"IIC-${product.intellijVersion}",
118-
"GO-${product.golandVersion}"
119-
)
120-
)
121-
failureLevel.set(
122-
EnumSet.complementOf(
123-
EnumSet.of(
124-
// skipping missing dependencies as com.intellij.java provided by IJ raises a false warning
125-
RunPluginVerifierTask.FailureLevel.MISSING_DEPENDENCIES,
126-
// skipping experimental API usage, as delaying Gradle execution relies on experimental GradleExecutionAware.
127-
// if the API changes, we should be able to detect that in our tests when a new version comes out.
128-
RunPluginVerifierTask.FailureLevel.EXPERIMENTAL_API_USAGES,
129-
// we do not fail on deprecated API usages, as we want to support older versions where the API has
130-
// not been deprecate yet, and the newer API not available
131-
RunPluginVerifierTask.FailureLevel.DEPRECATED_API_USAGES,
132-
// TODO: fix these
133-
RunPluginVerifierTask.FailureLevel.SCHEDULED_FOR_REMOVAL_API_USAGES,
134-
)
135-
)
136-
)
143+
version = "${System.getenv("IJ_PLUGIN_VERSION")}${versionSuffix}" // IJ_PLUGIN_VERSION env var available in CI
137144
}
138145

139146
publishPlugin {
140147
token.set(System.getenv("JETBRAINS_TOKEN")) // JETBRAINS_TOKEN env var available in CI
141148
}
142-
143-
// See https://youtrack.jetbrains.com/issue/KTIJ-782
144-
buildSearchableOptions {
145-
enabled = false
146-
}
147-
}
148-
149-
// endregion
149+
}

src/main/kotlin/com/squareup/cash/hermit/execution/HermitIdeaEnvProvider.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ class HermitIdeaEnvProvider : RunConfigurationExtension() {
1414
return Hermit(configuration.project).hasHermit()
1515
}
1616

17-
override fun <T : RunConfigurationBase<*>?> updateJavaParameters(configuration: T, params: JavaParameters, settings: RunnerSettings?) {
18-
val project = configuration?.getProject()
19-
if (project != null) {
20-
params.env = Hermit(project).environment().patch(params.env)
21-
}
17+
override fun <T : RunConfigurationBase<*>?> updateJavaParameters(
18+
configuration: T & Any,
19+
params: JavaParameters,
20+
settings: RunnerSettings?
21+
) {
22+
val project = configuration.project
23+
params.env = Hermit(project).environment().patch(params.env)
2224
}
2325
}

0 commit comments

Comments
 (0)