2021-07-08 16:38:20 +03:00
|
|
|
import sbt._
|
|
|
|
|
|
|
|
object Editions {
|
2021-08-12 17:55:23 +03:00
|
|
|
|
|
|
|
/** List of libraries that are shipped with the engine and reside in the
|
|
|
|
* engine repository.
|
|
|
|
*
|
|
|
|
* They currently all share the version number.
|
|
|
|
*/
|
2021-07-08 16:38:20 +03:00
|
|
|
val standardLibraries: Seq[String] = Seq(
|
|
|
|
"Standard.Base",
|
|
|
|
"Standard.Test",
|
|
|
|
"Standard.Table",
|
|
|
|
"Standard.Database",
|
2023-05-04 20:36:51 +03:00
|
|
|
"Standard.AWS",
|
2021-07-08 16:38:20 +03:00
|
|
|
"Standard.Image",
|
|
|
|
"Standard.Geo",
|
|
|
|
"Standard.Visualization",
|
2021-08-13 19:14:20 +03:00
|
|
|
"Standard.Examples",
|
2024-02-13 19:23:48 +03:00
|
|
|
"Standard.Searcher",
|
|
|
|
"Standard.Google_Api"
|
2021-07-08 16:38:20 +03:00
|
|
|
)
|
|
|
|
|
2021-08-12 17:55:23 +03:00
|
|
|
case class ContribLibrary(name: String, version: String)
|
|
|
|
|
|
|
|
/** A list of additional libraries from external sources that are published in
|
|
|
|
* the main repository and should be available in the default edition.
|
|
|
|
*/
|
|
|
|
val contribLibraries: Seq[ContribLibrary] = Seq()
|
|
|
|
|
2021-08-18 11:01:28 +03:00
|
|
|
/** The URL to the main library repository. */
|
|
|
|
val mainLibraryRepositoryUrl = "https://libraries.release.enso.org/libraries"
|
|
|
|
|
2022-02-07 17:14:32 +03:00
|
|
|
private val extension = ".yaml"
|
2021-08-12 17:55:23 +03:00
|
|
|
|
2021-07-08 16:38:20 +03:00
|
|
|
/** Generates a base edition file for the engine release that contains the
|
|
|
|
* Standard library and is associated with the current Enso version.
|
|
|
|
*/
|
|
|
|
def writeEditionConfig(
|
2022-02-07 17:14:32 +03:00
|
|
|
editionsRoot: File,
|
2021-07-08 16:38:20 +03:00
|
|
|
ensoVersion: String,
|
|
|
|
editionName: String,
|
|
|
|
libraryVersion: String,
|
|
|
|
log: Logger
|
|
|
|
): Unit = {
|
2021-08-12 17:55:23 +03:00
|
|
|
IO.createDirectory(editionsRoot)
|
|
|
|
val edition = editionsRoot / (editionName + extension)
|
2021-07-13 14:08:00 +03:00
|
|
|
|
2021-08-12 17:55:23 +03:00
|
|
|
for (file <- IO.listFiles(editionsRoot)) {
|
2021-07-13 14:08:00 +03:00
|
|
|
if (file.getName != edition.getName) {
|
|
|
|
IO.delete(file)
|
|
|
|
log.warn(s"Removed spurious file in editions directory: $file")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-07 17:14:32 +03:00
|
|
|
val editionConfigContent = {
|
2021-08-12 17:55:23 +03:00
|
|
|
val standardLibrariesConfigs = standardLibraries.map { libName =>
|
2021-07-08 16:38:20 +03:00
|
|
|
s""" - name: $libName
|
|
|
|
| repository: main
|
|
|
|
| version: $libraryVersion""".stripMargin
|
|
|
|
}
|
|
|
|
|
2021-08-12 17:55:23 +03:00
|
|
|
val contribLibrariesConfigs = contribLibraries.map {
|
|
|
|
case ContribLibrary(name, version) =>
|
|
|
|
s""" - name: $name
|
|
|
|
| repository: main
|
|
|
|
| version: $version""".stripMargin
|
|
|
|
}
|
|
|
|
|
|
|
|
val librariesConfigs = standardLibrariesConfigs ++ contribLibrariesConfigs
|
|
|
|
|
2021-07-08 16:38:20 +03:00
|
|
|
val editionConfig =
|
|
|
|
s"""engine-version: $ensoVersion
|
|
|
|
|repositories:
|
|
|
|
| - name: main
|
2021-08-18 11:01:28 +03:00
|
|
|
| url: $mainLibraryRepositoryUrl
|
2021-07-08 16:38:20 +03:00
|
|
|
|libraries:
|
|
|
|
|${librariesConfigs.mkString("\n")}
|
|
|
|
|""".stripMargin
|
2022-02-07 17:14:32 +03:00
|
|
|
editionConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
val currentContent = if (edition.exists()) Some(IO.read(edition)) else None
|
|
|
|
if (currentContent.contains(editionConfigContent)) {
|
|
|
|
log.debug(s"Edition config [$edition] is already up-to-date.")
|
2021-07-08 16:38:20 +03:00
|
|
|
} else {
|
2022-02-07 17:14:32 +03:00
|
|
|
IO.write(edition, editionConfigContent)
|
|
|
|
log.info(s"Written edition config to [$edition].")
|
2021-07-08 16:38:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|