From b0759d142b9288ad81b9d72be1c2d922ee63ee19 Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Tue, 27 Mar 2018 23:38:38 -0400 Subject: [PATCH 1/4] initial --- .gitignore | 1 + kotlin/build.gradle | 39 ++++--------------------- kotlin/{src => library}/LogEvent.kt | 2 +- kotlin/library/build.gradle | 45 +++++++++++++++++++++++++++++ kotlin/sample/build.gradle | 45 +++++++++++++++++++++++++++++ kotlin/sample/src/main/Main.kt | 10 +++++++ kotlin/settings.gradle | 1 + 7 files changed, 109 insertions(+), 34 deletions(-) create mode 100644 .gitignore rename kotlin/{src => library}/LogEvent.kt (98%) create mode 100644 kotlin/library/build.gradle create mode 100644 kotlin/sample/build.gradle create mode 100644 kotlin/sample/src/main/Main.kt create mode 100644 kotlin/settings.gradle diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3bb19ff --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.gradle/ diff --git a/kotlin/build.gradle b/kotlin/build.gradle index d614bc2..e8fc560 100644 --- a/kotlin/build.gradle +++ b/kotlin/build.gradle @@ -10,43 +10,16 @@ buildscript { } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.junit.platform:junit-platform-gradle-plugin:1.0.1" } } -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' +task clean(type: Delete) { + delete rootProject.buildDir } diff --git a/kotlin/src/LogEvent.kt b/kotlin/library/LogEvent.kt similarity index 98% rename from kotlin/src/LogEvent.kt rename to kotlin/library/LogEvent.kt index c83ae89..8344855 100644 --- a/kotlin/src/LogEvent.kt +++ b/kotlin/library/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/library/build.gradle b/kotlin/library/build.gradle new file mode 100644 index 0000000..6811551 --- /dev/null +++ b/kotlin/library/build.gradle @@ -0,0 +1,45 @@ +// 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 += '' +}*/ + +mainClassName = "LogEvent" + +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' +} + +jar { + manifest { + attributes "Main-Class": "vacuumanalytics.$mainClassName" + } + + baseName 'vacuum-analytics' +} diff --git a/kotlin/sample/build.gradle b/kotlin/sample/build.gradle new file mode 100644 index 0000000..2595192 --- /dev/null +++ b/kotlin/sample/build.gradle @@ -0,0 +1,45 @@ +// 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: "java" +apply plugin: "kotlin" +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"*/ +} + +compileKotlin { + kotlinOptions.jvmTarget = "1.8" +} + +jar { + manifest { + attributes "Main-Class": "sample.MainKt" + } + + from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } + + baseName 'sample' +} diff --git a/kotlin/sample/src/main/Main.kt b/kotlin/sample/src/main/Main.kt new file mode 100644 index 0000000..7bcbf89 --- /dev/null +++ b/kotlin/sample/src/main/Main.kt @@ -0,0 +1,10 @@ +// Copyright 2018 Sourcerer Inc. All Rights Reserved. +// Author: Alexander Surkov (alex@sourcerer.io) + +package sample + +import vacuumanalytics.LogEvent + +fun main(argv : Array) { + println("HEYHEYEYEHHE") +} diff --git a/kotlin/settings.gradle b/kotlin/settings.gradle new file mode 100644 index 0000000..77c36d0 --- /dev/null +++ b/kotlin/settings.gradle @@ -0,0 +1 @@ +include ':library', ':sample' From ff86fd2027fd3782ce55997c395c1352f6fdb614 Mon Sep 17 00:00:00 2001 From: Anatoly Kislov Date: Thu, 5 Apr 2018 15:35:11 +0300 Subject: [PATCH 2/4] fix: gradle multi-project fix --- .gitignore | 4 +++ kotlin/build.gradle | 9 ++++--- kotlin/library/build.gradle | 26 ++++++++++++++----- .../library/{ => src/main/kotlin}/LogEvent.kt | 0 kotlin/sample/build.gradle | 17 ++++++++---- kotlin/sample/src/main/{ => kotlin}/Main.kt | 0 kotlin/settings.gradle | 2 +- 7 files changed, 42 insertions(+), 16 deletions(-) rename kotlin/library/{ => src/main/kotlin}/LogEvent.kt (100%) rename kotlin/sample/src/main/{ => kotlin}/Main.kt (100%) diff --git a/.gitignore b/.gitignore index 3bb19ff..5e84f3f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ .gradle/ +.idea/ +kotlin/sample/build/ +kotlin/library/build/ +kotlin/build/ diff --git a/kotlin/build.gradle b/kotlin/build.gradle index e8fc560..9ffad71 100644 --- a/kotlin/build.gradle +++ b/kotlin/build.gradle @@ -13,6 +13,11 @@ buildscript { } } +apply plugin: "idea" +apply plugin: "java" +apply plugin: "kotlin" +apply plugin: "application" + allprojects { repositories { mavenCentral() @@ -20,6 +25,4 @@ allprojects { } } -task clean(type: Delete) { - delete rootProject.buildDir -} +mainClassName = "vacuumanalytics.LogEventKt" diff --git a/kotlin/library/build.gradle b/kotlin/library/build.gradle index 6811551..65f0788 100644 --- a/kotlin/library/build.gradle +++ b/kotlin/library/build.gradle @@ -17,12 +17,8 @@ apply plugin: "idea" apply plugin: "java" apply plugin: "kotlin" apply plugin: "application" -/* -sourceSets { - main.java.srcDirs += '' -}*/ -mainClassName = "LogEvent" +mainClassName = "vacuumanalytics.LogEventKt" repositories { mavenCentral() @@ -36,10 +32,26 @@ dependencies { 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": "vacuumanalytics.$mainClassName" + 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 'vacuum-analytics' + baseName 'library' } diff --git a/kotlin/library/LogEvent.kt b/kotlin/library/src/main/kotlin/LogEvent.kt similarity index 100% rename from kotlin/library/LogEvent.kt rename to kotlin/library/src/main/kotlin/LogEvent.kt diff --git a/kotlin/sample/build.gradle b/kotlin/sample/build.gradle index 2595192..79b323f 100644 --- a/kotlin/sample/build.gradle +++ b/kotlin/sample/build.gradle @@ -13,8 +13,11 @@ buildscript { } } +apply plugin: "idea" apply plugin: "java" apply plugin: "kotlin" +apply plugin: "application" + sourceSets { main.java.srcDirs += 'src/main/' } @@ -30,16 +33,20 @@ dependencies { /*compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"*/ } -compileKotlin { - kotlinOptions.jvmTarget = "1.8" -} +mainClassName = "sample.MainKt" jar { manifest { - attributes "Main-Class": "sample.MainKt" + attributes "Main-Class": "$mainClassName" } - from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } + 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/Main.kt b/kotlin/sample/src/main/kotlin/Main.kt similarity index 100% rename from kotlin/sample/src/main/Main.kt rename to kotlin/sample/src/main/kotlin/Main.kt diff --git a/kotlin/settings.gradle b/kotlin/settings.gradle index 77c36d0..a882e41 100644 --- a/kotlin/settings.gradle +++ b/kotlin/settings.gradle @@ -1 +1 @@ -include ':library', ':sample' +include 'library', 'sample' From aa5c5a16a4cb7e89ebab61c4f0af83683342f6ed Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Tue, 10 Apr 2018 20:05:01 -0400 Subject: [PATCH 3/4] bump kotlin version --- kotlin/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin/build.gradle b/kotlin/build.gradle index 9ffad71..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() From 0e0d3226c6a7679edc7b172120c054f87802420f Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Tue, 10 Apr 2018 22:33:24 -0400 Subject: [PATCH 4/4] add test itself --- kotlin/sample/src/main/kotlin/Main.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kotlin/sample/src/main/kotlin/Main.kt b/kotlin/sample/src/main/kotlin/Main.kt index 7bcbf89..8e69675 100644 --- a/kotlin/sample/src/main/kotlin/Main.kt +++ b/kotlin/sample/src/main/kotlin/Main.kt @@ -3,8 +3,15 @@ package sample +import com.github.kittinunf.fuel.core.Response +import java.net.URL import vacuumanalytics.LogEvent fun main(argv : Array) { - println("HEYHEYEYEHHE") + 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") }