diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5e84f3f --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.gradle/ +.idea/ +kotlin/sample/build/ +kotlin/library/build/ +kotlin/build/ diff --git a/kotlin/build.gradle b/kotlin/build.gradle index d614bc2..23f1b7d 100644 --- a/kotlin/build.gradle +++ b/kotlin/build.gradle @@ -2,7 +2,7 @@ buildscript { ext { - kotlin_version = '1.1.51' + kotlin_version = '1.2.31' } repositories { mavenCentral() @@ -10,7 +10,6 @@ buildscript { } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.junit.platform:junit-platform-gradle-plugin:1.0.1" } } @@ -18,35 +17,12 @@ apply plugin: "idea" apply plugin: "java" apply plugin: "kotlin" apply plugin: "application" -apply plugin: "org.junit.platform.gradle.plugin" -sourceSets { - main.java.srcDirs += 'src/' -} - -junitPlatform { - filters { - engines { - include 'spek' - } +allprojects { + repositories { + mavenCentral() + jcenter() } } -mainClassName = "LogEvent" - -repositories { - mavenCentral() - jcenter() - maven { url "http://dl.bintray.com/jetbrains/spek" } -} - -dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" - compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - compile 'com.github.kittinunf.fuel:fuel:1.11.0' - - testCompile 'org.jetbrains.kotlin:kotlin-test' - testCompile 'org.jetbrains.spek:spek-api:1.1.5' - testCompile 'org.junit.platform:junit-platform-runner:1.0.1' - testRuntime 'org.jetbrains.spek:spek-junit-platform-engine:1.1.5' -} +mainClassName = "vacuumanalytics.LogEventKt" diff --git a/kotlin/library/build.gradle b/kotlin/library/build.gradle new file mode 100644 index 0000000..65f0788 --- /dev/null +++ b/kotlin/library/build.gradle @@ -0,0 +1,57 @@ +// Copyright 2018 Sourcerer Inc. All Rights Reserved. + +buildscript { + ext { + kotlin_version = '1.1.51' + } + repositories { + mavenCentral() + jcenter() + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +apply plugin: "idea" +apply plugin: "java" +apply plugin: "kotlin" +apply plugin: "application" + +mainClassName = "vacuumanalytics.LogEventKt" + +repositories { + mavenCentral() + jcenter() +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" + compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + compile 'com.github.kittinunf.fuel:fuel:1.11.0' +} + +repositories { + mavenCentral() + jcenter() + flatDir { + dirs 'libs' + } +} + +// Include dependent libraries in archive. +jar { + manifest { + attributes "Main-Class": "$mainClassName" + } + from { + configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } + } { + exclude "META-INF/*.SF" + exclude "META-INF/*.DSA" + exclude "META-INF/*.RSA" + } + + baseName 'library' +} diff --git a/kotlin/src/LogEvent.kt b/kotlin/library/src/main/kotlin/LogEvent.kt similarity index 98% rename from kotlin/src/LogEvent.kt rename to kotlin/library/src/main/kotlin/LogEvent.kt index c83ae89..8344855 100644 --- a/kotlin/src/LogEvent.kt +++ b/kotlin/library/src/main/kotlin/LogEvent.kt @@ -1,7 +1,7 @@ // Copyright 2018 Sourcerer Inc. All Rights Reserved. // Author: Alexander Surkov (alex@sourcerer.io) -package sourcererio.vacuumanalytics +package vacuumanalytics import com.github.kittinunf.fuel.core.FuelError import com.github.kittinunf.fuel.core.FuelManager diff --git a/kotlin/sample/build.gradle b/kotlin/sample/build.gradle new file mode 100644 index 0000000..79b323f --- /dev/null +++ b/kotlin/sample/build.gradle @@ -0,0 +1,52 @@ +// Copyright 2018 Sourcerer Inc. All Rights Reserved. + +buildscript { + ext { + kotlin_version = '1.1.51' + } + repositories { + mavenCentral() + jcenter() + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +apply plugin: "idea" +apply plugin: "java" +apply plugin: "kotlin" +apply plugin: "application" + +sourceSets { + main.java.srcDirs += 'src/main/' +} + +repositories { + mavenCentral() + jcenter() +} + +dependencies { + compile project(':library') + compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" + /*compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"*/ +} + +mainClassName = "sample.MainKt" + +jar { + manifest { + attributes "Main-Class": "$mainClassName" + } + + from { + configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } + } { + exclude "META-INF/*.SF" + exclude "META-INF/*.DSA" + exclude "META-INF/*.RSA" + } + + baseName 'sample' +} diff --git a/kotlin/sample/src/main/kotlin/Main.kt b/kotlin/sample/src/main/kotlin/Main.kt new file mode 100644 index 0000000..8e69675 --- /dev/null +++ b/kotlin/sample/src/main/kotlin/Main.kt @@ -0,0 +1,17 @@ +// Copyright 2018 Sourcerer Inc. All Rights Reserved. +// Author: Alexander Surkov (alex@sourcerer.io) + +package sample + +import com.github.kittinunf.fuel.core.Response +import java.net.URL +import vacuumanalytics.LogEvent + +fun main(argv : Array) { + val fakeResponse = Response( + url = URL("http://0.0.0.0"), + headers = mapOf("Set-Cookie" to listOf("sessionid=kotlintst")) + ) + val logger = LogEvent("http://0.0.0.0:8080", fakeResponse, "sessionid") + logger.error("B'eba-%pBeba") +} diff --git a/kotlin/settings.gradle b/kotlin/settings.gradle new file mode 100644 index 0000000..a882e41 --- /dev/null +++ b/kotlin/settings.gradle @@ -0,0 +1 @@ +include 'library', 'sample'