Skip to content

Commit 4c30b4e

Browse files
authored
Update intellij plugin to 1.1 (#2598)
1 parent 90efaf6 commit 4c30b4e

File tree

11 files changed

+124
-137
lines changed

11 files changed

+124
-137
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ To test your changes locally, you can run the project from IntelliJ or gradle.
9292
```
9393
- This is needed to run PyCharm and WebStorm.
9494
- Notice that the top-level `:runIde` target is always used with `ALTERNATIVE_IDE`.
95-
- See also `alternativeIdePath` in the Gradle IntelliJ Plugin [documentation](https://github.com/JetBrains/gradle-intellij-plugin).
95+
- See also `ideDirectory` option in the `runIde` and `buildSearchableOptions` tasks provided by the Gradle IntelliJ Plugin [documentation](https://github.com/JetBrains/gradle-intellij-plugin).
9696
- To run **integration tests**:
9797
```
9898
./gradlew integrationTest

build.gradle.kts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,25 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import software.aws.toolkits.gradle.changelog.tasks.GenerateGithubChangeLog
5-
import software.aws.toolkits.gradle.intellij.IdeVersions
6-
7-
val ideProfile = IdeVersions.ideProfile(project)
8-
val toolkitVersion: String by project
95

106
plugins {
117
id("base")
128
id("toolkit-changelog")
139
id("toolkit-jacoco-report")
1410
}
1511

12+
val codeArtifactUrl: Provider<String> = providers.environmentVariable("CODEARTIFACT_URL").forUseAtConfigurationTime()
13+
val codeArtifactToken: Provider<String> = providers.environmentVariable("CODEARTIFACT_AUTH_TOKEN").forUseAtConfigurationTime()
14+
1615
allprojects {
1716
repositories {
18-
mavenLocal()
19-
System.getenv("CODEARTIFACT_URL")?.let {
20-
println("Using CodeArtifact proxy: $it")
17+
if (codeArtifactUrl.isPresent && codeArtifactToken.isPresent) {
18+
println("Using CodeArtifact proxy: ${codeArtifactUrl.get()}")
2119
maven {
22-
url = uri(it)
20+
url = uri(codeArtifactUrl.get())
2321
credentials {
2422
username = "aws"
25-
password = System.getenv("CODEARTIFACT_AUTH_TOKEN")
23+
password = codeArtifactToken.get()
2624
}
2725
}
2826
}

buildSrc/settings.gradle.kts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
val codeArtifactUrl: Provider<String> = providers.environmentVariable("CODEARTIFACT_URL").forUseAtConfigurationTime()
5+
val codeArtifactToken: Provider<String> = providers.environmentVariable("CODEARTIFACT_AUTH_TOKEN").forUseAtConfigurationTime()
6+
47
dependencyResolutionManagement {
58
repositories {
6-
mavenLocal()
7-
System.getenv("CODEARTIFACT_URL")?.let {
8-
println("Using CodeArtifact proxy: $it")
9+
if (codeArtifactUrl.isPresent && codeArtifactToken.isPresent) {
10+
println("Using CodeArtifact proxy: ${codeArtifactUrl.get()}")
911
maven {
10-
url = uri(it)
12+
url = uri(codeArtifactUrl.get())
1113
credentials {
1214
username = "aws"
13-
password = System.getenv("CODEARTIFACT_AUTH_TOKEN")
15+
password = codeArtifactToken.get()
1416
}
1517
}
1618
}

buildSrc/src/main/kotlin/software/aws/toolkits/gradle/BuildScriptUtils.kt

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,15 @@
33

44
package software.aws.toolkits.gradle
55

6-
import org.gradle.api.GradleException
76
import org.gradle.api.Project
8-
import org.jetbrains.intellij.IntelliJPluginExtension
9-
10-
/* When we dynamically apply(plugin = "org.jetbrains.intellij"), we do not get the nice extension functions
11-
* pulled into scope. This function hides that fact, and gives a better error message when it fails.
12-
*/
13-
fun Project.intellij(block: IntelliJPluginExtension.() -> Unit) {
14-
val intellij = try {
15-
project.extensions.getByType(IntelliJPluginExtension::class.java)
16-
} catch (e: Exception) {
17-
throw GradleException("Unable to get extension intellij, did you apply(plugin = \"org.jetbrains.intellij\")?", e)
18-
}
19-
intellij.block()
20-
}
217

228
/**
239
* Only run the given block if this build is running within a CI system (e.g. GitHub actions, CodeBuild etc)
2410
*/
2511
fun Project.ciOnly(block: () -> Unit) {
26-
if (providers.environmentVariable("CI").forUseAtConfigurationTime().isPresent) {
12+
if (isCi()) {
2713
block()
2814
}
2915
}
16+
17+
fun Project.isCi() : Boolean = providers.environmentVariable("CI").isPresent

buildSrc/src/main/kotlin/software/aws/toolkits/gradle/intellij/IdeVersions.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
package software.aws.toolkits.gradle.intellij
55

66
import org.gradle.api.Project
7+
import org.gradle.api.provider.Provider
8+
import org.gradle.api.provider.ProviderFactory
79

810
object IdeVersions {
9-
fun ideProfile(project: Project): Profile {
10-
val profileName = resolveIdeProfileName(project)
11-
return ideProfiles[profileName] ?: throw IllegalStateException("Can't find profile for $profileName")
11+
fun ideProfile(project: Project): Profile = ideProfile(project.providers).get()
12+
13+
fun ideProfile(providers: ProviderFactory): Provider<Profile> = resolveIdeProfileName(providers).map {
14+
ideProfiles[it] ?: throw IllegalStateException("Can't find profile for $it")
1215
}
1316

1417
private val ideProfiles = listOf(
@@ -86,11 +89,10 @@ object IdeVersions {
8689
)
8790
).associateBy { it.name }
8891

89-
private fun resolveIdeProfileName(project: Project): String = if (System.getenv()["ALTERNATIVE_IDE_PROFILE_NAME"] != null) {
90-
System.getenv("ALTERNATIVE_IDE_PROFILE_NAME")
91-
} else {
92-
project.properties["ideProfileName"]?.toString() ?: throw IllegalStateException("No ideProfileName property set")
93-
}
92+
private fun resolveIdeProfileName(providers: ProviderFactory): Provider<String> =
93+
providers.environmentVariable("ALTERNATIVE_IDE_PROFILE_NAME").forUseAtConfigurationTime().orElse(
94+
providers.gradleProperty("ideProfileName").forUseAtConfigurationTime()
95+
)
9496
}
9597

9698
open class ProductProfile(

buildSrc/src/main/kotlin/software/aws/toolkits/gradle/intellij/ToolkitIntelliJExtension.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,21 @@
44
package software.aws.toolkits.gradle.intellij
55

66
import org.gradle.api.provider.Property
7+
import org.gradle.api.provider.Provider
8+
import org.gradle.api.provider.ProviderFactory
79

8-
abstract class ToolkitIntelliJExtension {
9-
enum class IdeFlavor {IC, IU, RD}
10+
abstract class ToolkitIntelliJExtension(private val providers: ProviderFactory) {
11+
enum class IdeFlavor { IC, IU, RD }
1012

1113
abstract val ideFlavor: Property<IdeFlavor>
14+
15+
fun ideProfile() = IdeVersions.ideProfile(providers)
16+
17+
fun productProfile(): Provider<out ProductProfile> = ideFlavor.flatMap { flavor ->
18+
when (flavor) {
19+
IdeFlavor.IC -> ideProfile().map { it.community }
20+
IdeFlavor.IU -> ideProfile().map { it.ultimate }
21+
IdeFlavor.RD -> ideProfile().map { it.rider }
22+
}
23+
}
1224
}

buildSrc/src/main/kotlin/toolkit-intellij-subplugin.gradle.kts

Lines changed: 66 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import org.gradle.testing.jacoco.plugins.JacocoTaskExtension.Output
5-
import org.jetbrains.intellij.Utils
65
import org.jetbrains.intellij.tasks.DownloadRobotServerPluginTask
76
import org.jetbrains.intellij.tasks.RunIdeForUiTestTask
8-
import software.aws.toolkits.gradle.intellij.IdeVersions
97
import software.aws.toolkits.gradle.ciOnly
108
import software.aws.toolkits.gradle.findFolders
11-
import software.aws.toolkits.gradle.intellij
9+
import software.aws.toolkits.gradle.intellij.IdeVersions
1210
import software.aws.toolkits.gradle.intellij.ToolkitIntelliJExtension
1311
import software.aws.toolkits.gradle.intellij.ToolkitIntelliJExtension.IdeFlavor
12+
import software.aws.toolkits.gradle.isCi
1413

1514
val toolkitIntelliJ = project.extensions.create<ToolkitIntelliJExtension>("intellijToolkit")
1615

@@ -51,8 +50,6 @@ configurations {
5150
runtimeClasspath {
5251
// Exclude dependencies that ship with iDE
5352
exclude(group = "org.slf4j")
54-
exclude(group = "org.jetbrains.kotlin")
55-
exclude(group = "org.jetbrains.kotlinx")
5653

5754
// Exclude dependencies we don't use to make plugin smaller
5855
exclude(group = "software.amazon.awssdk", module = "netty-nio-client")
@@ -65,92 +62,83 @@ tasks.processResources {
6562
}
6663

6764
// Run after the project has been evaluated so that the extension (intellijToolkit) has been configured
68-
afterEvaluate {
69-
val flavor = toolkitIntelliJ.ideFlavor.get()
70-
val productProfile = when (flavor) {
71-
IdeFlavor.IC -> ideProfile.community
72-
IdeFlavor.IU -> ideProfile.ultimate
73-
IdeFlavor.RD -> ideProfile.rider
74-
}
65+
intellij {
66+
pluginName.set("aws-toolkit-jetbrains")
67+
version.set(toolkitIntelliJ.productProfile().map { it.sdkVersion })
68+
plugins.set(toolkitIntelliJ.productProfile().map { it.plugins.toMutableList() })
7569

76-
intellij {
77-
pluginName = "aws-toolkit-jetbrains"
78-
version = productProfile.sdkVersion
70+
downloadSources.set(toolkitIntelliJ.ideFlavor.map { it == IdeFlavor.IC && !project.isCi() })
71+
instrumentCode.set(toolkitIntelliJ.ideFlavor.map { it != IdeFlavor.RD })
72+
}
7973

80-
setPlugins(*productProfile.plugins)
74+
tasks.jar {
75+
archiveBaseName.set(toolkitIntelliJ.ideFlavor.map { "aws-toolkit-jetbrains-$it" })
76+
}
8177

82-
downloadSources = flavor != IdeFlavor.IC
83-
instrumentCode = flavor != IdeFlavor.RD
84-
}
78+
tasks.patchPluginXml {
79+
sinceBuild.set(toolkitIntelliJ.ideProfile().map { it.sinceVersion })
80+
untilBuild.set(toolkitIntelliJ.ideProfile().map { it.untilVersion })
81+
}
8582

86-
tasks.jar {
87-
archiveBaseName.set("aws-toolkit-jetbrains-$flavor")
88-
}
83+
// Disable building the settings search cache since it 1. fails the build, 2. gets run on the final packaged plugin
84+
tasks.buildSearchableOptions {
85+
enabled = false
86+
}
8987

90-
tasks.patchPluginXml {
91-
setSinceBuild(ideProfile.sinceVersion)
92-
setUntilBuild(ideProfile.untilVersion)
93-
}
88+
tasks.withType<Test>().all {
89+
systemProperty("log.dir", intellij.sandboxDir.map { "$it-test/logs" }.get())
90+
systemProperty("testDataPath", project.rootDir.resolve("testdata").absolutePath)
91+
}
9492

95-
// Disable building the settings search cache since it 1. fails the build, 2. gets run on the final packaged plugin
96-
tasks.buildSearchableOptions {
97-
enabled = false
98-
}
93+
tasks.withType<JavaExec> {
94+
systemProperty("aws.toolkits.enableTelemetry", false)
95+
}
9996

100-
tasks.withType<Test>().all {
101-
systemProperty("log.dir", "${Utils.stringInput(intellij.sandboxDirectory)}-test/logs")
102-
systemProperty("testDataPath", project.rootDir.resolve("testdata").absolutePath)
97+
tasks.runIde {
98+
val alternativeIde = providers.environmentVariable("ALTERNATIVE_IDE").forUseAtConfigurationTime()
99+
if (alternativeIde.isPresent) {
100+
// remove the trailing slash if there is one or else it will not work
101+
val value = alternativeIde.get()
102+
val path = File(value.trimEnd('/'))
103+
if (path.exists()) {
104+
ideDir.set(path)
105+
} else {
106+
throw GradleException("ALTERNATIVE_IDE path not found $value")
107+
}
103108
}
109+
}
104110

105-
tasks.withType<JavaExec> {
106-
systemProperty("aws.toolkits.enableTelemetry", false)
107-
}
111+
tasks.withType<DownloadRobotServerPluginTask> {
112+
version.set(remoteRobotVersion)
113+
}
108114

109-
tasks.runIde {
110-
val alternativeIde = System.getenv("ALTERNATIVE_IDE")
111-
if (alternativeIde != null) {
112-
// remove the trailing slash if there is one or else it will not work
113-
val path = alternativeIde.trimEnd('/')
114-
if (File(path).exists()) {
115-
setIdeDirectory(path)
116-
} else {
117-
throw GradleException("ALTERNATIVE_IDE path not found $alternativeIde")
118-
}
119-
}
115+
// Enable coverage for the UI test target IDE
116+
extensions.getByType<JacocoPluginExtension>().applyTo(tasks.withType<RunIdeForUiTestTask>())
117+
tasks.withType<RunIdeForUiTestTask>().all {
118+
systemProperty("robot-server.port", remoteRobotPort)
119+
systemProperty("ide.mac.file.chooser.native", "false")
120+
systemProperty("jb.consents.confirmation.enabled", "false")
121+
// This does some magic in EndUserAgreement.java to make it not show the privacy policy
122+
systemProperty("jb.privacy.policy.text", "<!--999.999-->")
123+
// This only works on 2020.3+ FIX_WHEN_MIN_IS_203 remove this explanation
124+
systemProperty("ide.show.tips.on.startup.default.value", false)
125+
126+
systemProperty("aws.telemetry.skip_prompt", "true")
127+
systemProperty("aws.suppress_deprecation_prompt", true)
128+
129+
// These are experiments to enable for UI tests
130+
systemProperty("aws.feature.connectedLocalTerminal", true)
131+
ciOnly {
132+
systemProperty("aws.sharedCredentialsFile", "/tmp/.aws/credentials")
120133
}
121134

122-
tasks.withType<DownloadRobotServerPluginTask>() {
123-
version = remoteRobotVersion
135+
debugOptions {
136+
enabled.set(true)
137+
suspend.set(false)
124138
}
125139

126-
// Enable coverage for the UI test target IDE
127-
extensions.getByType<JacocoPluginExtension>().applyTo(tasks.withType<RunIdeForUiTestTask>())
128-
tasks.withType<RunIdeForUiTestTask>().all {
129-
systemProperty("robot-server.port", remoteRobotPort)
130-
systemProperty("ide.mac.file.chooser.native", "false")
131-
systemProperty("jb.consents.confirmation.enabled", "false")
132-
// This does some magic in EndUserAgreement.java to make it not show the privacy policy
133-
systemProperty("jb.privacy.policy.text", "<!--999.999-->")
134-
// This only works on 2020.3+ FIX_WHEN_MIN_IS_203 remove this explanation
135-
systemProperty("ide.show.tips.on.startup.default.value", false)
136-
137-
systemProperty("aws.telemetry.skip_prompt", "true")
138-
systemProperty("aws.suppress_deprecation_prompt", true)
139-
140-
// These are experiments to enable for UI tests
141-
systemProperty("aws.feature.connectedLocalTerminal", true)
142-
ciOnly() {
143-
systemProperty("aws.sharedCredentialsFile", "/tmp/.aws/credentials")
144-
}
145-
146-
debugOptions {
147-
enabled.set(true)
148-
suspend.set(false)
149-
}
150-
151-
configure<JacocoTaskExtension> {
152-
includes = listOf("software.aws.toolkits.*")
153-
output = Output.TCP_CLIENT // Dump to our jacoco server instead of to a file
154-
}
140+
configure<JacocoTaskExtension> {
141+
includes = listOf("software.aws.toolkits.*")
142+
output = Output.TCP_CLIENT // Dump to our jacoco server instead of to a file
155143
}
156144
}

buildSrc/src/main/kotlin/toolkit-kotlin-conventions.gradle.kts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@ plugins {
1212
}
1313

1414
dependencies {
15-
// By default only use compileOnly, since it comes bundled in the IDEs
16-
compileOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
17-
compileOnly("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
18-
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
19-
20-
testImplementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
21-
testImplementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
22-
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
15+
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
16+
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
17+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
18+
19+
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion")
2320
}
2421

2522
sourceSets {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jgitVersion=5.11.0.202103091610-r
2222

2323
gradleRetryPluginVersion=1.2.1
2424
gradleTestLoggerPlugin=3.0.0
25-
ideaPluginVersion=0.7.3
25+
ideaPluginVersion=1.1
2626

2727
# Note: Versions > 10 use process isolation which blows us out of memory in CI,
2828
# only upgrade if that is fixed or move to a different plugin

0 commit comments

Comments
 (0)