Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Adam Warski
    @adamw
    trying :)
    yes that was it, thanks a lot! :)
    Sébastien Doeraene
    @sjrd
    np :)
    Eric Peters
    @er1c
    Has anyone seen a sbt-crossproject compatible syntax for adding jvm/src/main/scala-2.12-, jvm/src/main/scala-2.12, jvm/src/main/scala-2.11, jvm/src/main/scala-2.13, jvm/src/main/scala-2.13+, (and shared/js variants), I tried https://gist.github.com/er1c/06f66807ca00e8aa4a46ad260ed5e8f7 but I guess that doesn't take into account the platform variant directories
    Eric Peters
    @er1c
    https://gist.github.com/er1c/3e7c1b007ae18514b62eb491541a7c45 - I had to completely override the unmanagedSourceDirectories - any better solution?
    don't even know if that worked now lol
    Eric Peters
    @er1c
    is there anything in sbt-crossproject that would mess up the compileOrder? or is this because of the unmanagedSourceDirectories
    Eric Peters
    @er1c
    in a cross project that .dependsOn another, is there a reason why the test-classes dir wouldn't be included for the dependency during test:compile?
    Kirill A. Korinsky
    @catap

    @sjrd I guess it is the right place to ask a question regarding sbt-crossproject.

    Let image that I would like to have a project that is compiling to all three platforms: jvm, js and native.

    So, the question is: can I remap, replace or implement some class / object /trait with platform specified code and use "shared" version as fallback?

    Sébastien Doeraene
    @sjrd
    No, you cannot use shared as fallback. But you can have different implementations of some class/object/trait in the js/, jvm/ and/or native/ subdirectories.
    If it's the same implem on the JVM and Native but not JS (for example), you need to duplicate it in jvm/ and native/.
    Kirill A. Korinsky
    @catap
    Yep, and I'm using this way for now.
    Eric K Richardson
    @ekrich
    Kirill A. Korinsky
    @catap
    @ekrich thanks, I've enjoyed your code :) it is very nice and tricky stuff
    Eric K Richardson
    @ekrich
    I can't take credit for the build code - I harvested that elsewhere. Thanks!
    Kirill A. Korinsky
    @catap

    How can I make dependency on JS/JVM/Native cross project?

    Let me be clear. I have:

    lazy val project1 = crossProject(JSPlatform, JVMPlatform, NativePlatform)
    
    lazy val project2 = crossProject(JSPlatform, JVMPlatform, NativePlatform)
     .dependsOn(project1)

    And it makes dependency for project2 on shared code. I'd love to have some platform-specified dependency. How can I do this?

    Andriy Plokhotnyuk
    @plokhotnyuk
    @catap you can define platform specific vals for sub-projects with own dependencies and settings like here
    Kirill A. Korinsky
    @catap
    I see, the only way is define platform specified val's and add to theri dependency?
    I guess I figured this out. Code belowe make the trick:
    lazy val project1 = crossProject(JSPlatform, JVMPlatform, NativePlatform)
    
    lazy val project2 = crossProject(JSPlatform, JVMPlatform, NativePlatform)
      .jvmConfigure(_ dependsOn project1.jvm)
      .jsConfigure(_ dependsOn project1.js)
      .nativeConfigure(_ dependsOn project1.native)
    Kirill A. Korinsky
    @catap
    Nevermind, looks like I've used the wrong project, because dependsOn works as expected without this hack
    Kirill A. Korinsky
    @catap
    Does anybody have an example how to build sbt-crossproject based project to sjs1 and sjs0.6?
    Sébastien Doeraene
    @sjrd
    It's in the release notes of Scala.js 1.0.0
    That said, you might want to consider whether it's worth it, given that Scala.js 0.6.x is EOL.
    Kirill A. Korinsky
    @catap
    I see, so it is no way to run tests on both platforms
    Sébastien Doeraene
    @sjrd
    There is, but through two invocations of sbt.
    Not within a single invocation of sbt.
    Kirill A. Korinsky
    @catap
    I hope to some magic.
    :)
    Sébastien Doeraene
    @sjrd
    You may also try sbt-dynscalajs if you are really loath to using an env var.
    Kirill A. Korinsky
    @catap

    I defently don't need it and a few export in sh file is more than enough for my goal.

    Thanks!

    Tomer Margalit
    @matomer
    Hi, I'm trying to add a custom configuration to a cross project (e.g. a custom test configuration to use selenium as the JSEnv for some tests that involve features that are unsupported by jsdom), but I can't seem to find a way to include the cross project related settings (specifically adding the shared directory as a source directory) in a custom configuration.
    Is it possible to create a custom configuration for use with a cross project?
    Felipe Vieira
    @fmv1992

    Hi, I'm having problems setting dependencies for sbt-crossproject:

    Before crossproject : https://github.com/fmv1992/fmv1992_scala_utilities/blob/48e0ba474167568bc0e3dc8df8ec32e13725c8ec/fmv1992_scala_utilities/build.sbt#L159

    After crorssproject : https://github.com/fmv1992/fmv1992_scala_utilities/blob/6069385b0fb7968e7c112439a6a95d8332e94be2/fmv1992_scala_utilities/build.sbt#L159

    On sbt compile:

    [error] fmv1992_scala_utilities/src/main/scala/fmv1992/fmv1992_scala_utilities/uniq/Uniq.scala:22:34: macro implementation not found: putabspath
    [error] (the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them)
    [error]     Reader.readLines(S.putabspath("./src/main/resources/version")).mkString
    [error]                                  ^
    [error] one error found
    [error] Compilation failed
    [error]         at xsbt.CachedCompiler0.handleErrors(CompilerBridge.scala:183)
    [error]         at xsbt.CachedCompiler0.run(CompilerBridge.scala:172)
    [error]         at xsbt.CachedCompiler0.run(CompilerBridge.scala:134)

    util is used by uniq and has a macro which has to be compiled before. However I can't get this to work with sbtcrossproject.

    Can someone please give me a hand?

    Thanks in advance!

    You are not allowed to do that, not any more that factoring out a call to project.
    This is because project and crossProject are macros that decide what projectId to use based on the name of the val they are assigned to.
    Since it is about 4 lines that are used only twice, the easiest fix is to duplicate those lines at the two use sites instead.
    Felipe Vieira
    @fmv1992
    Thanks, Sebastien! : ) (edit: I'll try this shortly)
    Edward A. Maxedon, Sr.
    @edadma

    @sjrd i'm trying to create a sbt-crossproject template project (jvm, sjs). Everything seems to work except unit testing with scalatest. I have no problems with scalatest in an sjs specific project).

    It runs the test for jvm but no sjs. This is what I get

    [info] compiling 2 Scala sources to /home/ed/dev/crossproject/.js/target/scala-2.13/test-classes ...
    [info] Tests:
    [info] - test
    [info] Tests:
    [info] - test
    [info] Run completed in 122 milliseconds.
    [info] Total number of tests run: 1
    [info] Suites: completed 1, aborted 0
    [info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
    [info] All tests passed.
    [info] Run completed in 129 milliseconds.
    [info] Total number of tests run: 1
    [info] Suites: completed 1, aborted 0
    [info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
    [info] All tests passed.
    [info] done compiling
    [info] Fast optimizing /home/ed/dev/crossproject/.js/target/scala-2.13/crossproject-test-fastopt
    [info] Run completed in 19 milliseconds.
    [info] Total number of tests run: 0
    [info] Suites: completed 0, aborted 0
    [info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
    [info] No tests were executed.
    [error] Error during tests:
    [error]     Tests
    [error] (crossprojectJS / Test / test) sbt.TestsFailedException: Tests unsuccessful
    [error] Total time: 3 s, completed Jan. 29, 2021, 4:04:10 p.m.

    here's my build.sbt

    ThisBuild / scalaVersion := "2.13.4"
    ThisBuild / scalacOptions ++=
      Seq(
        "-deprecation", "-feature", "-unchecked",
        "-language:postfixOps", "-language:implicitConversions", "-language:existentials", "-language:dynamics",
        "-Xasync"
      )
    ThisBuild / libraryDependencies ++=
      Seq(
        "com.lihaoyi" %% "scalatags" % "0.9.3",
        "org.scalatest" %% "scalatest" % "3.2.3" % "test",
        "org.scala-lang.modules" %% "scala-async" % "0.10.0",
        "org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided
      )
    
    lazy val root = project.in(file(".")).
      aggregate(crossproject.js, crossproject.jvm).
      settings(
        publish := {},
        publishLocal := {},
      )
    
    lazy val crossproject = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure).in(file(".")).
      settings(
        name := "crossproject",
        version := "0.1.0-snapshot.1",
        mainClass := Some("Main")
      ).
      jvmSettings(
      ).
      jsSettings(
        jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(),
        Test / scalaJSUseMainModuleInitializer := false,
        Test / scalaJSUseTestModuleInitializer := true,
        scalaJSUseMainModuleInitializer := true,
        libraryDependencies ++=
          Seq(
            "com.lihaoyi" %%% "scalatags" % "0.9.3",
            "io.github.cquiroz" %%% "scala-java-time" % "2.0.0",
            "org.scalatest" %%% "scalatest" % "3.2.3" % "test",
          )
      )
    Sébastien Doeraene
    @sjrd
    You need to only use %%%. Here you have %% in ThisBuild and %%% in the JS settings. If you have both, you don't know which one you'll get, and if it's the JVM one, you won't get any tests.
    Edward A. Maxedon, Sr.
    @edadma

    @sjrd Thanks for replying. I made the change and typed clean and reload and got basically the same result:

    when I type crossprojectJVM / test, I get

    [info] Tests:
    [info] - test
    [info] Run completed in 107 milliseconds.
    [info] Total number of tests run: 1
    [info] Suites: completed 1, aborted 0
    [info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
    [info] All tests passed.
    [success] Total time: 0 s, completed Jan. 29, 2021, 6:30:00 p.m.

    and for crossprojectJS / test, I get

    [info] Fast optimizing /home/ed/dev/crossproject/.js/target/scala-2.13/crossproject-test-fastopt
    [info] Run completed in 37 milliseconds.
    [info] Total number of tests run: 0
    [info] Suites: completed 0, aborted 0
    [info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
    [info] No tests were executed.
    [error] Error during tests:
    [error]     Tests
    [error] (crossprojectJS / Test / test) sbt.TestsFailedException: Tests unsuccessful
    [error] Total time: 4 s, completed Jan. 29, 2021, 6:29:49 p.m.

    I tried downgrading to scalatest 3.1.1 which is what I've been using for doing Node.js development in Scala.js and there was no change in result. BTW, I only use Scala.js for making Node libraries and I love it. I hope I can get cross project development working.

    Edward A. Maxedon, Sr.
    @edadma
    µTest 0.7.7 works perfectly with sbt-crossproject: runs the same tests under both platforms (including async tests). scalatest just doesn't work well under sbt-crossproject
    Sébastien Doeraene
    @sjrd
    Make sure that show projectJS/test:fullClasspath doesn't contain any JVM library.
    Oleg Pyzhcov
    @oleg-py
    Hello. I'm trying to port this project to cross-build for JVM and JS. The project has multiple modules, and most of them use (the sbt feature)[https://www.scala-sbt.org/1.x/docs/Multi-Project.html#Appendix%3A+Subproject+build+definition+files] to declare additional dependencies in an sbt file that is in a submodule folder. It seems that when I turn a regular project into a cross-project, those files get totally ignored. Is that known/intended?
    Eric K Richardson
    @ekrich
    If you look at this project you can see how different dependencies are used in jvm vs js and native and how you can have a dependency in .settings for all the platforms. https://github.com/ekrich/sconfig/blob/master/build.sbt#L100
    You can also look at project/plugins.sbt to see how that is set up.
    Oleg Pyzhcov
    @oleg-py
    Yeah I know how I could set it up without relying on this sbt feature, just would like to avoid having to fully rewrite somebody else's build if that's an option
    Kirill A. Korinsky
    @catap
    Is it possible to define a few cross projects for JS with different jsEnv at tests?
    Yiannis Papagiannidis
    @ip9dis
    Hello, I have a project using sbt-crossproject. I would like to import classes from a jar in a file in the shared folder but I cannot do it. Where am I suppose to place the lib/my_jar so the shared folder files can see it as dependency?