Scala-js: Provide a way to determine if an sbt Project is a Scala.js project

Created on 22 Apr 2016  路  3Comments  路  Source: scala-js/scala-js

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")
  )
}
enhancement

Most helpful comment

It was superseded by crossProjectPlatform.value == JSPlatform, offered by sbt-crossproject.

All 3 comments

Example output:

> show isScalaJsProject
[info] str/*:isScalaJsProject
[info]  false
[info] strJs/*:isScalaJsProject
[info]  true
[info] strRoot/*:isScalaJsProject
[info]  false

Was this removed in 1.0? Is there an alternative we can use?

It was superseded by crossProjectPlatform.value == JSPlatform, offered by sbt-crossproject.

Was this page helpful?
0 / 5 - 0 ratings