-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert project to Gradle+Kotlin #2
Changes from all commits
49acd17
88bdd7e
8969fac
e9ab643
bbd507e
963d4e6
371d2e2
62e7a42
3681f88
70d93b9
ec746fd
adfd8c8
37316ad
b99ff8a
2fd8779
afe9ea6
1694000
6f1573d
14933cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
plugins { | ||
application | ||
kotlin("jvm") | ||
} | ||
|
||
dependencies { | ||
compile(Libs.kotlin_stdlib_jdk8) | ||
testCompile(Libs.junit) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
|
||
plugins { | ||
id("jmfayard.github.io.gradle-kotlin-dsl-libs") version "0.2.3" | ||
`kotlin-dsl` | ||
} | ||
|
||
|
||
allprojects { | ||
|
||
group = "me.rozkmin.testing" | ||
version = "1.0-SNAPSHOT" | ||
|
||
repositories { | ||
mavenCentral() | ||
jcenter() | ||
} | ||
|
||
tasks.withType<KotlinCompile>().configureEach { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need |
||
kotlinOptions.jvmTarget = "1.8" | ||
} | ||
|
||
apply(plugin = "java") | ||
java { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather to use |
||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
repositories { | ||
jcenter() | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import kotlin.String | ||
|
||
/** | ||
* Generated by [gradle-kotlin-dsl-libs](https://github.com/jmfayard/gradle-kotlin-dsl-libs) | ||
* | ||
* Run again | ||
* `$ ./gradlew syncLibs` | ||
* to update this file */ | ||
object Libs { | ||
const val jmfayard_github_io_gradle_kotlin_dsl_libs_gradle_plugin: String = | ||
"jmfayard.github.io.gradle-kotlin-dsl-libs:jmfayard.github.io.gradle-kotlin-dsl-libs.gradle.plugin:" + Versions.jmfayard_github_io_gradle_kotlin_dsl_libs_gradle_plugin | ||
|
||
/** | ||
* [junit website](http://junit.org) */ | ||
const val junit: String = "junit:junit:" + Versions.junit | ||
|
||
/** | ||
* [junit-jupiter-api website](http://junit.org/junit5/) */ | ||
const val junit_jupiter_api: String = | ||
"org.junit.jupiter:junit-jupiter-api:" + Versions.junit_jupiter_api | ||
|
||
/** | ||
* [junit-jupiter-engine website](http://junit.org/junit5/) */ | ||
const val junit_jupiter_engine: String = | ||
"org.junit.jupiter:junit-jupiter-engine:" + Versions.junit_jupiter_engine | ||
|
||
/** | ||
* [junit-jupiter-params website](http://junit.org/junit5/) */ | ||
const val junit_jupiter_params: String = | ||
"org.junit.jupiter:junit-jupiter-params:" + Versions.junit_jupiter_params | ||
|
||
/** | ||
* [kotlin-gradle-plugin website](https://kotlinlang.org/) */ | ||
const val kotlin_gradle_plugin: String = | ||
"org.jetbrains.kotlin:kotlin-gradle-plugin:" + Versions.kotlin_gradle_plugin | ||
|
||
/** | ||
* [kotlin-reflect website](https://kotlinlang.org/) */ | ||
const val kotlin_reflect: String = | ||
"org.jetbrains.kotlin:kotlin-reflect:" + Versions.kotlin_reflect | ||
|
||
/** | ||
* [kotlin-sam-with-receiver website](https://kotlinlang.org/) */ | ||
const val kotlin_sam_with_receiver: String = | ||
"org.jetbrains.kotlin:kotlin-sam-with-receiver:" + Versions.kotlin_sam_with_receiver | ||
|
||
/** | ||
* [kotlin-scripting-compiler-embeddable website](https://kotlinlang.org/) */ | ||
const val kotlin_scripting_compiler_embeddable: String = | ||
"org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:" + Versions.kotlin_scripting_compiler_embeddable | ||
|
||
/** | ||
* [kotlin-stdlib-jdk8 website](https://kotlinlang.org/) */ | ||
const val kotlin_stdlib_jdk8: String = | ||
"org.jetbrains.kotlin:kotlin-stdlib-jdk8:" + Versions.kotlin_stdlib_jdk8 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not use string templates? |
||
|
||
/** | ||
* [kotlintest-runner-junit5 website](http://www.github.com/kotlintest/kotlintest) */ | ||
const val kotlintest_runner_junit5: String = | ||
"io.kotlintest:kotlintest-runner-junit5:" + Versions.kotlintest_runner_junit5 | ||
|
||
/** | ||
* [mockito-core website](https://github.com/mockito/mockito) */ | ||
const val mockito_core: String = "org.mockito:mockito-core:" + Versions.mockito_core | ||
|
||
/** | ||
* [mockito-kotlin website](https://github.com/nhaarman/mockito-kotlin) */ | ||
const val mockito_kotlin: String = | ||
"com.nhaarman.mockitokotlin2:mockito-kotlin:" + Versions.mockito_kotlin | ||
|
||
/** | ||
* [mockk website](http://mockk.io) */ | ||
const val mockk: String = "io.mockk:mockk:" + Versions.mockk | ||
|
||
const val org_gradle_kotlin_kotlin_dsl_gradle_plugin: String = | ||
"org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:" + Versions.org_gradle_kotlin_kotlin_dsl_gradle_plugin | ||
|
||
/** | ||
* [spek-dsl-jvm website](https://spekframework.github.io/spek) */ | ||
const val spek_dsl_jvm: String = "org.spekframework.spek2:spek-dsl-jvm:" + Versions.spek_dsl_jvm | ||
|
||
/** | ||
* [spek-runner-junit5 website](https://spekframework.github.io/spek) */ | ||
const val spek_runner_junit5: String = | ||
"org.spekframework.spek2:spek-runner-junit5:" + Versions.spek_runner_junit5 | ||
|
||
const val strikt_core: String = "io.strikt:strikt-core:" + Versions.strikt_core | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import kotlin.String | ||
|
||
/** | ||
* Generated by [gradle-kotlin-dsl-libs](https://github.com/jmfayard/gradle-kotlin-dsl-libs) | ||
* | ||
* Run again | ||
* `$ ./gradlew syncLibs` | ||
* to update this file */ | ||
object Versions { | ||
const val jmfayard_github_io_gradle_kotlin_dsl_libs_gradle_plugin: String = | ||
"0.2.3" // available: milestone=0.2.4 | ||
|
||
const val junit: String = "4.12" // up-to-date | ||
|
||
const val junit_jupiter_api: String = "5.3.1" // up-to-date | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you decide to violate Kotlin style guide and do not use camelCase for constants? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, I forgot to reply. I follow the Kotlin style guide by default but in this case, I decided to that it was more important to be closer to what the maven coordinate is. |
||
|
||
const val junit_jupiter_engine: String = "5.3.1" // up-to-date | ||
|
||
const val junit_jupiter_params: String = "5.3.1" // up-to-date | ||
|
||
const val kotlin_gradle_plugin: String = "1.2.61" // available: milestone=1.3.0-rc-190 | ||
|
||
const val kotlin_reflect: String = "1.2.71" // available: milestone=1.3.0-rc-190 | ||
|
||
const val kotlin_sam_with_receiver: String = "1.2.61" // available: milestone=1.3.0-rc-190 | ||
|
||
const val kotlin_scripting_compiler_embeddable: String = | ||
"1.2.61" // available: milestone=1.3.0-rc-190 | ||
|
||
const val kotlin_stdlib_jdk8: String = "1.2.71" // available: milestone=1.3.0-rc-190 | ||
|
||
const val kotlintest_runner_junit5: String = "3.1.7" // available: milestone=3.1.10 | ||
|
||
const val mockito_core: String = "2.23.0" // up-to-date | ||
|
||
const val mockito_kotlin: String = "2.0.0-RC1" // available: milestone=2.0.0-RC3 | ||
|
||
const val mockk: String = "1.8.9" // up-to-date | ||
|
||
const val org_gradle_kotlin_kotlin_dsl_gradle_plugin: String = | ||
"1.0-rc-5" // available: milestone=1.0-rc-13 | ||
|
||
const val spek_dsl_jvm: String = "2.0.0-alpha.1" // available: milestone=2.0.0-alpha.2 | ||
|
||
const val spek_runner_junit5: String = "2.0.0-alpha.1" // available: milestone=2.0.0-alpha.2 | ||
|
||
const val strikt_core: String = "0.16.0" // available: milestone=0.16.2 | ||
|
||
object Gradle { | ||
const val runningVersion: String = "4.10.2" | ||
|
||
const val currentVersion: String = "4.10.2" | ||
|
||
const val nightlyVersion: String = "5.1-20181022112637+0000" | ||
|
||
const val releaseCandidate: String = "" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
plugins { | ||
java | ||
kotlin("jvm") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":application")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also use approach when all our modules are items of enum, so access to modules became type safe, I probably share sample project that uses this approach |
||
compile(Libs.kotlin_stdlib_jdk8) | ||
testCompile(Libs.junit) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import org.gradle.api.tasks.testing.logging.TestLogEvent | ||
|
||
plugins { | ||
java | ||
kotlin("jvm") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":application")) | ||
testCompile(Libs.junit_jupiter_api) | ||
testCompile(Libs.junit_jupiter_params) | ||
testRuntime(Libs.junit_jupiter_engine) | ||
} | ||
|
||
// GROOVY: test { ... } | ||
tasks.withType<Test>().configureEach { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, you don't need configureEach |
||
useJUnitPlatform() | ||
testLogging { | ||
// GROOVY: | ||
// events "passed", "skipped", "failed" | ||
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
plugins { | ||
java | ||
kotlin("jvm") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":application")) | ||
testCompile(Libs.kotlintest_runner_junit5) | ||
} | ||
|
||
|
||
|
||
//test { | ||
// useJUnitPlatform() | ||
//} | ||
tasks.withType<Test>().configureEach { | ||
useJUnitPlatform() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
plugins { | ||
application | ||
kotlin("jvm") | ||
} | ||
|
||
dependencies { | ||
compile(Libs.kotlin_stdlib_jdk8) | ||
implementation(project(":application")) | ||
testCompile(Libs.mockito_core) | ||
testCompile(Libs.mockito_kotlin) | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
plugins { | ||
application | ||
kotlin("jvm") | ||
} | ||
|
||
dependencies { | ||
compile(Libs.kotlin_stdlib_jdk8) | ||
implementation(project(":application")) | ||
testCompile(Libs.junit) | ||
testCompile(Libs.mockito_core) | ||
testCompile(Libs.junit) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
plugins { | ||
application | ||
kotlin("jvm") | ||
} | ||
|
||
dependencies { | ||
compile(Libs.kotlin_stdlib_jdk8) | ||
implementation(project(":application")) | ||
testCompile(Libs.junit) | ||
testCompile(Libs.mockk) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
rootProject.name = "KotlinUnitTesting" | ||
include (":junit4",":junit5",":kotlintest",":spek",":application", ":mockito", ":mockito-kotlin", "mockk", "strikt") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
plugins { | ||
java | ||
kotlin("jvm") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":application")) | ||
testImplementation(Libs.spek_dsl_jvm) { | ||
exclude("org.jetbrains.kotlin") | ||
} | ||
testRuntimeOnly(Libs.spek_runner_junit5) { | ||
exclude("org.junit.platform") | ||
exclude("org.jetbrains.kotlin") | ||
} | ||
|
||
testCompile(Libs.junit_jupiter_api) | ||
|
||
|
||
// spek requires kotlin-reflect, can be omitted if already in the classpath | ||
testRuntimeOnly(Libs.kotlin_reflect) | ||
} | ||
|
||
repositories { | ||
maven { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can replace it with |
||
setUrl("https://dl.bintray.com/spekframework/spek-dev") | ||
} | ||
} | ||
|
||
|
||
tasks.withType<Test>().configureEach { | ||
this.useJUnitPlatform { | ||
includeEngines("spek2") | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import org.gradle.api.tasks.testing.logging.TestLogEvent.* | ||
|
||
plugins { | ||
application | ||
kotlin("jvm") | ||
} | ||
|
||
dependencies { | ||
compile(Libs.kotlin_stdlib_jdk8) | ||
implementation(project(":application")) | ||
|
||
testCompile(Libs.junit_jupiter_api) | ||
testCompile(Libs.junit_jupiter_params) | ||
testRuntime(Libs.junit_jupiter_engine) | ||
testImplementation(Libs.strikt_core) | ||
|
||
} | ||
|
||
tasks.withType<Test>().configureEach { | ||
useJUnitPlatform() | ||
testLogging { | ||
events = setOf(PASSED, SKIPPED, FAILED) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need both mavenCentral and jcenter? jcenter is superset of maven central