Scala, VScode, Ubuntu
Je vais expliquer comment utiliser Scala avec VScode sur Ubuntu18.
Les versions sont:
- Scala: 2.11.12
- VScode: 1.34
- Ubuntu: 18.04.2 LTS
Les versions sont:
Installer sbt
D'abord, voir quelle version est la dernière.
http://dl.bintray.com/sbt/debian/
C’était version 1.2.8 à ce jour, alors je vais installer sbt 1.2.8:
$ curl -L -o sbt.deb http://dl.bintray.com/sbt/debian/sbt-1.2.8.deb
$ sudo dpkg -i sbt.deb
$ sudo apt-get update
$ sudo apt-get install sbt
Maintenant nous pouvons utiliser sbt comme ça:
$ sbt
[info] Loading project definition from /home/user/project
[info] Set current project to shu (in build file:/home/user/)
[info] sbt server started at local:///home/user/.sbt/1.0/server/9a48bc25b5f71ce94d5c/sock
sbt:user>
Pour voir la version:
$ sbt "show sbtVersion"
[info] Loading project definition from /home/user/project
[info] Set current project to shu (in build file:/home/shu/)
[info] 1.2.8
http://dl.bintray.com/sbt/debian/
$ curl -L -o sbt.deb http://dl.bintray.com/sbt/debian/sbt-1.2.8.deb
$ sudo dpkg -i sbt.deb
$ sudo apt-get update
$ sudo apt-get install sbt
$ sbt
[info] Loading project definition from /home/user/project
[info] Set current project to shu (in build file:/home/user/)
[info] sbt server started at local:///home/user/.sbt/1.0/server/9a48bc25b5f71ce94d5c/sock
sbt:user>
$ sbt "show sbtVersion"
[info] Loading project definition from /home/user/project
[info] Set current project to shu (in build file:/home/shu/)
[info] 1.2.8
Installer le support de Scala sur VScode
Créer un nouveau projet
Exécuter ces commandes sur le terminal de vscode:
$ cd {path of directory which you want to locate the project}
$ sbt new sbt/scala-seed.g8
Le projet de Scala est créé là. Glisser-poser le projet créé sur vscode.
Si ça commence compiler, attendre jusqu’à ça finit compiler.
$ cd {path of directory which you want to locate the project}
$ sbt new sbt/scala-seed.g8
Hello World
Exécuter cette commande sur le terminal de vscode pour voir si exécuter le projet:
$ sbt run
Si nous voyons ce message, ça veut dire c'est un succès. Nous sommes prêt à écrire avec Scala sur vscode.
$ sbt run
[info] Loading project definition from /home/shu/user/scala-test/project
[info] Updating ProjectRef(uri("file:/home/shu/user/scala-test/project/"), "scala-test-build")...
[info] Done updating.
[info] Compiling 1 Scala source to /home/shu/user/scala-test/project/target/scala-2.12/sbt-1.0/classes ...
[info] Done compiling.
[info] Loading settings for project root from build.sbt ...
[info] Set current project to scala test (in build file:/home/shu/user/scala-test/)
[info] Updating ...
[info] Done updating.
[info] Compiling 1 Scala source to /home/shu/user/scala-test/target/scala-2.12/classes ...
[info] Done compiling.
[info] Packaging /home/shu/user/scala-test/target/scala-2.12/scala-test_2.12-0.1.0-SNAPSHOT.jar ...
[info] Done packaging.
[info] Running example.Hello
hello
[success] Total time: 2 s, completed Jun 7, 2019 11:46:32 PM
$ sbt run
Si nous voyons ce message, ça veut dire c'est un succès. Nous sommes prêt à écrire avec Scala sur vscode.
$ sbt run
[info] Loading project definition from /home/shu/user/scala-test/project
[info] Updating ProjectRef(uri("file:/home/shu/user/scala-test/project/"), "scala-test-build")...
[info] Done updating.
[info] Compiling 1 Scala source to /home/shu/user/scala-test/project/target/scala-2.12/sbt-1.0/classes ...
[info] Done compiling.
[info] Loading settings for project root from build.sbt ...
[info] Set current project to scala test (in build file:/home/shu/user/scala-test/)
[info] Updating ...
[info] Done updating.
[info] Compiling 1 Scala source to /home/shu/user/scala-test/target/scala-2.12/classes ...
[info] Done compiling.
[info] Packaging /home/shu/user/scala-test/target/scala-2.12/scala-test_2.12-0.1.0-SNAPSHOT.jar ...
[info] Done packaging.
[info] Running example.Hello
hello
[success] Total time: 2 s, completed Jun 7, 2019 11:46:32 PM
Aucun commentaire:
Enregistrer un commentaire