forked from svtk/AtomicKotlinCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
130 lines (123 loc) · 3.62 KB
/
build.gradle
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
buildscript {
ext.kotlin_version = '1.5.20'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
def printOutput(def output) {
return tasks.create("printOutput") {
println "#educational_plugin_checker_version 1"
def lines = output.toString().split("(?<=\n)|(?=\n)")
for (line in lines) {
println "#educational_plugin" + line
}
}
}
allprojects {
apply plugin: 'java'
apply plugin: 'kotlin'
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect"
// kotlin.test
implementation "org.jetbrains.kotlin:kotlin-test"
implementation "org.jetbrains.kotlin:kotlin-test-junit"
implementation "junit:junit:4.12"
// Logging support for samples:
implementation 'io.github.microutils:kotlin-logging:2.0.10'
implementation 'org.slf4j:slf4j-simple:1.7.32'
}
compileKotlin.destinationDir = compileJava.destinationDir
compileKotlin {
kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
}
}
}
apply plugin: 'application'
sourceCompatibility = 8
dependencies {
testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
implementation project(':util').sourceSets.main.output
testImplementation project(':util').sourceSets.test.output
}
def srcList = []
def testList = []
rootProject.projectDir.eachDirRecurse {
if (!isTaskDir(it) || it.path.contains(".idea") || "util".equals(it.path)) {
return
}
def srcDir = new File(it, "src")
if (it.path.contains("Unit Testing")) {
testList.add(srcDir)
} else {
srcList.add(srcDir)
}
def testDir = new File(it, "test")
testList.add(testDir)
}
sourceSets {
main {
java {
srcDirs = srcList
}
kotlin {
srcDirs = srcList
}
}
test {
java {
srcDirs = testList
}
kotlin {
srcDirs = testList
}
}
}
static def isTaskDir(File dir) {
return new File(dir, "src").exists()
}
mainClassName = project.hasProperty("mainClass") ? project.getProperty("mainClass") : ""
test {
outputs.upToDateWhen { false }
afterTest { TestDescriptor test, TestResult result ->
if (result.resultType == TestResult.ResultType.FAILURE) {
def message = result.exception?.message ?: "Wrong answer"
def lines = message.readLines()
println "#educational_plugin FAILED + " + lines[0]
if (lines.size() > 1) {
lines[1..-1].forEach { line ->
println "#educational_plugin" + line
}
}
// we need this to separate output of different tests
println ""
}
}
}
def runOutput = new ByteArrayOutputStream()
tasks.run.setStandardOutput(runOutput)
tasks.run.doLast { printOutput(runOutput) }
project(':util') {
dependencies {
implementation group: 'junit', name: 'junit', version: '4.12'
}
}
if (new File('gradle/tests.gradle').exists()) {
apply from: 'gradle/tests.gradle'
}