-
Notifications
You must be signed in to change notification settings - Fork 51
/
settings.gradle.kts
174 lines (157 loc) · 5.33 KB
/
settings.gradle.kts
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
import java.io.IOException
import java.net.URL
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
import java.util.*
rootProject.name = "educational-plugin"
include(
"edu-format",
"intellij-plugin",
"intellij-plugin:educational-core",
"intellij-plugin:code-insight",
"intellij-plugin:code-insight:html",
"intellij-plugin:code-insight:markdown",
"intellij-plugin:code-insight:yaml",
"intellij-plugin:jvm-core",
"intellij-plugin:remote-env",
"intellij-plugin:AI",
"intellij-plugin:Edu-Java",
"intellij-plugin:Edu-Kotlin",
"intellij-plugin:Edu-Scala",
"intellij-plugin:Edu-Python",
"intellij-plugin:Edu-Python:Idea", // python support for IDEA and Android Studio
"intellij-plugin:Edu-Python:PyCharm", // python support for PyCharm and CLion
"intellij-plugin:Edu-Android",
"intellij-plugin:Edu-JavaScript",
"intellij-plugin:Edu-Rust",
"intellij-plugin:Edu-Cpp",
"intellij-plugin:Edu-Cpp:CLion-Classic", // specific support for CLion classic
"intellij-plugin:Edu-Cpp:CLion-Nova", // specific support for CLion Nova
"intellij-plugin:Edu-Go",
"intellij-plugin:Edu-Php",
"intellij-plugin:Edu-Shell",
"intellij-plugin:Edu-CSharp",
"intellij-plugin:sql",
"intellij-plugin:sql:sql-jvm",
"intellij-plugin:github",
"intellij-plugin:localization",
"intellij-plugin:features:command-line",
"intellij-plugin:features:ai-hints-core",
"intellij-plugin:features:ai-hints-kotlin"
)
if (settings.providers.gradleProperty("fleetIntegration").get().toBoolean()) {
include("fleet-plugin")
}
apply(from = "common.gradle.kts")
val secretProperties: String by extra
val inJetBrainsNetwork: () -> Boolean by extra
val isTeamCity: Boolean get() = System.getenv("TEAMCITY_VERSION") != null
configureSecretProperties()
downloadHyperskillCss()
fun configureSecretProperties() {
if (inJetBrainsNetwork() || isTeamCity) {
download(URL("https://repo.labs.intellij.net/edu-tools/secret.properties"), secretProperties)
}
else {
val secretProperties = file(secretProperties)
if (!secretProperties.exists()) {
secretProperties.createNewFile()
}
}
val secretProperties = loadProperties(secretProperties)
secretProperties.extractAndStore(
"intellij-plugin/educational-core/resources/stepik/stepik.properties",
"stepikClientId",
"cogniterraClientId",
)
secretProperties.extractAndStore(
"intellij-plugin/educational-core/resources/hyperskill/hyperskill-oauth.properties",
"hyperskillClientId",
)
secretProperties.extractAndStore(
"intellij-plugin/educational-core/resources/twitter/oauth_twitter.properties",
"twitterConsumerKey",
"twitterConsumerSecret"
)
secretProperties.extractAndStore(
"intellij-plugin/educational-core/resources/linkedin/linkedin-oauth.properties",
"linkedInClientId",
"linkedInClientSecret"
)
secretProperties.extractAndStore(
"edu-format/resources/aes/aes.properties",
"aesKey"
)
secretProperties.extractAndStore(
"intellij-plugin/educational-core/resources/marketplace/marketplace-oauth.properties",
"eduHubClientId",
"eduHubClientSecret",
"marketplaceHubClientId"
)
secretProperties.extractAndStore(
"intellij-plugin/educational-core/resources/lti/lti-auth.properties",
"ltiServiceToken"
)
}
fun downloadHyperskillCss() {
try {
download(URL("https://hyperskill.org/static/shared.css"), "intellij-plugin/educational-core/resources/style/hyperskill_task.css")
}
catch (e: IOException) {
System.err.println("Error downloading: ${e.message}. Using local copy")
Files.copy(
Paths.get("intellij-plugin/hyperskill_default.css"),
Paths.get("intellij-plugin/educational-core/resources/style/hyperskill_task.css"),
StandardCopyOption.REPLACE_EXISTING
)
}
}
fun download(url: URL, dstPath: String) {
println("Download $url")
url.openStream().use {
val path = file(dstPath).toPath().toAbsolutePath()
println("Copying file to $path")
Files.copy(it, path, StandardCopyOption.REPLACE_EXISTING)
}
}
fun loadProperties(path: String): Properties {
val properties = Properties()
file(path).bufferedReader().use { properties.load(it) }
return properties
}
fun Properties.extractAndStore(path: String, vararg keys: String) {
val properties = Properties()
for (key in keys) {
properties[key] = getProperty(key) ?: ""
}
val file = file(path)
file.parentFile?.mkdirs()
file.bufferedWriter().use { properties.store(it, "") }
}
buildCache {
local {
isEnabled = !isTeamCity
// By default, build cache is stored in gradle home directory
directory = File(rootDir, "build/build-cache")
removeUnusedEntriesAfterDays = 30
}
}
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
maven("https://oss.sonatype.org/content/repositories/snapshots/")
if (settings.providers.gradleProperty("fleetIntegration").get().toBoolean()) {
maven("https://cache-redirector.jetbrains.com/intellij-dependencies")
maven("https://packages.jetbrains.team/maven/p/teamcity-rest-client/teamcity-rest-client")
maven {
url = uri("https://packages.jetbrains.team/maven/p/fleet/fleet-sdk")
credentials {
username = settings.providers.gradleProperty("spaceUsername").orNull
password = settings.providers.gradleProperty("spacePassword").orNull
}
}
}
}
}