You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2023/01/17 17:53:51 UTC

[GitHub] [beam] damondouglas commented on a diff in pull request #25022: [Playground] Add config.g.dart+Fix gradle

damondouglas commented on code in PR #25022:
URL: https://github.com/apache/beam/pull/25022#discussion_r1072575604


##########
playground/terraform/build.gradle.kts:
##########
@@ -295,7 +295,25 @@ tasks.register("prepareConfig") {
         val configFileName = "config.g.dart"
         val modulePath = project(":playground:frontend").projectDir.absolutePath
         var file = File("$modulePath/lib/$configFileName")
-
+        val lines = file.readLines()
+        val endOfSlice = lines.indexOfFirst { it.contains("Generated content below") }
+        if (endOfSlice != -1) {
+            val oldContent = lines.slice(0 until endOfSlice)
+            val flagDelete = file.delete()
+            if (!flagDelete) {
+                throw kotlin.RuntimeException("Deleting file failed")
+            }
+            val sb = kotlin.text.StringBuilder()
+            val lastLine = oldContent[oldContent.size - 1]
+            oldContent.forEach {
+                if (it == lastLine) {
+                    sb.append(it)
+                } else {
+                    sb.appendLine(it)
+                }
+            }
+            file.writeText(sb.toString())
+        }

Review Comment:
   @MakarkinSAkvelon / @alexeyinkin Do we really need a gradle task wrapper to generate the `config.g.dart` file?  What would be the consequences if we do not automate its generation?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org