forked from JetBrains/educational-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.gradle.kts
117 lines (104 loc) · 3.17 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
import java.net.URL
import java.nio.file.Files
import java.nio.file.StandardCopyOption
import java.util.*
rootProject.name = "educational-plugin"
include(
"educational-core",
"code-insight",
"code-insight:html",
"code-insight:markdown",
"code-insight:yaml",
"jvm-core",
"Edu-Java",
"Edu-Kotlin",
"Edu-Scala",
"Edu-Python",
"Edu-Python:Idea", // python support for IDEA and Android Studio
"Edu-Python:PyCharm", // python support for PyCharm and CLion
"Edu-Android",
"Edu-JavaScript",
"Edu-Rust",
"Edu-Cpp",
"Edu-Go",
"Edu-Php",
"Edu-Sql"
)
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()
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(
"educational-core/resources/stepik/stepik.properties",
"stepikClientId",
"stepikClientSecret",
"stepikNonProductionClientId",
"stepikNonProductionClientSecret"
)
secretProperties.extractAndStore(
"educational-core/resources/hyperskill/hyperskill-oauth.properties",
"hyperskillClientId",
"hyperskillClientSecret")
secretProperties.extractAndStore(
"educational-core/resources/twitter/oauth_twitter.properties",
"twitterConsumerKey",
"twitterConsumerSecret")
secretProperties.extractAndStore(
"Edu-Python/resources/checkio/py-checkio-oauth.properties",
"pyCheckioClientId",
"pyCheckioClientSecret")
secretProperties.extractAndStore(
"Edu-JavaScript/resources/checkio/js-checkio-oauth.properties",
"jsCheckioClientId",
"jsCheckioClientSecret")
secretProperties.extractAndStore(
"educational-core/resources/aes/aes.properties",
"aesKey")
secretProperties.extractAndStore(
"educational-core/resources/marketplace/marketplace-oauth.properties",
"eduHubClientId",
"eduHubClientSecret",
"marketplaceHubClientId")
}
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
}
}