final
class
CrossProject extends AnyRef
Value Members
-
final
def
!=(arg0: AnyRef): Boolean
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: AnyRef): Boolean
-
final
def
==(arg0: Any): Boolean
-
-
final
def
asInstanceOf[T0]: T0
-
def
clone(): AnyRef
-
def
configs(cs: Configuration*): CrossProject
-
-
-
def
disablePlugins(ps: AutoPlugin*): CrossProject
-
def
enablePlugins(ns: Plugins*): CrossProject
-
final
def
eq(arg0: AnyRef): Boolean
-
def
equals(arg0: Any): Boolean
-
def
finalize(): Unit
-
final
def
getClass(): Class[_]
-
def
hashCode(): Int
-
-
final
def
isInstanceOf[T0]: Boolean
-
val
js: Project
-
def
jsConfigure(transformer: (Project) ⇒ Project): CrossProject
-
def
jsSettings(ss: sbt.Def.Setting[_]*): CrossProject
-
val
jvm: Project
-
def
jvmConfigure(transformer: (Project) ⇒ Project): CrossProject
-
def
jvmSettings(ss: sbt.Def.Setting[_]*): CrossProject
-
final
def
ne(arg0: AnyRef): Boolean
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
def
overrideConfigs(cs: Configuration*): CrossProject
-
def
settingSets(select: AddSettings*): CrossProject
-
def
settings(ss: sbt.Def.Setting[_]*): CrossProject
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
toString(): String
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
Inherited from AnyRef
Inherited from Any
A convenience structure that creates a JVM and a Scala.js project under the hood and forwards common operations to it.
Basic Usage
In your
build.sbt
, use CrossProject as follows:CrossProject types
There are three built-in types of CrossProjects. Each of them corresponds to a concrete subclass of CrossType:
Full CrossProject (CrossType.Full)
A CrossProject that has both shared and individual JVM/JS sources. This is the default.
The directory structure is as follows:
The shared source tree is included in both the JVM and the JS project.
Pure CrossProject (CrossType.Pure)
A CrossProject that does not have individual JVM/JS sources.
The directory structure is as follows:
The source tree is included in both the JVM and the JS project. The hidden folders are the true project roots in sbt's terms.
Dummy CrossProject (CrossType.Dummy)
A CrossProject that does not have shared JVM/JS sources. It is useful, since it can still be used for dependency tracking and aggregation.
The directory structure is as follows:
Eclipse Support
Note that by default, the sbteclipse plugin uses sbt's project names to name the Eclipse projects it generates. Since the CrossProject generates two projects with the same name, this may result in a conflict when importing the projects into Eclipse.
You can configure sbteclipse to [https://github.com/typesafehub/sbteclipse/wiki/Using-sbteclipse#useprojectid use the project ID] instead (which is unique in sbt as well):
EclipseKeys.useProjectId := true
Alternatively, you can of course also just import one of the two projects into your Eclipse.
IntelliJ IDEA Support
While CrossProject works out of the box with Eclipse and the sbt eclipse plugin, it does not with IntelliJ IDEA due to its missing support for shared source directories.
To fix this, you should add symlinks in the hierarchy to the shared source directory and include them in your imported IntelliJ IDEA project (but not in sbt). The recommended structure is as follows (for a Full CrossProject):
Note that we do not recommend to put the symlinks in version control, since they do not work on Windows (Git, for example, just ignores their existence when cloning).
Pitfalls to Avoid
Altering a contained Project outside the CrossProject
Since sbt projects are immutable structures, it is important that you do not "mutate" (i.e. create a new Project) outside of the CrossProject.
DON'T
DO
Manually setting the base of a contained Project
CrossProject puts its contained projects in a given directory structure. If you try to work around that, things will fail (and non-existing directories will be referenced). If you want to put your projects in a different directory structure, you are encouraged to implement your own subclass of CrossType.
DON'T
DO
Implement your own subclass (sub-object) of CrossType.