Git Product home page Git Product logo

scala3-example-project's Introduction

Example sbt project that compiles using Scala 3

Continuous Integration

Usage

This is a normal sbt project. You can start the sbt shell using sbt then compile code with compile, run the main method with run, run the tests with test and start a REPL using console.

If compiling this example project fails, you probably have a global sbt plugin that does not work with Scala 3. You might try disabling plugins in ~/.sbt/1.0/plugins and ~/.sbt/1.0.

Making a new Scala 3 project

The fastest way to start a new Scala 3 project is to use one of the following templates:

Using Scala 3 in an existing project

You will need to make the following adjustments to your build:

project/build.properties

sbt.version=1.9.9

You must use sbt 1.5.5 or newer; older versions of sbt are not supported.

build.sbt

Set the Scala 3 version:

scalaVersion := "3.4.1"

Getting your project to compile with Scala 3

For help with porting an existing Scala 2 project to Scala 3, see the Scala 3 migration guide.

Need help?

https://www.scala-lang.org/community/ has links.

scala3-example-project's People

Contributors

abgruszecki avatar allanrenucci avatar alvinj avatar anatoliykmetyuk avatar biboudis avatar bishabosha avatar blaisorblade avatar brbrown25 avatar darkdimius avatar dependabot[bot] avatar faveoled avatar felixmulder avatar ferhtaydn avatar fermiyon avatar julienrf avatar kordyjan avatar liufengyun avatar nicolasstucki avatar nthportal avatar olivierblanvillain avatar philippus avatar prolativ avatar sake92 avatar scala-steward avatar sethtisue avatar shapelesscat avatar smarter avatar unkarjedy avatar xhudik avatar xuwei-k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scala3-example-project's Issues

SBT fails to resolve dependency: wartremover

I'm getting the following error message. By the way same error with sbt new lampepfl/dotty.g8 and sbt new lampepfl/dotty-cross.g8.

warn] ==== sonatype-releases: tried
[warn] https://oss.sonatype.org/content/repositories/releases/org/brianmckenna/wartremover_0.1/0.12/wartremover_0.1-0.12.pom
[info] Resolving org.scala-lang.modules#scala-xml_2.11;1.0.1 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.brianmckenna#wartremover_0.1;0.12: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.brianmckenna:wartremover_0.1:0.12 ((sbt.BuildExtra) Defaults.scala#L2018)
[warn] +- dotty-example-project:dotty-example-project_0.1:0.1
sbt.ResolveException: unresolved dependency: org.brianmckenna#wartremover_0.1;0.12: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:313)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:191)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:168)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:133)
at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:57)
at sbt.IvySbt$$anon$4.call(Ivy.scala:65)
at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:93)
at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:78)

    at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:97)
    at xsbt.boot.Using$.withResource(Using.scala:10)
    at xsbt.boot.Using$.apply(Using.scala:9)
    at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:58)
    at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:48)
    at xsbt.boot.Locks$.apply0(Locks.scala:31)
    at xsbt.boot.Locks$.apply(Locks.scala:28)
    at sbt.IvySbt.withDefaultLogger(Ivy.scala:65)
    at sbt.IvySbt.withIvy(Ivy.scala:128)
    at sbt.IvySbt.withIvy(Ivy.scala:125)
    at sbt.IvySbt$Module.withModule(Ivy.scala:156)
    at sbt.IvyActions$.updateEither(IvyActions.scala:168)
    at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1488)
    at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1484)
    at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$121.apply(Defaults.scala:1519)
    at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$121.apply(Defaults.scala:1517)
    at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:37)
    at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1522)
    at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1516)
    at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:60)
    at sbt.Classpaths$.cachedUpdate(Defaults.scala:1539)
    at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1466)
    at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1418)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:237)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

[error] (*:update) sbt.ResolveException: unresolved dependency: org.brianmckenna#wartremover_0.1;0.12: not found

scala 3 vs scala 2

