Skip to content

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
  • Loading branch information
turboFei committed Nov 8, 2024
1 parent 2cd91d2 commit d7b5267
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions project/CelebornBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,17 @@ object CelebornOpenApi {
val internalWorkerSrcDir = file(openApiWorkerInternalOutputDir) / "src" / "main" / "java"
val openApiSrcDir = file(openApiClientOutputDir)

def compareDirectories(srcDir: File, dstDir: File): Unit = {
def getRelativePaths(dir: File): Set[String] = {
(dir ** "*.java").get.map(_.relativeTo(dir).get.getPath).toSet
}
val internalSrcPaths = getRelativePaths(internalMasterSrcDir) ++ getRelativePaths(internalWorkerSrcDir)
val openApiSrcPaths = getRelativePaths(openApiSrcDir)
val notGeneratedSrcPaths = openApiSrcPaths -- internalSrcPaths
if (notGeneratedSrcPaths.nonEmpty) {
sys.error(s"Files ${notGeneratedSrcPaths.mkString(", ")} not generated by openapi generator anymore, seems outdated.")
}

def diffDirSrcFiles(srcDir: File, dstDir: File): Unit = {
val srcFiles = (srcDir ** "*.java").get
val dstFiles = (dstDir ** "*.java").get

Expand All @@ -1461,22 +1471,10 @@ object CelebornOpenApi {
}
}
}
diffDirSrcFiles(internalMasterSrcDir, openApiSrcDir)
diffDirSrcFiles(internalWorkerSrcDir, openApiSrcDir)

compareDirectories(internalMasterSrcDir, openApiSrcDir)
compareDirectories(internalWorkerSrcDir, openApiSrcDir)

def getRelativePaths(dir: File): Set[String] = {
(dir ** "*.java").get.map(_.relativeTo(dir).get.getPath).toSet
}

val internalSrcPaths = getRelativePaths(internalMasterSrcDir) ++ getRelativePaths(internalWorkerSrcDir)
val openApiSrcPaths = getRelativePaths(openApiSrcDir)
val missingSrcPaths = openApiSrcPaths -- internalSrcPaths
if (missingSrcPaths.nonEmpty) {
sys.error(s"Files ${missingSrcPaths.mkString(", ")} not generated by openapi generator anymore, seems outdated.")
}

streams.value.log.info("All generated files are consistent with the existing code.")
streams.value.log.info("The openapi spec and code are consistent.")
},

(assembly / test) := { },
Expand Down

0 comments on commit d7b5267

Please sign in to comment.