Skip to content

Provide a way to determine if an sbt Project is a Scala.js project #2350

Closed
@dwijnand

Description

@dwijnand

It would be convenient if it were possible to determine if an sbt Project is a Scala.js project.

Perhaps something like this (which I have for now in user-land):

import sbt._
import sbt.Keys._

object IsScalaJsProjectAutoPlugin extends AutoPlugin {
  override def requires = plugins.JvmPlugin
  override def trigger = allRequirements

  object autoImport {
    val isScalaJsProject = settingKey[Boolean]("Determines if a project is a Scala.js project")
  }
  import autoImport._

  override def globalSettings: Seq[Setting[_]] = Seq(isScalaJsProject := false)

  override def projectSettings: Seq[Setting[_]] = Seq(
    isScalaJsProject := libraryDependencies.value.exists(_.name == "scalajs-library")
  )
}

Metadata

Metadata

Assignees

Labels

enhancementFeature request (that does not concern language semantics, see "language")

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions