Skip to content

Commit

Permalink
Merge pull request #36 from SimonMarquis/fix/34
Browse files Browse the repository at this point in the history
Support Windows file path separator
  • Loading branch information
rharter authored Jun 8, 2023
2 parents f291564 + 31c3ef5 commit 20bb027
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ public abstract class CreateFocusSettingsTask : DefaultTask() {
writer.appendLine()

// Add overrides for projects with a root that's different from the gradle path
val literalQuoteChar = "'"
dependencies
.forEach { dep ->
val gradleProjectPath = dep.path.substring(1).replace(":", "/")
if (project.rootDir.resolve(gradleProjectPath) != dep.projectDir) {
writer.appendLine("project(\"${dep.path}\").projectDir = new File($literalQuoteChar${dep.projectDir}$literalQuoteChar)")
val gradleProjectDir = dep.projectDir.path.replace("\\", "\\\\")
// language=groovy
writer.appendLine("""project("${dep.path}").projectDir = new File('$gradleProjectDir')""")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ class FocusPluginTest {
.runFixture(fixtureRoot) { build() }

val focusFileContent = File("src/test/projects/single-quote-path/build/notnowhere/build/focus.settings.gradle").readText()
assertThat(focusFileContent)
.containsMatch("""project\(\":module\"\).projectDir = new File\(\'.*/src/test/projects/single-quote-path/build/notnowhere\'\)""")
val absoluteFilePath = fixtureRoot.resolve("build/notnowhere").absolutePath.replace("\\", "\\\\")
// language=groovy
assertThat(focusFileContent).contains("""project(":module").projectDir = new File('$absoluteFilePath')""")
}

private fun GradleRunner.runFixture(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include(":module")

project(":module").projectDir = new File("${rootProject.projectDir}\\build\\notnowhere")
project(":module").projectDir = new File(rootDir, "build/notnowhere")

0 comments on commit 20bb027

Please sign in to comment.