Hi, a newbie question:
if I add println(Console.YELLOW + s"Scala version = ${util.Properties.versionString}") into Main.scala and run sbt run I got:

Scala version = 2.13.4
Trait Params example:
Hello Dotty!

...

Any idea why I'm getting 2.13.4 instead of Scala 3.0.0RC1? (the true is that I have installed Scala 2.13.4 on my local laptop)

How to use sbt plugin published in Scala 2 ?

This section described how to use normal dependencies published for Scala 2.

I think it would be great if the section also mention regarding sbt plugin, for people like me who lack of in-depth understadning sbt.

When I updated my project/plugins.sbt like below:

def dottySupport(moduleId: ModuleID): ModuleID = moduleId.withDottyCompat(scalaVersion.value)

addSbtPlugin(dottySupport("org.scala-js" % "sbt-scalajs" % "0.6.31"))
addSbtPlugin(dottySupport("org.scalameta" % "sbt-scalafmt" % "2.3.0"))

error: value withDottyCompat is not a member of sbt.ModuleID occured.

Travis CI Fails

Apparently, the failure is an infrastructural issue:

Expected feature release number in range of 9 to 13, but got: 8
The command "~/bin/install-jdk.sh --target "/home/travis/oraclejdk8" --workspace "/home/travis/.cache/install-jdk" --feature "8" --license "BCL"" failed and exited with 3 during .

Looks like Travis suddenly stopped digesting the JDK installation command.

`sbt compile` fails with global ammonite dependency

sbt compile in this project fails with the following error:

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.lihaoyi#ammonite_0.1-SNAPSHOT;0.7.0: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::

when I have the following in ~/.sbt/0.13/global.sbt:

libraryDependencies += "com.lihaoyi" % "ammonite" % "0.7.0" % "test" cross CrossVersion.full

It seems like the cross CrossVersion.full generates an invalid version in this case because there is no published SNAPSHOT version of ammonite?

I'm not sure if this is a bug or more of a pitfall to document. I'd be happy to make a PR adding warnings in the README if its a documentation issue.

Example usage @threadUnsafe annotation

Hi everyone.

This project include example to use lazy val field. In new proposal to Scala project have changed implementation of lazy val.

    /**
      * In order to get thread safety, you need to put @volatile before lazy vals.
      * https://dotty.epfl.ch/docs/reference/changed-features/lazy-vals-init.html
      */
    @volatile lazy val xs: List[String] = List("d", "o", "t", "t", "y")

As I understood to safe thread-safe sematics we need to attach @volatile annotation to lazy val field.

Dotty/Scala3 in std have scala.annotation.threadUnsafe annotation also. Is it still actual annotation? And if it is true in wich cases we need to use this annotation. Can you please add example?

Thank you

Error downloading ch.epfl.lamp:sbt-dotty;sbtVersion=1.0;scalaVersion=3.0.0-M2:0.4.6

I have very simple sbt project and can't get it run. What can I do? What am I doing wrong?

sbt version is 1.4.4

This is build.sbt

val dottyVersion = "3.0.0-M2"

lazy val root = project
  .in(file("."))
  .settings(
    name := "dotty-simple",
    version := "0.1.0",

    scalaVersion := dottyVersion
  )

sbt outputs the following:

