enso/project/Editions.scala

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

91 lines
2.6 KiB
Scala
Raw Normal View History

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",
"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",
"Standard.Searcher"
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"
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(
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-08-12 17:55:23 +03:00
for (file <- IO.listFiles(editionsRoot)) {
if (file.getName != edition.getName) {
IO.delete(file)
log.warn(s"Removed spurious file in editions directory: $file")
}
}
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
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 {
IO.write(edition, editionConfigContent)
log.info(s"Written edition config to [$edition].")
2021-07-08 16:38:20 +03:00
}
}
}