Skip to content

Commit c0ce20f

Browse files
authored
Fix settings that compile but don't actually do anything (#3207)
1 parent d2dcd99 commit c0ce20f

File tree

3 files changed

+45
-32
lines changed

3 files changed

+45
-32
lines changed

build.gradle.kts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
43
import org.jetbrains.gradle.ext.ProjectSettings
54
import org.jetbrains.gradle.ext.TaskTriggersConfig
65
import software.aws.toolkits.gradle.changelog.tasks.GenerateGithubChangeLog
@@ -14,8 +13,17 @@ plugins {
1413

1514
allprojects {
1615
repositories {
17-
val codeArtifactMavenRepo: ((RepositoryHandler) -> Unit)? by extra
18-
codeArtifactMavenRepo?.invoke(this)
16+
val codeArtifactUrl: Provider<String> = providers.environmentVariable("CODEARTIFACT_URL")
17+
val codeArtifactToken: Provider<String> = providers.environmentVariable("CODEARTIFACT_AUTH_TOKEN")
18+
if (codeArtifactUrl.isPresent && codeArtifactToken.isPresent) {
19+
maven {
20+
url = uri(codeArtifactUrl.get())
21+
credentials {
22+
username = "aws"
23+
password = codeArtifactToken.get()
24+
}
25+
}
26+
}
1927
mavenCentral()
2028
gradlePluginPortal()
2129
}

buildSrc/settings.gradle.kts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
pluginManagement {
4-
repositories {
5-
val codeArtifactMavenRepo: ((RepositoryHandler) -> Unit)? by extra
6-
codeArtifactMavenRepo?.invoke(this)
7-
gradlePluginPortal()
3+
val codeArtifactMavenRepo = fun RepositoryHandler.(): MavenArtifactRepository? {
4+
val codeArtifactUrl: Provider<String> = providers.environmentVariable("CODEARTIFACT_URL")
5+
val codeArtifactToken: Provider<String> = providers.environmentVariable("CODEARTIFACT_AUTH_TOKEN")
6+
return if (codeArtifactUrl.isPresent && codeArtifactToken.isPresent) {
7+
maven {
8+
url = uri(codeArtifactUrl.get())
9+
credentials {
10+
username = "aws"
11+
password = codeArtifactToken.get()
12+
}
13+
}
14+
} else {
15+
null
16+
}
17+
}.also {
18+
pluginManagement {
19+
repositories {
20+
it()
21+
gradlePluginPortal()
22+
}
823
}
924
}
1025

@@ -16,8 +31,7 @@ dependencyResolutionManagement {
1631
}
1732

1833
repositories {
19-
val codeArtifactMavenRepo: ((RepositoryHandler) -> Unit)? by extra
20-
codeArtifactMavenRepo?.invoke(this)
34+
codeArtifactMavenRepo()
2135
mavenCentral()
2236
gradlePluginPortal()
2337
maven {

settings.gradle.kts

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,23 @@
11
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
val codeArtifactMavenRepo = fun RepositoryHandler.(): MavenArtifactRepository? {
4-
val codeArtifactUrl: Provider<String> = providers.environmentVariable("CODEARTIFACT_URL")
5-
val codeArtifactToken: Provider<String> = providers.environmentVariable("CODEARTIFACT_AUTH_TOKEN")
6-
return if (codeArtifactUrl.isPresent && codeArtifactToken.isPresent) {
7-
println("Using CodeArtifact proxy: ${codeArtifactUrl.get()}")
8-
maven {
9-
url = uri(codeArtifactUrl.get())
10-
credentials {
11-
username = "aws"
12-
password = codeArtifactToken.get()
3+
pluginManagement {
4+
repositories {
5+
val codeArtifactUrl: Provider<String> = providers.environmentVariable("CODEARTIFACT_URL")
6+
val codeArtifactToken: Provider<String> = providers.environmentVariable("CODEARTIFACT_AUTH_TOKEN")
7+
if (codeArtifactUrl.isPresent && codeArtifactToken.isPresent) {
8+
println("Using CodeArtifact proxy: ${codeArtifactUrl.get()}")
9+
maven {
10+
url = uri(codeArtifactUrl.get())
11+
credentials {
12+
username = "aws"
13+
password = codeArtifactToken.get()
14+
}
1315
}
1416
}
15-
} else {
16-
null
17-
}
18-
}.also {
19-
pluginManagement {
20-
repositories {
21-
// janky because we need to apply to plugins in this file, but val falls out of scope
22-
it()
23-
gradlePluginPortal()
24-
}
17+
gradlePluginPortal()
2518
}
2619
}
2720

28-
extra["codeArtifactMavenRepo"] = codeArtifactMavenRepo
29-
3021
rootProject.name = "aws-toolkit-jetbrains"
3122

3223
include("resources")

0 commit comments

Comments
 (0)