Skip to content

Commit 67a35c9

Browse files
committed
Merge remote-tracking branch 'origin/master' into fix/failing_6_8_compat_test
2 parents 68b21d0 + 892b8d1 commit 67a35c9

File tree

7 files changed

+80
-71
lines changed

7 files changed

+80
-71
lines changed

.github/workflows/reusable-codeInspection.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Reusable test workflow
1+
name: Reusable Code Inspection
22

33
on: [ workflow_call ]
44

.github/workflows/reusable-unitTests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Reusable test workflow
1+
name: Reusable Unit Tests
22

33
on: [ workflow_call ]
44

src/main/kotlin/org/jetbrains/intellij/IntelliJPlugin.kt

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ import org.gradle.api.artifacts.Dependency
1414
import org.gradle.api.artifacts.DependencySet
1515
import org.gradle.api.file.ConfigurableFileCollection
1616
import org.gradle.api.file.DuplicatesStrategy
17-
import org.gradle.api.file.RegularFile
1817
import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact
1918
import org.gradle.api.internal.plugins.DefaultArtifactPublicationSet
2019
import org.gradle.api.plugins.ExtensionAware
2120
import org.gradle.api.plugins.JavaPlugin
2221
import org.gradle.api.plugins.JavaPlugin.COMPILE_JAVA_TASK_NAME
2322
import org.gradle.api.plugins.PluginInstantiationException
24-
import org.gradle.api.provider.Provider
2523
import org.gradle.api.tasks.ClasspathNormalizer
2624
import org.gradle.api.tasks.PathSensitivity
2725
import org.gradle.api.tasks.SourceSetContainer
@@ -424,20 +422,38 @@ abstract class IntelliJPlugin : Plugin<Project> {
424422

425423
val setupDependenciesTaskProvider = project.tasks.named<SetupDependenciesTask>(SETUP_DEPENDENCIES_TASK_NAME)
426424
val jarTaskProvider = project.tasks.named<Jar>(JavaPlugin.JAR_TASK_NAME)
425+
val runtimeConfiguration = project.configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)
427426

