Skip to content

Commit 7ace0ab

Browse files
author
debop
committed
Setup kotlin-basic, kotlin-coroutines
1 parent 89e1368 commit 7ace0ab

File tree

17 files changed

+386
-42
lines changed

17 files changed

+386
-42
lines changed

.travis.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: java
2+
3+
jdk:
4+
- oraclejdk8
5+
6+
sudo: false
7+
8+
install: true
9+
10+
script: ./gradlew clean build

build.gradle.kts

+86-18
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,95 @@
1-
/*
2-
* This file was generated by the Gradle 'init' task.
3-
*
4-
* This generated file contains a sample Kotlin library project to get you started.
5-
*/
1+
import io.gitlab.arturbosch.detekt.detekt
2+
import org.jetbrains.dokka.gradle.DokkaTask
3+
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin
64

75
plugins {
8-
// Apply the Kotlin JVM plugin to add support for Kotlin on the JVM.
9-
id("org.jetbrains.kotlin.jvm").version("1.3.21")
6+
base
7+
kotlin("jvm") version "1.3.31" apply false
8+
id("io.gitlab.arturbosch.detekt") version "1.0.0-RC12" apply false
9+
id("org.jetbrains.dokka") version "0.9.17" apply false
1010
}
1111

12-
repositories {
13-
// Use jcenter for resolving your dependencies.
14-
// You can declare any Maven/Ivy/file repository here.
15-
jcenter()
12+
allprojects {
13+
14+
repositories {
15+
mavenCentral()
16+
jcenter()
17+
}
1618
}
1719

18-
dependencies {
19-
// Use the Kotlin JDK 8 standard library.
20-
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
20+
subprojects {
21+
22+
apply {
23+
plugin<JavaLibraryPlugin>()
24+
plugin<KotlinPlatformJvmPlugin>()
25+
plugin("io.gitlab.arturbosch.detekt")
26+
plugin("jacoco")
27+
28+
plugin("org.jetbrains.dokka")
29+
plugin("maven-publish")
30+
}
31+
32+
val sourceSets = project.the<SourceSetContainer>()
33+
34+
val sourcesJar by tasks.creating(Jar::class) {
35+
from(sourceSets["main"].allSource)
36+
archiveClassifier.set("sources")
37+
}
38+
39+
// Configure existing Dokka task to output HTML to typical Javadoc directory
40+
val dokka by tasks.getting(DokkaTask::class) {
41+
outputFormat = "html"
42+
outputDirectory = "$buildDir/javadoc"
43+
}
44+
45+
// Create dokka Jar task from dokka task output
46+
val dokkaJar by tasks.creating(Jar::class) {
47+
group = JavaBasePlugin.DOCUMENTATION_GROUP
48+
description = "Assembles Kotlin docs with Dokka"
49+
archiveClassifier.set("javadoc")
50+
// dependsOn(tasks.dokka) not needed; dependency automatically inferred by from(tasks.dokka)
51+
from(dokka)
52+
}
53+
54+
tasks.withType<Test> {
55+
useJUnitPlatform()
56+
57+
testLogging {
58+
events("FAILED")
59+
}
60+
61+
maxParallelForks = Runtime.getRuntime().availableProcessors()
62+
setForkEvery(1L)
63+
}
64+
65+
detekt {
66+
description = "Runs a failfast detekt build."
67+
68+
input = files("src/main/kotlin")
69+
config = files("../detekt.yml")
70+
filters = ".*/build/.*"
71+
72+
reports {
73+
xml.enabled = false
74+
html.enabled = true
75+
}
76+
}
77+
78+
// jacoco
79+
configure<JacocoPluginExtension> {
80+
}
2181

22-
// Use the Kotlin test library.
23-
testImplementation("org.jetbrains.kotlin:kotlin-test")
82+
tasks.withType<JacocoReport> {
83+
reports {
84+
html.isEnabled = true
85+
xml.isEnabled = true
86+
csv.isEnabled = false
87+
}
88+
}
2489

25-
// Use the Kotlin JUnit integration.
26-
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
90+
tasks["clean"].doLast {
91+
delete("./.project")
92+
delete("./out")
93+
delete("./bin")
94+
}
2795
}

detekt.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
complexity:
2+
LongMethod:
3+
threshold: 32
4+
5+
LongParameterList:
6+
threshold: 6
7+
ignoreDefaultParameters: true
8+
9+
TooManyFunctions:
10+
thresholdInFiles: 60
11+
thresholdInClasses: 20
12+

gradle.properties

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# Copyright (c) 2016. Sunghyouk Bae <[email protected]>
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
group = "io.github.debop"
17+
version = 0.0.1
18+
19+
org.gradle.daemon = true
20+
org.gradle.parallel = true
21+
org.gradle.caching = false
22+
23+
kotlin.incremental = true
24+
kotlin.parallel.tasks.in.project = true
25+
kapt.use.worker.api = true
26+
java.incremental = true
27+
28+
kotlin = 1.3.31
29+
coroutines = 1.2.1
30+
jodatime = 2.10.1
31+
rxjava2 = 2.2.8
32+
failsafe = 2.0.1
33+
34+
junitJupiter = 5.4.2

kotlin-basic/build.gradle.kts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
4+
kotlin {
5+
KotlinPlatformType.jvm
6+
}
7+
tasks.withType<KotlinCompile> {
8+
sourceCompatibility = "1.8"
9+
kotlinOptions.jvmTarget = "1.8"
10+
}
11+
12+
dependencies {
13+
14+
implementation(kotlin("stdlib"))
15+
16+
implementation("io.github.microutils:kotlin-logging:1.6.22")
17+
implementation("org.slf4j:slf4j-api:1.7.25")
18+
testImplementation("ch.qos.logback:logback-classic:1.2.3")
19+
20+
implementation("net.jodah:failsafe:${extra["failsafe"]}")
21+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${extra.get("coroutines")}")
22+
23+
val junitJupiterVersion = extra["junitJupiter"]
24+
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion")
25+
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitJupiterVersion")
26+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion")
27+
28+
testImplementation("org.amshove.kluent:kluent:1.45")
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package io.github.debop.kotlin.workshop
2+
3+
/**
4+
* Helloworld
5+
*
6+
* @author debop
7+
* @since 19. 5. 22
8+
*/
9+
fun main() {
10+
println("Hello world")
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package io.github.debop.kotlin.workshop
2+
3+
import mu.KLogging
4+
import org.junit.jupiter.api.AfterAll
5+
import org.junit.jupiter.api.AfterEach
6+
import org.junit.jupiter.api.BeforeAll
7+
import org.junit.jupiter.api.BeforeEach
8+
import org.junit.jupiter.api.Test
9+
import org.junit.jupiter.api.TestInstance
10+
import org.junit.jupiter.api.TestInstance.Lifecycle
11+
12+
/**
13+
* HelloworldTest
14+
*
15+
* @author debop
16+
* @since 19. 5. 22
17+
*/
18+
@TestInstance(Lifecycle.PER_CLASS) // see resources/junit-platform.properties
19+
class HelloworldTest {
20+
21+
companion object : KLogging()
22+
23+
@BeforeAll
24+
fun beforeAll() {
25+
logger.debug { "BeforeAll - Call before running all test methods" }
26+
}
27+
28+
@BeforeEach
29+
fun beforeEach() {
30+
logger.debug { "BeforeEach - Call before running each test method" }
31+
}
32+
33+
@AfterEach
34+
fun afterEach() {
35+
logger.debug { "AfterEach - Call before running each test method" }
36+
}
37+
38+
@AfterAll
39+
fun afterAll() {
40+
logger.debug { "AfterAll - Call before running all test methods" }
41+
}
42+
43+
@Test
44+
fun `my first test using junit5`() {
45+
logger.debug { "My first time test method using JUnit5" }
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Copyright (c) 2016. Sunghyouk Bae <[email protected]>
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
junit.jupiter.testinstance.lifecycle.default = per_class
17+
18+
junit.jupiter.execution.parallel.enabled = true
19+
junit.jupiter.execution.parallel.config.strategy = dynamic
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright (c) 2016. Sunghyouk Bae <[email protected]>
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<configuration>
18+
<!-- help : http://logback.qos.ch/manual/appenders.html -->
19+
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
20+
<withJansi>true</withJansi>
21+
<immediateFlush>true</immediateFlush>
22+
<encoder>
23+
<pattern>%d{ISO8601} %highlight(%-5level) [%blue(%t)] %yellow(%logger): %msg%n%throwable</pattern>
24+
<charset>UTF-8</charset>
25+
</encoder>
26+
</appender>
27+
28+
<logger name="io.github.debop.kotlin.workshop" level="TRACE"/>
29+
30+
<root level="INFO">
31+
<appender-ref ref="console"/>
32+
</root>
33+
34+
</configuration>

kotlin-coroutines/build.gradle.kts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
4+
kotlin {
5+
KotlinPlatformType.jvm
6+
}
7+
tasks.withType<KotlinCompile> {
8+
sourceCompatibility = "1.8"
9+
kotlinOptions.jvmTarget = "1.8"
10+
}
11+
12+
sourceSets {
13+
getByName("main").java.srcDirs("src/main/kotlin")
14+
getByName("test").java.srcDirs("src/main/kotlin")
15+
}
16+
17+
dependencies {
18+
19+
implementation(kotlin("stdlib"))
20+
21+
implementation("io.github.microutils:kotlin-logging:1.6.22")
22+
implementation("org.slf4j:slf4j-api:1.7.25")
23+
testImplementation("ch.qos.logback:logback-classic:1.2.3")
24+
25+
implementation("net.jodah:failsafe:${extra["failsafe"]}")
26+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${extra.get("coroutines")}")
27+
28+
val junitJupiterVersion = extra["junitJupiter"]
29+
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion")
30+
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitJupiterVersion")
31+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion")
32+
33+
testImplementation("org.amshove.kluent:kluent:1.45")
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* package-info
3+
*
4+
* @author debop
5+
* @since 19. 5. 22
6+
*/
7+
package io.github.debop.kotlin.workshop;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* package-info
3+
*
4+
* @author debop
5+
* @since 19. 5. 22
6+
*/
7+
package io.github.debop.kotlin.workshop;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Copyright (c) 2016. Sunghyouk Bae <[email protected]>
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
junit.jupiter.testinstance.lifecycle.default = per_class
17+
18+
junit.jupiter.execution.parallel.enabled = true
19+
junit.jupiter.execution.parallel.config.strategy = dynamic

0 commit comments

Comments
 (0)