rybalkinsd / kohttp

Kotlin DSL http client
https://kohttp.gitbook.io
Apache License 2.0
478 stars 42 forks source link

Fixed test source directory typo #199

Closed GolovPavel closed 4 years ago

GolovPavel commented 4 years ago

It looks like a typo in build.gradle file. Please check it.

codecov[bot] commented 4 years ago

Codecov Report

Merging #199 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #199   +/-   ##
=========================================
  Coverage     91.28%   91.28%           
  Complexity      127      127           
=========================================
  Files            44       44           
  Lines           413      413           
  Branches         52       52           
=========================================
  Hits            377      377           
  Misses            9        9           
  Partials         27       27           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 031d8b3...9fb9754. Read the comment docs.

GolovPavel commented 4 years ago

I researched this topic.

First of all I tried to build snapshot with this PR remark and last released version of library. The content of these 2 jars was identical, because we collect into the jar only main source set:

val sourcesJar = task<Jar>("sourcesJar") {
    from(sourceSets["main"].allSource)
    archiveClassifier.set("sources")
}

Hence it wasn't affected publication process.

After that I wrote special gradle task to watch all available source sets, because I did not understand why in release build configuration there is no src/test/kotlin directory present, but IDEA and gradle sees this directory perfectly. I wrote the next gradle task:

tasks.register("sourceset-test") {
    doLast {
        sourceSets.forEach {
            println("""
                All source directories for the ${it.getName()} source set:
                ${it.getAllSource().getSrcDirs()}
            """.trimIndent())
        }
    }
}

And executed it for the last released version of code. As result, for example for sub project "kohttp", I received:

> Task :kohttp:sourceset-test
All source directories for the main source set:
[/home/pgolov/Repositories/kohttp/kohttp/src/main/resources, /home/pgolov/Repositories/kohttp/kohttp/src/main/java, /home/pgolov/Repositories/kohttp/kohttp/src/main/kotlin]
All source directories for the test source set:
[/home/pgolov/Repositories/kohttp/kohttp/src/test/resources, /home/pgolov/Repositories/kohttp/kohttp/src/test/java, /home/pgolov/Repositories/kohttp/kohttp/src/main/kotlin, /home/pgolov/Repositories/kohttp/kohttp/src/test/kotlin]

We can see, that there are redundant source set directory (topic of this PR) src/main/kotlin in 'test' source set and unexpectedly appeared src/test/kotlin directory, despite the fact that we did not specify it.

I suggested that kotlin gradle plugin by default contains src/(main|test)/kotlin directories in main and test source sets and it was confirmed in this documentation:

By default the production sources are located in src/main/kotlin and the test sources - in src/test/kotlin.

As result, I concluded that this block of code is redundant at all:

sourceSets {
    getByName("main").java.srcDirs("src/main/kotlin")
    getByName("test").java.srcDirs("src/test/kotlin")
}