Skip to content
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

Fix Renzu generating for Ant, Kobalt and Maven #894

Merged
merged 9 commits into from
Jul 1, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,16 @@ fun ClassOrPackageDataWrapper.typeConstraints(): String =
}
}

fun recurseFilesUpwards(fileName: String): File =
recurseFilesUpwards(fileName, File(".").absoluteFile)
fun recurseFilesUpwards(fileNames: Set<String>): File =
recurseFilesUpwards(fileNames, File(".").absoluteFile)

fun recurseFilesUpwards(fileName: String, currentDirectory: File): File =
if (currentDirectory.list().contains(fileName)) {
fun recurseFilesUpwards(fileNames: Set<String>, currentDirectory: File): File {
Copy link
Member

@pakoito pakoito Jun 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tailrec? Looks like tailrec to me.


val filesInDir = currentDirectory.list()

return if ((filesInDir.intersect(fileNames)).isNotEmpty()) {
currentDirectory
} else {
recurseFilesUpwards(fileName, currentDirectory.parentFile)
recurseFilesUpwards(fileNames, currentDirectory.parentFile)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ class RenzuGenerator(
}

fun generate() {

val topLevelFiles = setOf("settings.gradle", "pom.xml", "build.xml", "Build.kt", "settings.gradle.kt")

val generatedDir = if (isolateForTests)
File("./infographic")
else
File("${recurseFilesUpwards("settings.gradle").absolutePath}/infographic")
File("${recurseFilesUpwards(topLevelFiles).absolutePath}/infographic")
.also { it.mkdirs() }

val file = File(generatedDir, "arrow-infographic.txt")
Expand Down