/usr/lib/jvm/java-11-openjdk-amd64/bin/java -Djline.terminal=jline.UnsupportedTerminal -Dsbt.log.noformat=true -Dfile.encoding=UTF-8 -Didea.managed=true -Dfile.encoding=UTF-8 -jar /home/snet/.local/share/JetBrains/IntelliJIdea2020.3/Scala/launcher/sbt-launch.jar
[info] welcome to sbt 1.4.4 (Ubuntu Java 11.0.9.1)
[info] loading global plugins from /home/snet/.sbt/1.0/plugins
[info] loading settings for project dotty-workaround-build from plugins.sbt ...
[info] loading project definition from /home/snet/Documents/razvoj/dotty-workaround/project
[info] loading settings for project root from build.sbt,project\plugins.sbt ...
[info] set current project to dotty-simple (in build file:/home/snet/Documents/razvoj/dotty-workaround/)
[info] sbt server started at local:///home/snet/.sbt/1.0/server/026a91eb7bb819c87101/sock
[info] started sbt server
sbt:dotty-simple>
;set _root_.scala.collection.Seq(historyPath := None,shellPrompt := { _ => "" },SettingKey[_root_.scala.Option[_root_.sbt.File]]("sbtStructureOutputFile")
in _root_.sbt.Global := _root_.scala.Some(_root_.sbt.file("/tmp/sbt-structure.xml")),SettingKey[_root_.java.lang.String]("sbtStructureOptions")
in _root_.sbt.Global := "download, resolveClassifiers")
[info] Defining Global / sbtStructureOptions, Global / sbtStructureOutputFile and 1 others.
[info] The new values will be used by cleanKeepGlobs
[info] 	Run `last` for details.
[info] Reapplying settings...
[info] set current project to dotty-simple (in build file:/home/snet/Documents/razvoj/dotty-workaround/)
[info] Applying State transformations org.jetbrains.sbt.CreateTasks from /home/snet/.local/share/JetBrains/IntelliJIdea2020.3/Scala/repo/org.jetbrains/sbt-structure-extractor/scala_2.12/sbt_1.0/2020.3/jars/sbt-structure-extractor.jar
[info] Reapplying settings...
[info] set current project to dotty-simple (in build file:/home/snet/Documents/razvoj/dotty-workaround/)
[warn]
[warn] 	Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn] 		ch.epfl.lamp:sbt-dotty:0.4.6 (sbtVersion=1.0, scalaVersion=3.0.0-M2)
[warn]
[warn] 	Note: Unresolved dependencies path:
[error] stack trace is suppressed; run 'last update' for the full output
[error] stack trace is suppressed; run 'last ssExtractDependencies' for the full output
[error] (update) sbt.librarymanagement.ResolveException: Error downloading ch.epfl.lamp:sbt-dotty;sbtVersion=1.0;scalaVersion=3.0.0-M2:0.4.6
[error]   Not found
[error]   Not found
[error]   not found: /home/snet/.ivy2/local/ch.epfl.lamp/sbt-dotty/scala_3.0.0-M2/sbt_1.0/0.4.6/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/ch/epfl/lamp/sbt-dotty_3.0.0-M2_1.0/0.4.6/sbt-dotty-0.4.6.pom
[error] Error downloading org.scala-lang:scala-library:3.0.0-M2
[error]   Not found
[error]   Not found
[error]   not found: /home/snet/.ivy2/local/org.scala-lang/scala-library/3.0.0-M2/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/org/scala-lang/scala-library/3.0.0-M2/scala-library-3.0.0-M2.pom
[error] (ssExtractDependencies) sbt.librarymanagement.ResolveException: Error downloading ch.epfl.lamp:sbt-dotty;sbtVersion=1.0;scalaVersion=3.0.0-M2:0.4.6
[error]   Not found
[error]   Not found
[error]   not found: /home/snet/.ivy2/local/ch.epfl.lamp/sbt-dotty/scala_3.0.0-M2/sbt_1.0/0.4.6/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/ch/epfl/lamp/sbt-dotty_3.0.0-M2_1.0/0.4.6/sbt-dotty-0.4.6.pom
[error] Error downloading org.scala-lang:scala-library:3.0.0-M2
[error]   Not found
[error]   Not found
[error]   not found: /home/snet/.ivy2/local/org.scala-lang/scala-library/3.0.0-M2/ivys/ivy.xml
[error]   not found: https://repo1.maven.org/maven2/org/scala-lang/scala-library/3.0.0-M2/scala-library-3.0.0-M2.pom
[error] Total time: 1 s, completed 16. dec. 2020 11:00:38
[info] shutting down sbt server

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.