-
Notifications
You must be signed in to change notification settings - Fork 270
/
IntelliJPlugin.kt
1715 lines (1520 loc) · 81.4 KB
/
IntelliJPlugin.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.intellij
import com.jetbrains.plugin.structure.base.utils.extension
import com.jetbrains.plugin.structure.base.utils.hasExtension
import com.jetbrains.plugin.structure.base.utils.nameWithoutExtension
import com.jetbrains.plugin.structure.intellij.version.IdeVersion
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.DependencySet
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.internal.plugins.DefaultArtifactPublicationSet
import org.gradle.api.logging.LogLevel
import org.gradle.api.plugins.ExtensionAware
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.plugins.JavaPlugin.*
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.ClasspathNormalizer
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.bundling.Zip
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.testing.Test
import org.gradle.internal.jvm.Jvm
import org.gradle.internal.os.OperatingSystem
import org.gradle.jvm.toolchain.JavaToolchainService
import org.gradle.kotlin.dsl.*
import org.gradle.kotlin.dsl.support.serviceOf
import org.gradle.language.jvm.tasks.ProcessResources
import org.gradle.plugins.ide.idea.model.IdeaModel
import org.gradle.plugins.ide.idea.model.IdeaProject
import org.gradle.util.GradleVersion
import org.jetbrains.gradle.ext.IdeaExtPlugin
import org.jetbrains.gradle.ext.ProjectSettings
import org.jetbrains.gradle.ext.TaskTriggersConfig
import org.jetbrains.intellij.BuildFeature.*
import org.jetbrains.intellij.IntelliJPluginConstants.ANDROID_STUDIO_PRODUCTS_RELEASES_URL
import org.jetbrains.intellij.IntelliJPluginConstants.ANNOTATIONS_DEPENDENCY_VERSION
import org.jetbrains.intellij.IntelliJPluginConstants.BUILD_PLUGIN_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.BUILD_SEARCHABLE_OPTIONS_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.CLASSPATH_INDEX_CLEANUP_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.COMPILE_KOTLIN_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.DEFAULT_IDEA_VERSION
import org.jetbrains.intellij.IntelliJPluginConstants.DEFAULT_INTELLIJ_REPOSITORY
import org.jetbrains.intellij.IntelliJPluginConstants.DEFAULT_SANDBOX
import org.jetbrains.intellij.IntelliJPluginConstants.DOWNLOAD_ANDROID_STUDIO_PRODUCT_RELEASES_XML_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.DOWNLOAD_IDE_PRODUCT_RELEASES_XML_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.DOWNLOAD_ROBOT_SERVER_PLUGIN_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.DOWNLOAD_ZIP_SIGNER_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.EXTENSION_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.IDEA_CONFIGURATION_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.IDEA_GRADLE_PLUGIN_ID
import org.jetbrains.intellij.IntelliJPluginConstants.IDEA_PLUGINS_CONFIGURATION_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.IDEA_PRODUCTS_RELEASES_URL
import org.jetbrains.intellij.IntelliJPluginConstants.INITIALIZE_INTELLIJ_PLUGIN_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.INSTRUMENTED_JAR_CONFIGURATION_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.INSTRUMENTED_JAR_PREFIX
import org.jetbrains.intellij.IntelliJPluginConstants.INSTRUMENTED_JAR_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.INSTRUMENT_CODE_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.INSTRUMENT_TEST_CODE_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.INTELLIJ_DEFAULT_DEPENDENCIES_CONFIGURATION_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.INTELLIJ_DEPENDENCIES
import org.jetbrains.intellij.IntelliJPluginConstants.JAR_SEARCHABLE_OPTIONS_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.JAVA_COMPILER_ANT_TASKS_MAVEN_METADATA
import org.jetbrains.intellij.IntelliJPluginConstants.KOTLIN_GRADLE_PLUGIN_ID
import org.jetbrains.intellij.IntelliJPluginConstants.LIST_BUNDLED_PLUGINS_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.LIST_PRODUCTS_RELEASES_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.MARKETPLACE_HOST
import org.jetbrains.intellij.IntelliJPluginConstants.PATCH_PLUGIN_XML_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.PERFORMANCE_PLUGIN_ID
import org.jetbrains.intellij.IntelliJPluginConstants.PERFORMANCE_TEST_CONFIGURATION_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.PLATFORM_TYPE_CLION
import org.jetbrains.intellij.IntelliJPluginConstants.PLATFORM_TYPE_INTELLIJ_COMMUNITY
import org.jetbrains.intellij.IntelliJPluginConstants.PLATFORM_TYPE_PHPSTORM
import org.jetbrains.intellij.IntelliJPluginConstants.PLATFORM_TYPE_PYCHARM
import org.jetbrains.intellij.IntelliJPluginConstants.PLATFORM_TYPE_RIDER
import org.jetbrains.intellij.IntelliJPluginConstants.PLUGIN_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.PLUGIN_VERIFIER_REPOSITORY
import org.jetbrains.intellij.IntelliJPluginConstants.PLUGIN_XML_DIR_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.PREPARE_SANDBOX_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.PREPARE_TESTING_SANDBOX_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.PREPARE_UI_TESTING_SANDBOX_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.PRINT_BUNDLED_PLUGINS_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.PRINT_PRODUCTS_RELEASES_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.PUBLISH_PLUGIN_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.RELEASE_SUFFIX_EAP
import org.jetbrains.intellij.IntelliJPluginConstants.RELEASE_SUFFIX_EAP_CANDIDATE
import org.jetbrains.intellij.IntelliJPluginConstants.RELEASE_SUFFIX_SNAPSHOT
import org.jetbrains.intellij.IntelliJPluginConstants.RELEASE_TYPE_RELEASES
import org.jetbrains.intellij.IntelliJPluginConstants.RUN_IDE_FOR_UI_TESTS_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.RUN_IDE_PERFORMANCE_TEST_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.RUN_IDE_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.RUN_PLUGIN_VERIFIER_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.SEARCHABLE_OPTIONS_DIR_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.SETUP_DEPENDENCIES_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.SIGN_PLUGIN_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.TASKS
import org.jetbrains.intellij.IntelliJPluginConstants.VERIFY_PLUGIN_CONFIGURATION_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.VERIFY_PLUGIN_SIGNATURE_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.VERIFY_PLUGIN_TASK_NAME
import org.jetbrains.intellij.IntelliJPluginConstants.VERSION_LATEST
import org.jetbrains.intellij.dependency.*
import org.jetbrains.intellij.jbr.JbrResolver
import org.jetbrains.intellij.model.MavenMetadata
import org.jetbrains.intellij.model.XmlExtractor
import org.jetbrains.intellij.performanceTest.ProfilerName
import org.jetbrains.intellij.pluginRepository.PluginRepositoryFactory
import org.jetbrains.intellij.propertyProviders.IntelliJPlatformArgumentProvider
import org.jetbrains.intellij.propertyProviders.LaunchSystemArgumentProvider
import org.jetbrains.intellij.propertyProviders.PluginPathArgumentProvider
import org.jetbrains.intellij.tasks.*
import org.jetbrains.intellij.utils.ArchiveUtils
import org.jetbrains.intellij.utils.DependenciesDownloader
import org.jetbrains.intellij.utils.ivyRepository
import org.jetbrains.intellij.utils.mavenRepository
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.File
import java.net.URL
import java.nio.file.Path
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.util.*
import kotlin.io.path.exists
abstract class IntelliJPlugin : Plugin<Project> {
private lateinit var archiveUtils: ArchiveUtils
private lateinit var dependenciesDownloader: DependenciesDownloader
private lateinit var jbrResolver: JbrResolver
private lateinit var context: String
override fun apply(project: Project) {
project.checkGradleVersion()
context = project.logCategory()
archiveUtils = project.objects.newInstance()
dependenciesDownloader = project.objects.newInstance(project.gradle.startParameter.isOffline)
project.plugins.apply(JavaPlugin::class)
project.plugins.apply(IdeaExtPlugin::class)
project.pluginManager.withPlugin(IDEA_GRADLE_PLUGIN_ID) {
project.idea {
// IdeaModel.project is available only for a root project
this.project?.settings {
taskTriggers {
afterSync(SETUP_DEPENDENCIES_TASK_NAME)
}
}
}
}
val extension = project.extensions.create<IntelliJPluginExtension>(EXTENSION_NAME, dependenciesDownloader).apply {
version.convention(project.provider {
if (!localPath.isSpecified) {
throw GradleException("The value for the 'intellij.version' property was not specified, see: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-version")
}
null
})
pluginName.convention(project.provider {
project.name
})
updateSinceUntilBuild.convention(true)
sameSinceUntilBuild.convention(false)
instrumentCode.convention(true)
sandboxDir.convention(
project.layout.buildDirectory
.dir(DEFAULT_SANDBOX)
.map { it.asFile.canonicalPath }
)
intellijRepository.convention(DEFAULT_INTELLIJ_REPOSITORY)
downloadSources.convention(!System.getenv().containsKey("CI"))
configureDefaultDependencies.convention(true)
type.convention(PLATFORM_TYPE_INTELLIJ_COMMUNITY)
}
val gradleProjectJavaToolchainSpec = project.extensions.getByType<JavaPluginExtension>().toolchain
val gradleProjectJavaService = project.serviceOf<JavaToolchainService>()
jbrResolver = project.objects.newInstance(
extension.jreRepository,
archiveUtils,
dependenciesDownloader,
gradleProjectJavaToolchainSpec,
gradleProjectJavaService,
context,
)
val ideaDependencyProvider = prepareIdeaDependencyProvider(project, extension).memoize()
configureDependencies(project, extension, ideaDependencyProvider)
configureTasks(project, extension, ideaDependencyProvider)
}
private fun configureTasks(project: Project, extension: IntelliJPluginExtension, ideaDependencyProvider: Provider<IdeaDependency>) {
info(context, "Configuring plugin")
project.tasks.withType<RunIdeBase> {
prepareConventionMappingsForRunIdeTask(project, extension, ideaDependencyProvider, PREPARE_SANDBOX_TASK_NAME)
}
project.tasks.withType<RunIdeForUiTestTask> {
prepareConventionMappingsForRunIdeTask(project, extension, ideaDependencyProvider, PREPARE_UI_TESTING_SANDBOX_TASK_NAME)
}
configureInitializeGradleIntelliJPluginTask(project)
configureSetupDependenciesTask(project, ideaDependencyProvider)
configureClassPathIndexCleanupTask(project, ideaDependencyProvider)
configureInstrumentation(project, extension, ideaDependencyProvider)
configurePatchPluginXmlTask(project, extension, ideaDependencyProvider)
configureDownloadRobotServerPluginTask(project)
configurePrepareSandboxTasks(project, extension, ideaDependencyProvider)
configureListProductsReleasesTask(project, extension)
configureListBundledPluginsTask(project, ideaDependencyProvider)
configurePluginVerificationTask(project)
configureRunIdeTask(project)
configureRunIdePerformanceTestTask(project, extension)
configureRunIdeForUiTestsTask(project)
configureBuildSearchableOptionsTask(project)
configureJarSearchableOptionsTask(project)
configureBuildPluginTask(project)
configureRunPluginVerifierTask(project, extension)
configureDownloadZipSignerTask(project)
configureSignPluginTask(project)
configurePublishPluginTask(project)
configureProcessResources(project)
configureVerifyPluginConfigurationTask(project, ideaDependencyProvider)
assert(!project.state.executed) { "afterEvaluate is a no-op for an executed project" }
project.pluginManager.withPlugin(KOTLIN_GRADLE_PLUGIN_ID) {
project.tasks.withType<KotlinCompile> {
dependsOn(VERIFY_PLUGIN_CONFIGURATION_TASK_NAME)
}
}
project.tasks.withType<JavaCompile> {
dependsOn(VERIFY_PLUGIN_CONFIGURATION_TASK_NAME)
}
(TASKS - INITIALIZE_INTELLIJ_PLUGIN_TASK_NAME).forEach {
project.tasks.named(it) {
dependsOn(INITIALIZE_INTELLIJ_PLUGIN_TASK_NAME)
}
}
project.afterEvaluate {
configureProjectAfterEvaluate(this, extension, ideaDependencyProvider)
}
}
private fun prepareIdeaDependencyProvider(project: Project, extension: IntelliJPluginExtension) = project.provider {
val configureDefaultDependencies = extension.configureDefaultDependencies.get()
val downloadSources = extension.downloadSources.get()
val extraDependencies = extension.extraDependencies.get()
val ideaDependencyCachePath = extension.ideaDependencyCachePath.orNull.orEmpty()
val intellijRepository = extension.intellijRepository.get()
val localPath = extension.localPath.orNull
val localSourcesPath = extension.localSourcesPath.orNull
val type = extension.getVersionType().orNull
val version = extension.getVersionNumber().orNull
val ideaConfiguration = project.configurations.getByName(IDEA_CONFIGURATION_NAME)
val dependencyManager = project.objects.newInstance<IdeaDependencyManager>(
intellijRepository,
ideaDependencyCachePath,
archiveUtils,
dependenciesDownloader,
context,
)
val ideaDependency = when {
localPath != null && version != null -> {
throw GradleException("Both 'intellij.localPath' and 'intellij.version' are specified, but one of these is allowed to be present.")
}
version != null && type != null -> {
info(context, "Using IDE from remote repository")
dependencyManager.resolveRemote(project, version, type, downloadSources, extraDependencies)
}
localPath != null -> {
info(context, "Using path to locally installed IDE: $localPath")
dependencyManager.resolveLocal(project, localPath, localSourcesPath)
}
else -> {
throw GradleException("Either 'intellij.localPath' or 'intellij.version' must be specified")
}
}
if (configureDefaultDependencies && ideaConfiguration.dependencies.isEmpty()) {
info(context, "${ideaDependency.buildNumber} is used for building")
dependencyManager.register(project, ideaDependency, ideaConfiguration.dependencies)
ideaConfiguration.resolve()
if (!ideaDependency.extraDependencies.isEmpty()) {
info(context, "Note: ${ideaDependency.buildNumber} extra dependencies (${ideaDependency.extraDependencies}) should be applied manually")
}
} else {
info(context, "IDE ${ideaDependency.buildNumber} dependencies are applied manually")
}
ideaDependency
}
private fun configureDependencies(project: Project, extension: IntelliJPluginExtension, ideaDependencyProvider: Provider<IdeaDependency>) {
val idea = project.configurations.create(IDEA_CONFIGURATION_NAME)
.setVisible(false)
.apply {
isCanBeConsumed = false
isCanBeResolved = true
}
val ideaPlugins = project.configurations.create(IDEA_PLUGINS_CONFIGURATION_NAME)
.setVisible(false)
.withDependencies {
configurePluginDependencies(project, ideaDependencyProvider, extension, this)
}
.apply {
isCanBeConsumed = false
isCanBeResolved = true
}
val defaultDependencies = project.configurations.create(INTELLIJ_DEFAULT_DEPENDENCIES_CONFIGURATION_NAME)
.setVisible(false)
.withDependencies {
add(
project.dependencies.create(
group = "org.jetbrains",
name = "annotations",
version = ANNOTATIONS_DEPENDENCY_VERSION,
)
)
}
.apply {
isCanBeConsumed = false
isCanBeResolved = true
}
val performanceTest = project.configurations.create(PERFORMANCE_TEST_CONFIGURATION_NAME)
.setVisible(false)
.withDependencies {
val resolver = project.objects.newInstance<PluginDependencyManager>(
project.gradle.gradleUserHomeDir.canonicalPath,
ideaDependencyProvider,
extension.getPluginsRepositories(),
archiveUtils,
context,
)
// Check that the `runIdePerformanceTest` task was launched
// Check that `performanceTesting.jar` is absent (that means it's a community version)
// Check that user didn't pass a custom version of the performance plugin
if (
RUN_IDE_PERFORMANCE_TEST_TASK_NAME in project.gradle.startParameter.taskNames
&& extension.plugins.get().none { it is String && it.startsWith(PERFORMANCE_PLUGIN_ID) }
) {
val bundledPlugins = BuiltinPluginsRegistry.resolveBundledPlugins(ideaDependencyProvider.get().classes.toPath(), context)
if (!bundledPlugins.contains(PERFORMANCE_PLUGIN_ID)) {
val buildNumber = ideaDependencyProvider.get().buildNumber
val resolvedPlugin = resolveLatestPluginUpdate(PERFORMANCE_PLUGIN_ID, buildNumber)
?: throw BuildException("No suitable plugin update found for $PERFORMANCE_PLUGIN_ID:$buildNumber")
val plugin = resolver.resolve(project, resolvedPlugin)
?: throw BuildException(with(resolvedPlugin) { "Failed to resolve plugin $id:$version@$channel" })
configurePluginDependency(project, plugin, extension, this, resolver)
}
}
}
.apply {
isCanBeConsumed = false
isCanBeResolved = true
}
fun Configuration.extend() = extendsFrom(defaultDependencies, idea, ideaPlugins, performanceTest)
with(project.configurations) {
getByName(COMPILE_ONLY_CONFIGURATION_NAME).extend()
getByName(TEST_IMPLEMENTATION_CONFIGURATION_NAME).extend()
project.pluginManager.withPlugin("java-test-fixtures") {
getByName("testFixturesCompileOnly").extend()
}
}
}
private fun configureProjectAfterEvaluate(project: Project, extension: IntelliJPluginExtension, ideaDependencyProvider: Provider<IdeaDependency>) {
project.subprojects.forEach { subproject ->
if (subproject.plugins.findPlugin(IntelliJPlugin::class) == null) {
subproject.extensions.findByType<IntelliJPluginExtension>()?.let {
configureProjectAfterEvaluate(subproject, it, ideaDependencyProvider)
}
}
}
configureTestTasks(project, extension, ideaDependencyProvider)
}
private fun verifyJavaPluginDependency(project: Project, ideaDependency: IdeaDependency, plugins: List<Any>) {
val hasJavaPluginDependency = plugins.contains("java") || plugins.contains("com.intellij.java")
if (!hasJavaPluginDependency && File(ideaDependency.classes, "plugins/java").exists()) {
sourcePluginXmlFiles(project).forEach { path ->
parsePluginXml(path, context)?.dependencies?.forEach {
if (it.dependencyId == "com.intellij.modules.java") {
throw BuildException("The project depends on 'com.intellij.modules.java' module but doesn't declare a compile dependency on it.\nPlease delete 'depends' tag from '${path}' or add Java plugin to Gradle dependencies (https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html#java)")
}
}
}
}
}
private fun configureBuiltinPluginsDependencies(
project: Project,
dependencies: DependencySet,
resolver: PluginDependencyManager,
extension: IntelliJPluginExtension,
ideaDependency: IdeaDependency,
) {
val configuredPlugins = extension.getUnresolvedPluginDependencies()
.filter(PluginDependency::builtin)
.map(PluginDependency::id)
ideaDependency.pluginsRegistry.collectBuiltinDependencies(configuredPlugins).forEach {
val plugin = resolver.resolve(project, PluginDependencyNotation(it, null, null)) ?: return
configurePluginDependency(project, plugin, extension, dependencies, resolver)
}
}
private fun configurePluginDependency(
project: Project,
plugin: PluginDependency,
extension: IntelliJPluginExtension,
dependencies: DependencySet,
resolver: PluginDependencyManager,
) {
if (extension.configureDefaultDependencies.get()) {
resolver.register(project, plugin, dependencies)
}
extension.addPluginDependency(plugin)
project.tasks.withType<PrepareSandboxTask> {
configureExternalPlugin(plugin)
}
}
private fun configureProjectPluginTasksDependency(dependency: Project, task: PrepareSandboxTask) {
// invoke before tasks graph is ready
if (dependency.plugins.findPlugin(IntelliJPlugin::class) == null) {
throw BuildException("Cannot use '$dependency' as a plugin dependency. IntelliJ Plugin not found: ${dependency.plugins}")
}
dependency.tasks.named(PREPARE_SANDBOX_TASK_NAME) {
task.dependsOn(this)
}
}
private fun configureProjectPluginDependency(project: Project, dependency: Project, dependencies: DependencySet, extension: IntelliJPluginExtension) {
// invoke on demand when plugin artifacts are needed
if (dependency.plugins.findPlugin(IntelliJPlugin::class) == null) {
throw BuildException("Cannot use '$dependency' as a plugin dependency. IntelliJ Plugin not found: ${dependency.plugins}")
}
dependencies.add(project.dependencies.create(dependency))
val prepareSandboxTaskProvider = dependency.tasks.named<PrepareSandboxTask>(PREPARE_SANDBOX_TASK_NAME)
val dependencyDirectory = prepareSandboxTaskProvider.flatMap { prepareSandboxTask ->
prepareSandboxTask.pluginName.map { pluginName ->
prepareSandboxTask.destinationDir.resolve(pluginName)
}
}
val pluginDependency = PluginProjectDependency(dependencyDirectory.get(), context)
extension.addPluginDependency(pluginDependency)
project.tasks.withType<PrepareSandboxTask> {
configureCompositePlugin(pluginDependency)
}
}
private fun configurePatchPluginXmlTask(project: Project, extension: IntelliJPluginExtension, ideaDependencyProvider: Provider<IdeaDependency>) {
info(context, "Configuring patch plugin.xml task")
val buildNumberProvider = ideaDependencyProvider.map { it.buildNumber }
project.tasks.register<PatchPluginXmlTask>(PATCH_PLUGIN_XML_TASK_NAME)
project.tasks.withType<PatchPluginXmlTask> {
version.convention(project.provider {
project.version.toString()
})
pluginXmlFiles.convention(project.provider {
sourcePluginXmlFiles(project).map(Path::toFile)
})
destinationDir.convention(project.layout.buildDirectory.dir(PLUGIN_XML_DIR_NAME))
outputFiles.convention(pluginXmlFiles.map {
it.map { file ->
destinationDir.get().asFile.resolve(file.name)
}
})
sinceBuild.convention(project.provider {
if (extension.updateSinceUntilBuild.get()) {
val ideVersion = IdeVersion.createIdeVersion(buildNumberProvider.get())
"${ideVersion.baselineVersion}.${ideVersion.build}"
} else {
null
}
})
untilBuild.convention(project.provider {
if (extension.updateSinceUntilBuild.get()) {
if (extension.sameSinceUntilBuild.get()) {
"${sinceBuild.get()}.*"
} else {
val ideVersion = IdeVersion.createIdeVersion(buildNumberProvider.get())
"${ideVersion.baselineVersion}.*"
}
} else {
null
}
})
}
}
private fun configurePrepareSandboxTasks(project: Project, extension: IntelliJPluginExtension, ideaDependencyProvider: Provider<IdeaDependency>) {
val jarTaskProvider = project.tasks.named<Jar>(JAR_TASK_NAME)
val instrumentedJarTaskProvider = project.tasks.named<Jar>(INSTRUMENTED_JAR_TASK_NAME)
val downloadPluginTaskProvider = project.tasks.named<DownloadRobotServerPluginTask>(DOWNLOAD_ROBOT_SERVER_PLUGIN_TASK_NAME)
val runtimeConfiguration = project.configurations.getByName(RUNTIME_CLASSPATH_CONFIGURATION_NAME)
val ideaDependencyJarFiles = ideaDependencyProvider.map {
project.files(it.jarFiles)
}
val pluginJarProvider = extension.instrumentCode.flatMap { instrumentCode ->
when (instrumentCode) {
true -> instrumentedJarTaskProvider
false -> jarTaskProvider
}
}.flatMap { jarTask -> jarTask.archiveFile }
val gradleVersion = project.provider {
project.gradle.gradleVersion
}
val projectVersion = project.provider {
project.version
}
val buildSdk = project.provider {
extension.localPath.flatMap {
ideaDependencyProvider.map { ideaDependency ->
ideaDependency.classes.toPath().let {
// Fall back on build number if product-info.json is not present, this is the case for recent versions of Android Studio.
ideProductInfo(it)
?.run { "$productCode-$projectVersion" }
?: ideBuildNumber(it)
}
}
}.orElse(extension.getVersionType().zip(extension.getVersionNumber()) { type, version ->
"$type-$version"
})
}
listOf(jarTaskProvider, instrumentedJarTaskProvider).forEach {
it.configure {
exclude("**/classpath.index")
manifest.attributes(
"Created-By" to gradleVersion.map { version -> "Gradle $version" },
"Build-JVM" to Jvm.current(),
"Version" to projectVersion,
"Build-Plugin" to PLUGIN_NAME,
"Build-Plugin-Version" to getCurrentPluginVersion().or("0.0.0"),
"Build-OS" to OperatingSystem.current(),
"Build-SDK" to buildSdk.get(),
)
}
}
project.tasks.register<PrepareSandboxTask>(PREPARE_SANDBOX_TASK_NAME) {
testSuffix.convention("")
}
project.tasks.register<PrepareSandboxTask>(PREPARE_TESTING_SANDBOX_TASK_NAME) {
testSuffix.convention("-test")
}
project.tasks.register<PrepareSandboxTask>(PREPARE_UI_TESTING_SANDBOX_TASK_NAME) {
testSuffix.convention("-uiTest")
from(downloadPluginTaskProvider.flatMap { downloadPluginTask ->
downloadPluginTask.outputDir
})
dependsOn(DOWNLOAD_ROBOT_SERVER_PLUGIN_TASK_NAME)
}
project.tasks.withType<PrepareSandboxTask> {
pluginName.convention(extension.pluginName)
pluginJar.convention(pluginJarProvider)
defaultDestinationDir.convention(extension.sandboxDir.flatMap {
testSuffix.map { testSuffixValue ->
project.file("$it/plugins$testSuffixValue")
}
})
configDir.convention(extension.sandboxDir.flatMap {
testSuffix.map { testSuffixValue ->
"$it/config$testSuffixValue"
}
})
librariesToIgnore.convention(ideaDependencyJarFiles)
pluginDependencies.convention(project.provider {
extension.getPluginDependenciesList(project)
})
runtimeClasspathFiles.convention(runtimeConfiguration)
intoChild(pluginName.map { "$it/lib" })
.from(runtimeClasspathFiles.map { files ->
val librariesToIgnore = librariesToIgnore.get().toSet() + Jvm.current().toolsJar
val pluginDirectories = pluginDependencies.get().map { it.artifact }
listOf(pluginJar.get().asFile) + files.filter { file ->
!(librariesToIgnore.contains(file) || pluginDirectories.any { p ->
file.toPath() == p || file.canonicalPath.startsWith("$p${File.separator}")
})
}
})
.eachFile {
name = ensureName(file.toPath())
}
dependsOn(runtimeConfiguration)
dependsOn(jarTaskProvider)
dependsOn(instrumentedJarTaskProvider)
project.afterEvaluate {
extension.plugins.get().filterIsInstance<Project>().forEach { dependency ->
if (dependency.state.executed) {
configureProjectPluginTasksDependency(dependency, this@withType)
} else {
dependency.afterEvaluate {
configureProjectPluginTasksDependency(dependency, this@withType)
}
}
}
}
}
}
private fun configureDownloadRobotServerPluginTask(project: Project) {
info(context, "Configuring robot-server download Task")
project.tasks.register<DownloadRobotServerPluginTask>(DOWNLOAD_ROBOT_SERVER_PLUGIN_TASK_NAME)
project.tasks.withType<DownloadRobotServerPluginTask> {
val taskContext = logCategory()
version.convention(VERSION_LATEST)
outputDir.convention(project.layout.buildDirectory.dir("robotServerPlugin"))
pluginArchive.convention(project.provider {
val resolvedVersion = resolveRobotServerPluginVersion(version.orNull)
val (group, name) = getDependency(resolvedVersion).split(':')
dependenciesDownloader.downloadFromRepository(taskContext, {
create(
group = group,
name = name,
version = resolvedVersion,
)
}, {
mavenRepository(INTELLIJ_DEPENDENCIES) {
content { includeGroup(group) }
}
}).first()
})
}
}
private fun configureRunPluginVerifierTask(project: Project, extension: IntelliJPluginExtension) {
info(context, "Configuring run plugin verifier task")
val listProductsReleasesTaskProvider = project.tasks.named<ListProductsReleasesTask>(LIST_PRODUCTS_RELEASES_TASK_NAME)
val runIdeTaskProvider = project.tasks.named<RunIdeTask>(RUN_IDE_TASK_NAME)
val userHomeProvider = project.providers.systemProperty("user.home")
project.tasks.register<RunPluginVerifierTask>(RUN_PLUGIN_VERIFIER_TASK_NAME)
project.tasks.withType<RunPluginVerifierTask> {
val taskContext = logCategory()
failureLevel.convention(EnumSet.of(RunPluginVerifierTask.FailureLevel.COMPATIBILITY_PROBLEMS))
verifierVersion.convention(VERSION_LATEST)
distributionFile.convention(project.resolveBuildTaskOutput())
verificationReportsDir.convention(
project.layout.buildDirectory.dir("reports/pluginVerifier").map { it.asFile.canonicalPath }
)
verificationReportsFormats.convention(
EnumSet.of(
RunPluginVerifierTask.VerificationReportsFormats.PLAIN,
RunPluginVerifierTask.VerificationReportsFormats.HTML,
)
)
downloadDir.convention(ideDownloadDir().map {
it.toFile().invariantSeparatorsPath
})
downloadPath.convention(userHomeProvider.map {
val userHomePath = Path.of(it)
with(downloadDir.get()) {
when {
startsWith("~/") -> userHomePath.resolve(removePrefix("~/"))
equals("~") -> userHomePath
else -> Path.of(this)
}
}
})
teamCityOutputFormat.convention(false)
subsystemsToCheck.convention("all")
ideDir.convention(runIdeTaskProvider.flatMap { runIdeTask ->
runIdeTask.ideDir
})
productsReleasesFile.convention(listProductsReleasesTaskProvider.flatMap { listProductsReleasesTask ->
listProductsReleasesTask.outputFile.asFile
})
verifierPath.convention(project.provider {
debug(context, "Using Verifier in '$currentVersion' version")
dependenciesDownloader.downloadFromRepository(taskContext, {
create(
group = "org.jetbrains.intellij.plugins",
name = "verifier-cli",
version = currentVersion,
classifier = "all",
ext = "jar",
)
}, {
mavenRepository(PLUGIN_VERIFIER_REPOSITORY)
}).first().canonicalPath
})
jreRepository.convention(extension.jreRepository)
offline.convention(project.gradle.startParameter.isOffline)
resolvedRuntimeDir.convention(project.provider {
resolveRuntimeDir(jbrResolver).toFile()
})
dependsOn(BUILD_PLUGIN_TASK_NAME)
dependsOn(VERIFY_PLUGIN_TASK_NAME)
dependsOn(LIST_PRODUCTS_RELEASES_TASK_NAME)
val isIdeVersionsEmpty = localPaths.flatMap { localPaths ->
ideVersions.map { ideVersions ->
localPaths.isEmpty() && ideVersions.isEmpty()
}
}
listProductsReleasesTaskProvider.get().onlyIf { isIdeVersionsEmpty.get() }
}
}
private fun configurePluginVerificationTask(project: Project) {
info(context, "Configuring plugin verification task")
val prepareSandboxTaskProvider = project.tasks.named<PrepareSandboxTask>(PREPARE_SANDBOX_TASK_NAME)
project.tasks.register<VerifyPluginTask>(VERIFY_PLUGIN_TASK_NAME)
project.tasks.withType<VerifyPluginTask> {
ignoreFailures.convention(false)
ignoreUnacceptableWarnings.convention(false)
ignoreWarnings.convention(true)
pluginDir.convention(
project.layout.dir(
prepareSandboxTaskProvider.flatMap { prepareSandboxTask ->
prepareSandboxTask.pluginName.map { pluginName ->
prepareSandboxTask.destinationDir.resolve(pluginName)
}
}
)
)
dependsOn(PREPARE_SANDBOX_TASK_NAME)
}
}
private fun configureVerifyPluginConfigurationTask(project: Project, ideaDependencyProvider: Provider<IdeaDependency>) {
info(context, "Configuring plugin configuration verification task")
val patchPluginXmlTaskProvider = project.tasks.named<PatchPluginXmlTask>(PATCH_PLUGIN_XML_TASK_NAME)
val runPluginVerifierTaskProvider = project.tasks.named<RunPluginVerifierTask>(RUN_PLUGIN_VERIFIER_TASK_NAME)
val compileJavaTaskProvider = project.tasks.named<JavaCompile>(COMPILE_JAVA_TASK_NAME)
val stdlibDefaultDependencyProvider = project.providers.gradleProperty("kotlin.stdlib.default.dependency").map {
it.toBoolean()
}
val incrementalUseClasspathSnapshot = project.providers.gradleProperty("kotlin.incremental.useClasspathSnapshot").map {
it.toBoolean()
}
val downloadDirProvider = runPluginVerifierTaskProvider.flatMap { runPluginVerifierTask ->
runPluginVerifierTask.downloadDir
}
project.tasks.register<VerifyPluginConfigurationTask>(VERIFY_PLUGIN_CONFIGURATION_TASK_NAME)
project.tasks.withType<VerifyPluginConfigurationTask> {
platformBuild.convention(ideaDependencyProvider.map {
it.buildNumber
})
platformVersion.convention(ideaDependencyProvider.map {
it.version
})
pluginXmlFiles.convention(patchPluginXmlTaskProvider.flatMap { patchPluginXmlTask ->
patchPluginXmlTask.outputFiles
})
sourceCompatibility.convention(compileJavaTaskProvider.map {
it.sourceCompatibility
})
targetCompatibility.convention(compileJavaTaskProvider.map {
it.targetCompatibility
})
pluginVerifierDownloadDir.convention(downloadDirProvider)
kotlinxCoroutinesLibraryPresent.convention(project.provider {
listOf(IMPLEMENTATION_CONFIGURATION_NAME, COMPILE_ONLY_CONFIGURATION_NAME).any { configurationName ->
project.configurations.getByName(configurationName).dependencies.any {
it.group == "org.jetbrains.kotlinx" && it.name.startsWith("kotlinx-coroutines")
}
}
})
kotlinPluginAvailable.convention(project.provider {
project.pluginManager.hasPlugin(KOTLIN_GRADLE_PLUGIN_ID)
})
project.pluginManager.withPlugin(KOTLIN_GRADLE_PLUGIN_ID) {
val compileKotlinTaskProvider = project.tasks.named<KotlinCompile>(COMPILE_KOTLIN_TASK_NAME)
kotlinJvmTarget.convention(project.provider {
compileKotlinTaskProvider.get().kotlinOptions.jvmTarget
})
kotlinApiVersion.convention(project.provider {
compileKotlinTaskProvider.get().kotlinOptions.apiVersion
})
kotlinLanguageVersion.convention(project.provider {
compileKotlinTaskProvider.get().kotlinOptions.languageVersion
})
kotlinVersion.convention(project.provider {
project.kotlinExtension.coreLibrariesVersion
})
kotlinStdlibDefaultDependency.convention(stdlibDefaultDependencyProvider)
kotlinIncrementalUseClasspathSnapshot.convention(incrementalUseClasspathSnapshot)
}
dependsOn(PATCH_PLUGIN_XML_TASK_NAME)
}
}
private fun configureRunIdeTask(project: Project) {
info(context, "Configuring run IDE task")
project.tasks.register<RunIdeTask>(RUN_IDE_TASK_NAME)
project.tasks.withType<RunIdeTask> {
dependsOn(PREPARE_SANDBOX_TASK_NAME)
finalizedBy(CLASSPATH_INDEX_CLEANUP_TASK_NAME)
}
}
private fun configureRunIdePerformanceTestTask(project: Project, extension: IntelliJPluginExtension) {
info(context, "Configuring run IDE performance test task")
project.tasks.register<RunIdePerformanceTestTask>(RUN_IDE_PERFORMANCE_TEST_TASK_NAME)
project.tasks.withType<RunIdePerformanceTestTask> {
artifactsDir.convention(extension.type.flatMap { type ->
extension.version.flatMap { version ->
project.layout.buildDirectory.dir(
"reports/performance-test/$type$version-${project.version}-${
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd-HHmm"))
}"
).map { it.toString() }
}
})
profilerName.convention(ProfilerName.ASYNC)
finalizedBy(CLASSPATH_INDEX_CLEANUP_TASK_NAME)
}
}
private fun resolveLatestPluginUpdate(pluginId: String, buildNumber: String, channel: String = "") =
PluginRepositoryFactory.create(MARKETPLACE_HOST)
.pluginManager
.searchCompatibleUpdates(listOf(pluginId), buildNumber, channel)
.firstOrNull()
?.let { PluginDependencyNotation(it.pluginXmlId, it.version, it.channel) }
private fun configureRunIdeForUiTestsTask(project: Project) {
info(context, "Configuring run IDE for UI tests task")
project.tasks.register<RunIdeForUiTestTask>(RUN_IDE_FOR_UI_TESTS_TASK_NAME)
project.tasks.withType<RunIdeForUiTestTask> {
dependsOn(PREPARE_UI_TESTING_SANDBOX_TASK_NAME)
finalizedBy(CLASSPATH_INDEX_CLEANUP_TASK_NAME)
}
}
private fun configureBuildSearchableOptionsTask(project: Project) {
info(context, "Configuring build searchable options task")
project.tasks.register<BuildSearchableOptionsTask>(BUILD_SEARCHABLE_OPTIONS_TASK_NAME)
project.tasks.withType<BuildSearchableOptionsTask> {
outputDir.convention(project.layout.buildDirectory.dir(SEARCHABLE_OPTIONS_DIR_NAME))
showPaidPluginWarning.convention(project.provider {
project.isBuildFeatureEnabled(PAID_PLUGIN_SEARCHABLE_OPTIONS_WARNING) && run {
sourcePluginXmlFiles(project).any {
parsePluginXml(it, context)?.productDescriptor != null
}
}
})
dependsOn(PREPARE_SANDBOX_TASK_NAME)
onlyIf {
val number = ideBuildNumber(ideDir.get().toPath())
Version.parse(number.split('-').last()) >= Version.parse("191.2752")
}
}
}
private fun RunIdeBase.prepareConventionMappingsForRunIdeTask(
project: Project,
extension: IntelliJPluginExtension,
ideaDependencyProvider: Provider<IdeaDependency>,
prepareSandBoxTaskName: String,
) {
val taskContext = logCategory()
val prepareSandboxTaskProvider = project.tasks.named<PrepareSandboxTask>(prepareSandBoxTaskName)
val initializeIntelliJPluginTaskProvider = project.tasks.named<InitializeIntelliJPluginTask>(INITIALIZE_INTELLIJ_PLUGIN_TASK_NAME)
val pluginIds = sourcePluginXmlFiles(project).mapNotNull { parsePluginXml(it, taskContext)?.id }
ideDir.convention(ideaDependencyProvider.map {
project.file(it.classes.path)
})
requiredPluginIds.convention(project.provider {
pluginIds
})
configDir.convention(prepareSandboxTaskProvider.flatMap { prepareSandboxTask ->
prepareSandboxTask.configDir.map { project.file(it) }
})
pluginsDir.convention(prepareSandboxTaskProvider.map { prepareSandboxTask ->
project.layout.projectDirectory.dir(prepareSandboxTask.destinationDir.path)
})
systemDir.convention(extension.sandboxDir.map {
project.file("$it/system")
})
autoReloadPlugins.convention(ideDir.map {
val number = ideBuildNumber(it.toPath())
Version.parse(number.split('-').last()) >= Version.parse("202.0")
})
projectWorkingDir.convention(ideDir.map {
it.resolve("bin")
})
projectExecutable.convention(project.provider {
jbrResolver.resolveRuntime(
jbrVersion = jbrVersion.orNull,
jbrVariant = jbrVariant.orNull,
jbrArch = jbrArch.orNull,
ideDir = ideDir.orNull,
).toString()
})
coroutinesJavaAgentPath.convention(initializeIntelliJPluginTaskProvider.flatMap {
it.coroutinesJavaAgentPath
})
}
private fun configureJarSearchableOptionsTask(project: Project) {
info(context, "Configuring jar searchable options task")
val prepareSandboxTaskProvider = project.tasks.named<PrepareSandboxTask>(PREPARE_SANDBOX_TASK_NAME)
project.tasks.register<JarSearchableOptionsTask>(JAR_SEARCHABLE_OPTIONS_TASK_NAME)
project.tasks.withType<JarSearchableOptionsTask> {
inputDir.convention(project.layout.buildDirectory.dir(SEARCHABLE_OPTIONS_DIR_NAME))
pluginName.convention(prepareSandboxTaskProvider.flatMap { prepareSandboxTask ->
prepareSandboxTask.pluginName
})
sandboxDir.convention(prepareSandboxTaskProvider.map { prepareSandboxTask ->
prepareSandboxTask.destinationDir.canonicalPath
})
archiveBaseName.convention("lib/$SEARCHABLE_OPTIONS_DIR_NAME")
destinationDirectory.convention(project.layout.buildDirectory.dir("libsSearchableOptions"))
noSearchableOptionsWarning.convention(project.provider {
project.isBuildFeatureEnabled(NO_SEARCHABLE_OPTIONS_WARNING)
})
dependsOn(BUILD_SEARCHABLE_OPTIONS_TASK_NAME)
dependsOn(PREPARE_SANDBOX_TASK_NAME)
onlyIf { inputDir.get().asFile.isDirectory }
}
}
private fun configureInstrumentation(project: Project, extension: IntelliJPluginExtension, ideaDependencyProvider: Provider<IdeaDependency>) {
info(context, "Configuring compile tasks")
val instrumentedJar = project.configurations.create(INSTRUMENTED_JAR_CONFIGURATION_NAME)
.apply {
isCanBeConsumed = true
isCanBeResolved = false
extendsFrom(project.configurations["implementation"], project.configurations["runtimeOnly"])
}
val jarTaskProvider = project.tasks.named<Jar>(JAR_TASK_NAME)
val instrumentCodeProvider = project.provider { extension.instrumentCode.get() }