427+
val ideaDependencyJarFiles = setupDependenciesTaskProvider.flatMap { setupDependenciesTask ->
428+
setupDependenciesTask.idea.map {
429+
project.files(it.jarFiles)
430+
}
431+
}
432+
val jarArchiveFile = jarTaskProvider.flatMap { jarTask ->
433+
jarTask.archiveFile
434+
}
435+
val runtimeConfigurationFiles = project.provider {
436+
runtimeConfiguration.allDependencies.flatMap {
437+
runtimeConfiguration.fileCollection(it)
438+
}
439+
}
428440
val gradleVersion = project.provider { project.gradle.gradleVersion }
429441
val projectVersion = project.provider { project.version }
430-
val version = project.provider { project.version }
431442
val buildSdk = project.provider {
432-
when (extension.localPath.orNull) {
433-
null -> "${extension.getVersionType()}-${extension.getVersionNumber()}"
434-
else -> setupDependenciesTaskProvider.get().idea.get().classes.let { ideaClasses ->
435-
ideProductInfo(ideaClasses)?.run { "$productCode-$version" }
436-
// Fall back on build number if product-info.json is not present, this is the case
437-
// for recent versions of Android Studio.
438-
?: ideBuildNumber(ideaClasses)
443+
extension.localPath.flatMap {
444+
setupDependenciesTaskProvider.flatMap { setupDependenciesTask ->
445+
setupDependenciesTask.idea.map { ideaDependency ->
446+
ideaDependency.classes.let {
447+
ideProductInfo(it)?.run { "$productCode-$projectVersion" }
448+
// Fall back on build number if product-info.json is not present, this is the case
449+
// for recent versions of Android Studio.
450+
?: ideBuildNumber(it)
451+
}
452+
}
439453
}
440-
}
454+
}.orElse(project.provider {
455+
"${extension.getVersionType()}-${extension.getVersionNumber()}"
456+
})
441457
}
442458

443459
jarTaskProvider.configure {
@@ -457,24 +473,39 @@ abstract class IntelliJPlugin : Plugin<Project> {
457473
project.tasks.register<PrepareSandboxTask>(taskName) {
458474
group = PLUGIN_GROUP_NAME
459475
description = "Prepares sandbox directory with installed plugin and its dependencies."
476+
duplicatesStrategy = DuplicatesStrategy.FAIL
460477

461478
pluginName.convention(extension.pluginName)
462-
pluginJar.convention(jarTaskProvider.get().archiveFile)
479+
pluginJar.convention(jarArchiveFile)
463480
defaultDestinationDir.convention(extension.sandboxDir.map {
464481
project.file("$it/plugins$testSuffix")
465482
})
466483
configDir.convention(extension.sandboxDir.map {
467484
"$it/config$testSuffix"
468485
})
469-
librariesToIgnore.convention(setupDependenciesTaskProvider.get().idea.map {
470-
project.files(it.jarFiles)
471-
})
486+
librariesToIgnore.convention(ideaDependencyJarFiles)
472487
pluginDependencies.convention(project.provider {
473488
extension.getPluginDependenciesList(project)
474489
})
475490

491+
492+
intoChild(pluginName.map { "$it/lib" })
493+
.from(runtimeConfigurationFiles.map { files ->
494+
val librariesToIgnore = librariesToIgnore.get().toSet() + Jvm.current().toolsJar
495+
val pluginDirectories = pluginDependencies.get().map { it.artifact.canonicalPath }
496+
497+
listOf(pluginJar.get().asFile) + files.filter { file ->
498+
!(librariesToIgnore.contains(file) || pluginDirectories.any { p ->
499+
file.canonicalPath == p || file.canonicalPath.startsWith("$p${File.separator}")
500+
})
501+
}
502+
})
503+
.eachFile {
504+
name = ensureName(file.toPath())
505+
}
506+
476507
dependsOn(JavaPlugin.JAR_TASK_NAME)
477-
dependsOn(project.configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME))
508+
dependsOn(runtimeConfiguration)
478509
dependsOn(SETUP_DEPENDENCIES_TASK_NAME)
479510

480511
configure?.invoke(this)
@@ -1274,9 +1305,13 @@ abstract class IntelliJPlugin : Plugin<Project> {
12741305
channels.convention(listOf("default"))
12751306

12761307
distributionFile.convention(
1277-
signPluginTaskProvider.flatMap { signPluginTask ->
1278-
signPluginTask.outputArchiveFile
1279-
}.orElse(resolveBuildTaskOutput(project))
1308+
signPluginTaskProvider
1309+
.flatMap { signPluginTask ->
1310+
when (signPluginTask.didWork) {
1311+
true -> signPluginTask.outputArchiveFile
1312+
else -> resolveBuildTaskOutput(project)
1313+
}
1314+
}
12801315
)
12811316

12821317
dependsOn(BUILD_PLUGIN_TASK_NAME)

src/main/kotlin/org/jetbrains/intellij/tasks/PrepareSandboxTask.kt

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@
22

33
package org.jetbrains.intellij.tasks
44

5+
import com.jetbrains.plugin.structure.base.utils.extension
6+
import com.jetbrains.plugin.structure.base.utils.nameWithoutExtension
7+
import com.jetbrains.plugin.structure.base.utils.simpleName
58
import com.jetbrains.plugin.structure.intellij.utils.JDOMUtil
69
import groovy.lang.Closure
710
import org.gradle.api.GradleException
811
import org.gradle.api.Task
9-
import org.gradle.api.file.DuplicatesStrategy
12+
import org.gradle.api.file.CopySpec
1013
import org.gradle.api.file.RegularFileProperty
11-
import org.gradle.api.plugins.JavaPlugin
1214
import org.gradle.api.provider.ListProperty
1315
import org.gradle.api.provider.Property
1416
import org.gradle.api.tasks.*
15-
import org.gradle.internal.jvm.Jvm
1617
import org.jdom2.Element
1718
import org.jetbrains.intellij.dependency.PluginDependency
1819
import org.jetbrains.intellij.dependency.PluginProjectDependency
1920
import org.jetbrains.intellij.error
2021
import org.jetbrains.intellij.logCategory
2122
import org.jetbrains.intellij.transformXml
2223
import java.io.File
24+
import java.nio.file.Path
2325

2426
abstract class PrepareSandboxTask : Sync() {
2527

@@ -73,56 +75,20 @@ abstract class PrepareSandboxTask : Sync() {
7375
abstract val defaultDestinationDir: Property<File>
7476

7577
private val context = logCategory()
76-
77-
init {
78-
duplicatesStrategy = DuplicatesStrategy.FAIL
79-
configurePlugin()
80-
}
78+
private val usedNames = mutableMapOf<String, Path>()
8179

8280
@TaskAction
8381
override fun copy() {
8482
disableIdeUpdate()
8583
super.copy()
8684
}
8785

86+
fun intoChild(destinationDir: Any): CopySpec = mainSpec.addChild().into(destinationDir)
87+
8888
override fun getDestinationDir(): File = defaultDestinationDir.get()
8989

9090
override fun configure(closure: Closure<*>): Task = super.configure(closure)
9191

92-
private fun configurePlugin() {
93-
val plugin = mainSpec.addChild().into(project.provider { "${pluginName.get()}/lib" })
94-
val usedNames = mutableMapOf<String, String>()
95-
val runtimeConfiguration = project.configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)
96-
val librariesToIgnore = librariesToIgnore.get().toSet() + Jvm.current().toolsJar
97-
val pluginDirectories = pluginDependencies.get().map { it.artifact.canonicalPath }
98-
99-
plugin.from(project.provider {
100-
listOf(pluginJar.get().asFile) + runtimeConfiguration.allDependencies.map {
101-
runtimeConfiguration.fileCollection(it).filter { file ->
102-
!(librariesToIgnore.contains(file) || pluginDirectories.any { p ->
103-
file.canonicalPath == p || file.canonicalPath.startsWith("$p${File.separator}")
104-
})
105-
}
106-
}.flatten()
107-
}).eachFile {
108-
val dotIndex = name.lastIndexOf('.')
109-
val originalName = when {
110-
dotIndex != -1 -> name.substring(0, dotIndex)
111-
else -> name
112-
}
113-
val originalExtension = when {
114-
dotIndex != -1 -> name.substring(dotIndex)
115-
else -> ""
116-
}
117-
var index = 1
118-
var previousPath = usedNames.putIfAbsent(name, file.canonicalPath)
119-
while (previousPath != null && previousPath != file.canonicalPath) {
120-
name = "${originalName}_${index++}${originalExtension}"
121-
previousPath = usedNames.putIfAbsent(name, file.canonicalPath)
122-
}
123-
}
124-
}
125-
12692
fun configureCompositePlugin(pluginDependency: PluginProjectDependency) {
12793
from(pluginDependency.artifact) { into(pluginDependency.artifact.name) }
12894
}
@@ -183,4 +149,16 @@ abstract class PrepareSandboxTask : Sync() {
183149
transformXml(document, updatesConfig)
184150
}
185151
}
152+
153+
fun ensureName(file: Path): String {
154+
var name = file.simpleName
155+
var index = 1
156+
var previousPath = usedNames.putIfAbsent(name, file)
157+
while (previousPath != null && previousPath != file) {
158+
name = "${file.nameWithoutExtension}_${index++}.${file.extension}"
159+
previousPath = usedNames.putIfAbsent(name, file)
160+
}
161+
162+
return name
163+
}
186164
}

src/main/kotlin/org/jetbrains/intellij/tasks/VerifyPluginConfigurationTask.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ abstract class VerifyPluginConfigurationTask @Inject constructor(
150150
}
151151

152152
if (
153-
pluginVerifierDownloadPath == oldPluginVerifierDownloadPath
153+
pluginVerifierDownloadPath != oldPluginVerifierDownloadPath
154154
&& oldPluginVerifierDownloadPath.exists()
155155
&& oldPluginVerifierDownloadPath.listFiles().isNotEmpty()
156156
) {

src/main/kotlin/org/jetbrains/intellij/utils.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,8 @@ fun getIdeaSystemProperties(
139139
}
140140

141141
fun getIdeJvmArgs(options: JavaForkOptions, arguments: List<String>?, ideDirectory: File?): List<String> {
142-
with(options) {
143-
maxHeapSize = maxHeapSize ?: "512m"
144-
minHeapSize = minHeapSize ?: "256m"
145-
}
146-
147142
val productInfo = ideProductInfo(ideDirectory!!)
143+
val defaults = listOf("-Xmx512m", "-Xms256m")
148144
val bootclasspath = ideDirectory
149145
.resolve("lib/boot.jar")
150146
.takeIf { it.exists() }
@@ -158,7 +154,7 @@ fun getIdeJvmArgs(options: JavaForkOptions, arguments: List<String>?, ideDirecto
158154
?.takeIf { it.isNotEmpty() }
159155
?: OpenedPackages
160156

161-
return arguments.orEmpty() + bootclasspath + vmOptions + additionalJvmArguments
157+
return defaults + arguments.orEmpty() + bootclasspath + vmOptions + additionalJvmArguments + options.allJvmArgs
162158
}
163159

164160
fun ideBuildNumber(ideDirectory: File) = (

src/test/kotlin/org/jetbrains/intellij/tasks/VerifyPluginConfigurationTaskSpec.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class VerifyPluginConfigurationTaskSpec : IntelliJPluginSpecBase() {
2222
super.setUp()
2323

2424
gradleArguments.add("-Duser.home=$gradleHome")
25-
File(gradleHome).run {
25+
File(gradleHome).resolve(".pluginVerifier/ides").run {
2626
deleteRecursively()
2727
mkdirs()
2828
}

0 commit comments

Comments
 (0)