1
1
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
2
2
import org.gradle.api.tasks.testing.logging.TestLogEvent
3
3
import org.jetbrains.changelog.markdownToHTML
4
- import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
4
+ import org.jetbrains.intellij.platform.gradle.TestFrameworkType
5
+ import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
5
6
import java.net.URL
6
7
import java.text.SimpleDateFormat
7
8
import java.util.Date
8
9
9
10
fun properties (key : String ) = project.findProperty(key).toString()
10
11
12
+ fun isSnapshotBuild () = System .getenv(" IJ_PLUGIN_SNAPSHOT" ).toBoolean()
13
+
14
+
11
15
plugins {
12
16
id(" org.jetbrains.kotlin.jvm" )
13
- id(" org.jetbrains.intellij" )
17
+ id(" org.jetbrains.intellij.platform " )
14
18
alias(libs.plugins.apollo.published)
15
19
}
16
20
@@ -21,6 +25,10 @@ repositories {
21
25
// Uncomment this one to use the Kotlin "dev" repository
22
26
// maven { url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/") }
23
27
mavenCentral()
28
+
29
+ intellijPlatform {
30
+ defaultRepositories()
31
+ }
24
32
}
25
33
26
34
group = properties(" pluginGroup" )
@@ -36,109 +44,40 @@ fun getSnapshotVersionSuffix(): String {
36
44
// Set the JVM language level used to build project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
37
45
kotlin {
38
46
jvmToolchain {
39
- ( this as JavaToolchainSpec ).languageVersion.set( JavaLanguageVersion .of(properties( " javaVersion " ).toInt()) )
47
+ languageVersion = JavaLanguageVersion .of(17 )
40
48
}
41
49
}
42
50
43
- // Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
44
- intellij {
45
- pluginName.set(properties(" pluginName" ))
46
- version.set(properties(" platformVersion" ))
47
- type.set(properties(" platformType" ))
48
-
49
- // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
50
- plugins.set(properties(" platformPlugins" ).split(' ,' ).map(String ::trim).filter(String ::isNotEmpty))
51
-
52
- // Uncomment to use a local repository e.g. for testing not yet published versions of the GraphQL plugin
53
- // pluginsRepositories {
54
- // maven("file://${System.getProperty("user.home")}/.m2/repository")
55
- // // Note: using 2 repositories doesn't work currently - see https://github.com/JetBrains/gradle-intellij-plugin/issues/1292
56
- // // marketplace()
57
- // }
58
- }
59
-
60
51
val apolloDependencies = configurations.create(" apolloDependencies" ).apply {
61
52
listOf (" :apollo-annotations" , " :apollo-api" , " :apollo-runtime" ).forEach {
62
53
dependencies.add(project.dependencies.project(it, " jvmApiElements" ))
63
54
}
64
55
}
65
56
66
57
tasks {
67
- withType<KotlinCompile > {
68
- kotlinOptions {
58
+ withType<KotlinCompilationTask < * > > {
59
+ compilerOptions {
69
60
freeCompilerArgs = listOf (" -Xcontext-receivers" )
70
61
}
71
62
}
72
63
73
- patchPluginXml {
74
- pluginId.set(properties(" pluginId" ))
75
- version.set(project.version.toString())
76
- sinceBuild.set(properties(" pluginSinceBuild" ))
77
- untilBuild.set(properties(" pluginUntilBuild" ))
78
-
79
- // Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
80
- pluginDescription.set(
81
- projectDir.resolve(" README.md" ).readText().lines().run {
82
- val start = " <!-- Plugin description -->"
83
- val end = " <!-- Plugin description end -->"
84
-
85
- if (! containsAll(listOf (start, end))) {
86
- throw GradleException (" Plugin description section not found in README.md:\n $start ... $end " )
87
- }
88
- subList(indexOf(start) + 1 , indexOf(end))
89
- }.joinToString(" \n " ).run { markdownToHTML(this ) }
90
- )
91
-
92
- changeNotes.set(
93
- if (isSnapshotBuild()) {
94
- " Weekly snapshot builds contain the latest changes from the <code>main</code> branch."
95
- } else {
96
- " See the <a href=\" https://github.com/apollographql/apollo-kotlin/releases/tag/v${project.version} \" >release notes</a>."
97
- }
98
- )
99
- }
100
-
101
- // Configure UI tests plugin
102
- // Read more: https://github.com/JetBrains/intellij-ui-test-robot
103
- runIdeForUiTests {
104
- systemProperty(" robot-server.port" , " 8082" )
105
- systemProperty(" ide.mac.message.dialogs.as.sheets" , " false" )
106
- systemProperty(" jb.privacy.policy.text" , " <!--999.999-->" )
107
- systemProperty(" jb.consents.confirmation.enabled" , " false" )
108
-
109
- // Enables debug logging for the plugin
110
- systemProperty(" idea.log.debug.categories" , " Apollo" )
111
- }
112
-
113
- runIde {
114
- // Enables debug logging for the plugin
115
- systemProperty(" idea.log.debug.categories" , " Apollo" )
116
-
117
- // Disable hiding frequent exceptions in logs (annoying for debugging). See com.intellij.idea.IdeaLogger.
118
- systemProperty(" idea.logger.exception.expiration.minutes" , " 0" )
119
-
120
- // Use a custom IntelliJ installation. Set this property in your local ~/.gradle/gradle.properties file.
64
+ val runLocalIde by intellijPlatformTesting.runIde.registering {
65
+ // Use a custom IJ/AS installation. Set this property in your local ~/.gradle/gradle.properties file.
121
66
// (for AS, it should be something like '/Applications/Android Studio.app/Contents')
122
67
// See https://plugins.jetbrains.com/docs/intellij/android-studio.html#configuring-the-plugin-gradle-build-script
123
- if (project.hasProperty (" apolloIntellijPlugin.ideDir" )) {
124
- ideDir.set( file(project.property( " apolloIntellijPlugin.ideDir " ) !! ) )
68
+ providers.gradleProperty (" apolloIntellijPlugin.ideDir" ).orNull?. let {
69
+ localPath = file(it )
125
70
}
126
71
127
- // Uncomment to disable internal mode - see https://plugins.jetbrains.com/docs/intellij/enabling-internal.html
128
- // systemProperty("idea.is.internal", "false")
129
- }
72
+ task {
73
+ // Enables debug logging for the plugin
74
+ systemProperty( " idea.log.debug.categories " , " Apollo " )
130
75
131
- signPlugin {
132
- certificateChain.set(System .getenv(" CERTIFICATE_CHAIN" ))
133
- privateKey.set(System .getenv(" PRIVATE_KEY" ))
134
- password.set(System .getenv(" PRIVATE_KEY_PASSWORD" ))
135
- }
76
+ // Disable hiding frequent exceptions in logs (annoying for debugging). See com.intellij.idea.IdeaLogger.
77
+ systemProperty(" idea.logger.exception.expiration.minutes" , " 0" )
136
78
137
- publishPlugin {
138
- token.set(System .getenv(" PUBLISH_TOKEN" ))
139
- if (isSnapshotBuild()) {
140
- // Read more: https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html#specifying-a-release-channel
141
- channels.set(listOf (" snapshots" ))
79
+ // Uncomment to disable internal mode - see https://plugins.jetbrains.com/docs/intellij/enabling-internal.html
80
+ // systemProperty("idea.is.internal", "false")
142
81
}
143
82
}
144
83
@@ -164,7 +103,9 @@ tasks.register("downloadMockJdk") {
164
103
val rtJar = mockJdkRoot.resolve(" java/mockJDK-1.7/jre/lib/rt.jar" )
165
104
if (! rtJar.exists()) {
166
105
rtJar.parentFile.mkdirs()
167
- rtJar.writeBytes(URL (" https://github.com/JetBrains/intellij-community/raw/master/java/mockJDK-1.7/jre/lib/rt.jar" ).openStream().readBytes())
106
+ rtJar.writeBytes(URL (" https://github.com/JetBrains/intellij-community/raw/master/java/mockJDK-1.7/jre/lib/rt.jar" ).openStream()
107
+ .readBytes()
108
+ )
168
109
}
169
110
}
170
111
}
@@ -177,19 +118,6 @@ tasks.test.configure {
177
118
systemProperty(" idea.home.path" , mockJdkRoot.relativeTo(project.projectDir).path)
178
119
}
179
120
180
- dependencies {
181
- implementation(project(" :apollo-gradle-plugin-external" ))
182
- implementation(project(" :apollo-ast" ))
183
- implementation(project(" :apollo-tooling" ))
184
- implementation(project(" :apollo-normalized-cache-sqlite" ))
185
- implementation(libs.sqlite.jdbc)
186
- implementation(libs.apollo.runtime.published)
187
- runtimeOnly(libs.slf4j.simple)
188
- testImplementation(libs.google.testparameterinjector)
189
- }
190
-
191
- fun isSnapshotBuild () = System .getenv(" IJ_PLUGIN_SNAPSHOT" ).toBoolean()
192
-
193
121
apollo {
194
122
service(" apolloDebugServer" ) {
195
123
packageName.set(" com.apollographql.ijplugin.apollodebugserver" )
@@ -207,3 +135,82 @@ tasks.configureEach {
207
135
enabled = false
208
136
}
209
137
}
138
+
139
+ // IntelliJ Platform Gradle Plugin configuration
140
+ // See https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html#intellijPlatform-pluginConfiguration
141
+ intellijPlatform {
142
+ pluginConfiguration {
143
+ id.set(properties(" pluginId" ))
144
+ name.set(properties(" pluginName" ))
145
+ version.set(project.version.toString())
146
+ ideaVersion {
147
+ sinceBuild = properties(" pluginSinceBuild" )
148
+ untilBuild = properties(" pluginUntilBuild" )
149
+ }
150
+ // Extract the <!-- Plugin description --> section from README.md and provide it to the plugin's manifest
151
+ description.set(
152
+ projectDir.resolve(" README.md" ).readText().lines().run {
153
+ val start = " <!-- Plugin description -->"
154
+ val end = " <!-- Plugin description end -->"
155
+
156
+ if (! containsAll(listOf (start, end))) {
157
+ throw GradleException (" Plugin description section not found in README.md:\n $start ... $end " )
158
+ }
159
+ subList(indexOf(start) + 1 , indexOf(end))
160
+ }.joinToString(" \n " ).run { markdownToHTML(this ) }
161
+ )
162
+ changeNotes.set(
163
+ if (isSnapshotBuild()) {
164
+ " Weekly snapshot builds contain the latest changes from the <code>main</code> branch."
165
+ } else {
166
+ " See the <a href=\" https://github.com/apollographql/apollo-kotlin/releases/tag/v${project.version} \" >release notes</a>."
167
+ }
168
+ )
169
+ }
170
+
171
+ signing {
172
+ certificateChain.set(System .getenv(" CERTIFICATE_CHAIN" ))
173
+ privateKey.set(System .getenv(" PRIVATE_KEY" ))
174
+ password.set(System .getenv(" PRIVATE_KEY_PASSWORD" ))
175
+ }
176
+
177
+ publishing {
178
+ token.set(System .getenv(" PUBLISH_TOKEN" ))
179
+ if (isSnapshotBuild()) {
180
+ // Read more: https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html#specifying-a-release-channel
181
+ channels.set(listOf (" snapshots" ))
182
+ }
183
+ }
184
+
185
+ verifyPlugin {
186
+ ides {
187
+ recommended()
188
+ }
189
+ }
190
+ }
191
+
192
+ dependencies {
193
+ intellijPlatform {
194
+ val localIdeDir = providers.gradleProperty(" apolloIntellijPlugin.ideDir" ).orNull
195
+ if (localIdeDir != null ) {
196
+ local(localIdeDir)
197
+ } else {
198
+ create(type = properties(" platformType" ), version = properties(" platformVersion" ))
199
+ }
200
+
201
+ bundledPlugins(properties(" platformBundledPlugins" ).split(' ,' ).map(String ::trim).filter(String ::isNotEmpty))
202
+ plugins(properties(" platformPlugins" ).split(' ,' ).map(String ::trim).filter(String ::isNotEmpty))
203
+ instrumentationTools()
204
+ pluginVerifier()
205
+ testFramework(TestFrameworkType .Plugin .Java )
206
+ zipSigner()
207
+ }
208
+ implementation(project(" :apollo-gradle-plugin-external" ))
209
+ implementation(project(" :apollo-ast" ))
210
+ implementation(project(" :apollo-tooling" ))
211
+ implementation(project(" :apollo-normalized-cache-sqlite" ))
212
+ implementation(libs.sqlite.jdbc)
213
+ implementation(libs.apollo.runtime.published)
214
+ runtimeOnly(libs.slf4j.simple)
215
+ testImplementation(libs.google.testparameterinjector)
216
+ }
0 commit comments