@@ -214,25 +214,38 @@ class BuildUtility(logger: ManagedLogger) {
214
214
def packageGUITask (guiProjectPath : String , scalaMajorVersion : String , crossTargetDir : File ): Unit = {
215
215
val dir = new File (guiProjectPath, " dist" )
216
216
if (! dir.exists()) {
217
+ logger info " GUI hasn't been compiled. Won't create a jar for it."
217
218
return
218
219
}
219
220
220
221
val files = recursiveFileListing(dir)
221
222
222
223
// contains tuples with the actual file as the first value and the name with directory in the jar as the second value
223
- val jarEntries = files.map(file => ( file, " /chatoverflow-gui/" + dir.toURI.relativize(file.toURI)) )
224
+ val jarEntries = files.map(file => file -> s " /chatoverflow-gui/ ${ dir.toURI.relativize(file.toURI).toString} " )
224
225
225
- val guiVersion = getGUIVersion(guiProjectPath)
226
+ val guiVersion = getGUIVersion(guiProjectPath).getOrElse( " unknown " )
226
227
227
228
sbt.IO .jar(jarEntries, new File (crossTargetDir, s " chatoverflow-gui_ $scalaMajorVersion- $guiVersion.jar " ), new Manifest ())
228
229
}
229
230
230
- private def getGUIVersion (guiProjectPath : String ): String = {
231
- val packageJson = Source .fromFile(s " $guiProjectPath/package.json " )
232
- val version = new ObjectMapper ().reader().readTree(packageJson.mkString).get(" version" ).asText()
231
+ private def getGUIVersion (guiProjectPath : String ): Option [String ] = {
232
+ val packageJson = new File (s " $guiProjectPath/package.json " )
233
+ if (! packageJson.exists()) {
234
+ logger error " The package.json file of the GUI doesn't exist. Have you cloned the GUI in the correct directory?"
235
+ return None
236
+ }
237
+
238
+ val content = Source .fromFile(packageJson)
239
+ val version = new ObjectMapper ().reader().readTree(content.mkString).get(" version" ).asText()
240
+
241
+ content.close()
233
242
234
- packageJson.close()
235
- version
243
+ if (version.isEmpty) {
244
+ logger warn " The GUI version couldn't be loaded from the package.json."
245
+ None
246
+ } else {
247
+ Option (version)
248
+ }
236
249
}
237
250
238
251
/**
0 commit comments