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,17 @@ 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()

//Am I being to smart? Basically we want to check if there is an element that is in both fileNames and filesInDir
return if ((fileNames - filesInDir).isNotEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

insersect would be readable, and then you can remove the comment.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/intersect.html

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")
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.

Could you please add build.gradle.kt too? It's the Gradle API for Kotlin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add settings.gradle.kt - build.gradle.kt can be in submodule.


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