-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
152 lines (128 loc) · 4.37 KB
/
build.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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.jetbrains.intellij") version "1.17.4"
java
kotlin("jvm") version "1.8.20" apply true
application
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
}
intellij {
version.set("2022.1.1")
plugins.set(listOf("java", "Kotlin"))
type.set("IC")
}
buildscript {
extra["kotlin_version"] = "1.8.20"
repositories {
mavenCentral()
}
dependencies {
classpath(kotlin("gradle-plugin", version = "1.8.20"))
}
}
fun printOutput(output: Any): Task {
return tasks.create("printOutput") {
println("#educational_plugin_check(er_version 1")
val lines = output.toString().split("(?<=\n)|(?=\n)")
for (line in lines) {
println("#educational_plugin$line")
}
}
}
allprojects {
apply {
plugin("application")
plugin("java")
plugin("kotlin")
}
repositories {
mavenCentral()
mavenLocal()
maven {
url = uri("https://packages.jetbrains.team/maven/p/kotlin-test-framework/kotlin-test-framework")
}
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.20")
testImplementation("junit:junit:4.13.1")
val junitJupiterVersion = "5.9.0"
implementation("org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion")
runtimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion")
implementation("org.junit.jupiter:junit-jupiter-params:$junitJupiterVersion")
runtimeOnly("org.junit.platform:junit-platform-console:1.9.0")
implementation("org.ini4j:ini4j:0.5.4")
}
tasks {
withType<JavaCompile> {
sourceCompatibility = "11"
targetCompatibility = "11"
}
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
withType<Test> {
useJUnitPlatform()
outputs.upToDateWhen { false }
addTestListener(object : TestListener {
override fun beforeSuite(suite: TestDescriptor) {}
override fun beforeTest(testDescriptor: TestDescriptor) {}
override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) {
if (result.resultType == TestResult.ResultType.FAILURE) {
val message = result.exception?.message ?: "Wrong answer"
val lines = message.split("\n")
println("#educational_plugin FAILED + ${lines[0]}")
lines.subList(1, lines.size).forEach { line ->
println("#educational_plugin$line")
}
// we need this to separate output of different tests
println()
}
}
override fun afterSuite(suite: TestDescriptor, result: TestResult) {}
})
}
}
sourceSets {
getByName("main").java.srcDirs("src")
getByName("main").kotlin.srcDirs("src")
getByName("test").java.srcDirs("test")
getByName("test").kotlin.srcDirs("test")
}
}
tasks {
wrapper {
gradleVersion = project.findProperty("gradleVersion").toString()
}
}
project(":util") {
dependencies {
implementation("junit:junit:4.13")
}
}
configure(subprojects.filter { it.name != "util" }) {
dependencies {
implementation(project(":util"))
}
}
configure(subprojects.filter { it.name.endsWith("Practice") || it.name.endsWith("task") }) {
plugins.apply("org.jetbrains.intellij")
intellij {
version.set("2022.1.1")
plugins.set(listOf("java", "Kotlin"))
type.set("IC")
}
dependencies {
val testSystemVersion = "2.1.1"
testImplementation("org.jetbrains.academy.test.system:core:$testSystemVersion")
testImplementation("org.jetbrains.academy.test.system:kotlin-psi:$testSystemVersion")
testImplementation("org.jetbrains.academy.test.system:common:$testSystemVersion")
}
}
configure(subprojects.filter { it.name == "CodeStyleAndFormatting-CodeSchemasAndEditorConfig-ReformatTheCodeAccordingToStyleSettingsPractice" }) {
apply {
plugin("org.jlleitschuh.gradle.ktlint")
}
tasks.withType<KotlinCompile> {
dependsOn("ktlintCheck")
}
}