Skip to content

Commit

Permalink
Fix regression separating classpath entries - #2961 (#2977)
Browse files Browse the repository at this point in the history
* Fix regression separating classpath entries - #2961

* Use File.pathSeparaterChar to join classpath

* Swap separator chars in comment
  • Loading branch information
arturbosch committed Aug 18, 2020
1 parent 2a2e82e commit b0bd7b9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal class EnvironmentFacade(
}

internal fun CompilerSpec.classpathEntries(): List<String> =
classpath?.split(":;") ?: emptyList() // support both windows : and unix ;
classpath?.split(":", ";") ?: emptyList() // support both windows ; and unix :

internal fun CompilerSpec.parseLanguageVersion(): LanguageVersion? {
fun parse(value: String): LanguageVersion {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.gitlab.arturbosch.detekt.core.settings

import io.gitlab.arturbosch.detekt.core.createNullLoggingSpec
import io.gitlab.arturbosch.detekt.core.createProcessingSettings
import org.assertj.core.api.Assertions.assertThat
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe

internal class EnvironmentFacadeSpec : Spek({

describe("classpath entries can be separated by : or ;") {

arrayOf(
"supports ;" to "file1;file2;file3",
"supports :" to "file1:file2:file3",
"supports mixing ; and :" to "file1;file2:file3"
).forEach { (testName, classpath) ->
it(testName) {
testSettings(classpath).use {
assertThat(it.classpath).hasSize(3)
}
}
}
}
})

private fun testSettings(classpath: String) = createProcessingSettings(
spec = createNullLoggingSpec {
compiler {
this.classpath = classpath
}
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.gitlab.arturbosch.detekt.invoke
import io.gitlab.arturbosch.detekt.extensions.DetektReportType
import org.gradle.api.file.FileCollection
import org.gradle.api.file.RegularFile
import java.io.File

private const val DEBUG_PARAMETER = "--debug"
private const val INPUT_PARAMETER = "--input"
Expand Down Expand Up @@ -39,7 +40,7 @@ internal data class InputArgument(val fileCollection: FileCollection) : CliArgum
internal data class ClasspathArgument(val fileCollection: FileCollection) : CliArgument() {
override fun toArgument() = if (!fileCollection.isEmpty) listOf(
CLASSPATH_PARAMETER,
fileCollection.joinToString(";") { it.absolutePath }) else emptyList()
fileCollection.joinToString(File.pathSeparator) { it.absolutePath }) else emptyList()
}

internal data class LanguageVersionArgument(val languageVersion: String?) : CliArgument() {
Expand Down

0 comments on commit b0bd7b9

Please sign in to comment.