Skip to content

Commit

Permalink
Force resolve IntelliJ Platform configuration because we need it to b…
Browse files Browse the repository at this point in the history
…e ready for defining the default dependencies.
  • Loading branch information
AlexanderBartash committed Oct 12, 2024
1 parent 8085539 commit d937e1f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.gradle.testkit.runner.TaskOutcome
import org.jetbrains.intellij.platform.gradle.Constants.Tasks
import org.jetbrains.intellij.platform.gradle.models.Coordinates
import org.jetbrains.intellij.platform.gradle.models.resolveLatestVersion
import kotlin.test.Ignore
import kotlin.test.Test

private const val DEPENDENCIES = "dependencies"
Expand All @@ -15,6 +16,7 @@ class IntelliJPlatformDependencyValidationIntegrationTest : IntelliJPlatformInte
) {

@Test
@Ignore("Because we do not allow it now, since we force resolve it.")
fun `allow for no IntelliJ Platform dependency if not running tasks`() {
build(DEPENDENCIES) {
assertContains(
Expand Down Expand Up @@ -72,6 +74,7 @@ class IntelliJPlatformDependencyValidationIntegrationTest : IntelliJPlatformInte
}

@Test
@Ignore("Because we can not add any more dependencies, since we force resolve it.")
fun `report too many IntelliJ Platform dependencies`() {
buildFile write //language=kotlin
"""
Expand All @@ -95,6 +98,7 @@ class IntelliJPlatformDependencyValidationIntegrationTest : IntelliJPlatformInte
}

@Test
@Ignore("Because we do not allow it now, since we force resolve it.")
fun `inform about missing IntelliJ Platform dependency`() {
buildFile write //language=kotlin
"""
Expand Down Expand Up @@ -200,6 +204,7 @@ class IntelliJPlatformDependencyValidationIntegrationTest : IntelliJPlatformInte
}

@Test
@Ignore("Because there is a default dependency now.")
fun `fail signing when no Marketplace ZIP Signer dependency is present`() {
buildFile write //language=kotlin
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ class IntelliJPlatformDependenciesHelper(
}
}.apply(action)
})

// This is dicey.
runCatching {
configurations[configurationName].resolve()
}.onFailure {
log.warn(it.message.orEmpty())
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,12 @@ abstract class IntelliJPlatformBasePlugin : Plugin<Project> {
attribute(Attributes.extracted, false)
}

intellijPlatformConfiguration.incoming.afterResolve {
if (intellijPlatformConfiguration.resolvedConfiguration.hasError()) {
log.warn("Configuration '$intellijPlatformConfiguration' has some resolution errors.")
} else if (intellijPlatformConfiguration.isEmpty) {
log.warn("Configuration '$intellijPlatformConfiguration' is empty.")
} else {
defaultDependencies {
val dependency = dependenciesHelper.obtainJetBrainsRuntimeVersion()
.map { version -> dependenciesHelper.createJetBrainsRuntime(version) }.get()
add(dependency)
}
}
defaultDependencies {
// The provider is pointless, but it improves stack traces because they point to this line
addLater(project.providers.provider {
dependenciesHelper.obtainJetBrainsRuntimeVersion()
.map { version -> dependenciesHelper.createJetBrainsRuntime(version) }.get()
})
}
}

Expand Down Expand Up @@ -196,17 +190,9 @@ abstract class IntelliJPlatformBasePlugin : Plugin<Project> {
name = Configurations.INTELLIJ_PLUGIN_VERIFIER,
description = "IntelliJ Plugin Verifier",
) {
intellijPlatformConfiguration.incoming.afterResolve {
if (intellijPlatformConfiguration.resolvedConfiguration.hasError()) {
log.warn("Configuration '$intellijPlatformConfiguration' has some resolution errors.")
} else if (intellijPlatformConfiguration.isEmpty) {
log.warn("Configuration '$intellijPlatformConfiguration' is empty.")
} else {
defaultDependencies {
add(dependenciesHelper.createPluginVerifier())
}
}
}
defaultDependencies {
addLater(project.providers.provider { dependenciesHelper.createPluginVerifier() })
}
}

val intellijPluginVerifierIdesDependencyConfiguration = create(
Expand Down Expand Up @@ -242,16 +228,8 @@ abstract class IntelliJPlatformBasePlugin : Plugin<Project> {
name = Configurations.MARKETPLACE_ZIP_SIGNER,
description = "Marketplace ZIP Signer",
) {
intellijPlatformConfiguration.incoming.afterResolve {
if (intellijPlatformConfiguration.resolvedConfiguration.hasError()) {
log.warn("Configuration '$intellijPlatformConfiguration' has some resolution errors.")
} else if (intellijPlatformConfiguration.isEmpty) {
log.warn("Configuration '$intellijPlatformConfiguration' is empty.")
} else {
defaultDependencies {
add(dependenciesHelper.createMarketplaceZipSigner())
}
}
defaultDependencies {
addLater(project.providers.provider { dependenciesHelper.createMarketplaceZipSigner() })
}
}

Expand All @@ -270,16 +248,8 @@ abstract class IntelliJPlatformBasePlugin : Plugin<Project> {
name = Configurations.INTELLIJ_PLATFORM_JAVA_COMPILER,
description = "Java Compiler used by Ant tasks",
) {
intellijPlatformConfiguration.incoming.afterResolve {
if (intellijPlatformConfiguration.resolvedConfiguration.hasError()) {
log.warn("Configuration '$intellijPlatformConfiguration' has some resolution errors.")
} else if (intellijPlatformConfiguration.isEmpty) {
log.warn("Configuration '$intellijPlatformConfiguration' is empty.")
} else {
defaultDependencies {
add(dependenciesHelper.createJavaCompiler())
}
}
defaultDependencies {
addLater(project.providers.provider { dependenciesHelper.createJavaCompiler() })
}
}

Expand Down Expand Up @@ -378,7 +348,11 @@ abstract class IntelliJPlatformBasePlugin : Plugin<Project> {
}

PluginVerification.register(project, target = intelliJPlatform).let { pluginVerification ->
PluginVerification.Ides.register(dependenciesHelper, project.extensionProvider, target = pluginVerification)
PluginVerification.Ides.register(
dependenciesHelper,
project.extensionProvider,
target = pluginVerification
)
}

Signing.register(project, target = intelliJPlatform)
Expand Down

0 comments on commit d937e1f

Please sign in to comment.