From 95966f0e581f828e5dee62abd23b5305dc52d07f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC?= Date: Mon, 5 Sep 2022 08:53:51 +0300 Subject: [PATCH 01/13] Add getting-started in russian --- _getting-started/index.md | 2 +- _ru/_getting-started/index.md | 234 ++++++++++++++++++++++++++++++++++ 2 files changed, 235 insertions(+), 1 deletion(-) create mode 100644 _ru/_getting-started/index.md diff --git a/_getting-started/index.md b/_getting-started/index.md index 9b232187c1..1166dc4fd0 100644 --- a/_getting-started/index.md +++ b/_getting-started/index.md @@ -2,7 +2,7 @@ layout: singlepage-overview title: Getting Started partof: getting-started -languages: [fr, ja, uk] +languages: [fr, ja, ru, uk] includeTOC: true newcomer_resources: diff --git a/_ru/_getting-started/index.md b/_ru/_getting-started/index.md new file mode 100644 index 0000000000..e365fa7553 --- /dev/null +++ b/_ru/_getting-started/index.md @@ -0,0 +1,234 @@ +--- +layout: singlepage-overview +title: Начало работы +partof: getting-started +language: ru +includeTOC: true + +newcomer_resources: + - title: Вы пришли с Java? + description: Что нужно знать, чтобы ускорить работу со Scala после первоначального запуска. + icon: "fa fa-coffee" + link: /tutorials/scala-for-java-programmers.html + - title: Scala в браузере + description: > + Чтобы сразу начать экспериментировать со Scala, используйте "Scastie" в своем браузере. + icon: "fa fa-cloud" + link: https://scastie.scala-lang.org/pEBYc5VMT02wAGaDrfLnyw +--- + +Приведенные ниже инструкции охватывают как Scala 3, так и Scala 2. + +
+{% altDetails need-help-info-box 'Нужна помощь?' class=help-info %} +*Если у вас возникли проблемы с настройкой Scala, смело обращайтесь за помощью в канал `#scala-users` +[нашего Discord](https://discord.com/invite/scala).* +{% endaltDetails %} +
+ +## Resources For Newcomers + +{% include inner-documentation-sections.html links=page.newcomer_resources %} + +## Install Scala on your computer + +Installing Scala means installing various command-line tools such as the Scala compiler and build tools. +We recommend using the Scala installer tool "Coursier" that automatically installs all the requirements, but you can still manually install each tool. + +### Using the Scala Installer (recommended way) + +The Scala installer is a tool named [Coursier](https://get-coursier.io/docs/cli-overview), whose main command is named `cs`. +It ensures that a JVM and standard Scala tools are installed on your system. +Install it on your system with the following instructions. + + +{% tabs install-cs-setup-tabs class=platform-os-options %} + + +{% tab macOS for=install-cs-setup-tabs %} +Run the following command in your terminal, following the on-screen instructions: +{% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-brew %} +{% altDetails cs-setup-macos-nobrew "Alternatively, if you don't use Homebrew:" %} + {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-default %} +{% endaltDetails %} +{% endtab %} + + + +{% tab Linux for=install-cs-setup-tabs %} + Run the following command in your terminal, following the on-screen instructions: + {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.linux %} +{% endtab %} + + + +{% tab Windows for=install-cs-setup-tabs %} + Download and execute [the Scala installer for Windows]({{site.data.setup-scala.windows-link}}) + based on Coursier, and follow the on-screen instructions. +{% endtab %} + + + +{% tab Other for=install-cs-setup-tabs defaultTab %} + + Follow the documentation from Coursier on + [how to install and run `cs setup`](https://get-coursier.io/docs/cli-installation). +{% endtab %} + + +{% endtabs %} + + + +{% altDetails testing-your-setup 'Testing your setup' %} +Check your setup with the command `scala -version`, which should output: +```bash +$ scala -version +Scala code runner version {{site.scala-3-version}} -- Copyright 2002-2022, LAMP/EPFL +``` +If that does not work, you may need to log out and log back in (or reboot) in order for the changes to take effect. +{% endaltDetails %} + + + +Along with managing JVMs, `cs setup` also installs useful command-line tools: + +| Commands | Description | +|----------|-------------| +| `scalac` | the Scala compiler | +| `scala` | the Scala REPL and script runner | +| `scala-cli`| [Scala CLI](https://scala-cli.virtuslab.org), interactive toolkit for Scala | +| `sbt`, `sbtn` | The [sbt](https://www.scala-sbt.org/) build tool | +| `amm` | [Ammonite](https://ammonite.io/) is an enhanced REPL | +| `scalafmt` | [Scalafmt](https://scalameta.org/scalafmt/) is the Scala code formatter | + +For more information about `cs`, read +[coursier-cli documentation](https://get-coursier.io/docs/cli-overview). + +> `cs setup` installs the Scala 3 compiler and runner by default (the `scalac` and +> `scala` commands, respectively). Whether you intend to use Scala 2 or 3, +> this is usually not an issue because most projects use a build tool that will +> use the correct version of Scala irrespective of the one installed "globally". +> Nevertheless, you can always launch a specific version of Scala using +> ``` +> $ cs launch scala:{{ site.scala-version }} +> $ cs launch scalac:{{ site.scala-version }} +> ``` +> If you prefer Scala 2 to be run by default, you can force that version to be installed with: +> ``` +> $ cs install scala:{{ site.scala-version }} scalac:{{ site.scala-version }} +> ``` + +### ...or manually + +You only need two tools to compile, run, test, and package a Scala project: Java 8 or 11, +and sbt. +To install them manually: + +1. if you don't have Java 8 or 11 installed, download + Java from [Oracle Java 8](https://www.oracle.com/java/technologies/javase-jdk8-downloads.html), [Oracle Java 11](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html), + or [AdoptOpenJDK 8/11](https://adoptopenjdk.net/). Refer to [JDK Compatibility](/overviews/jdk-compatibility/overview.html) for Scala/Java compatibility detail. +1. Install [sbt](https://www.scala-sbt.org/download.html) + +## Create a "Hello World" project with sbt + +Once you have installed sbt, you are ready to create a Scala project, which +is explained in the following sections. + +To create a project, you can either use the command line or an IDE. +If you are familiar with the command line, we recommend that approach. + +### Using the command line + +sbt is a build tool for Scala. sbt compiles, runs, +and tests your Scala code. (It can also publish libraries and do many other tasks.) + +To create a new Scala project with sbt: + +1. `cd` to an empty folder. +1. Run the command `sbt new scala/scala3.g8` to create a Scala 3 project, or `sbt new scala/hello-world.g8` to create a Scala 2 project. + This pulls a project template from GitHub. + It will also create a `target` folder, which you can ignore. +1. When prompted, name the application `hello-world`. This will + create a project called "hello-world". +1. Let's take a look at what just got generated: + +``` +- hello-world + - project (sbt uses this for its own files) + - build.properties + - build.sbt (sbt's build definition file) + - src + - main + - scala (all of your Scala code goes here) + - Main.scala (Entry point of program) <-- this is all we need for now +``` + +More documentation about sbt can be found in the [Scala Book](/scala3/book/tools-sbt.html) (see [here](/overviews/scala-book/scala-build-tool-sbt.html) for the Scala 2 version) +and in the official sbt [documentation](https://www.scala-sbt.org/1.x/docs/index.html) + +### With an IDE + +You can skip the rest of this page and go directly to [Building a Scala Project with IntelliJ and sbt](/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.html) + + +## Open hello-world project + +Let's use an IDE to open the project. The most popular ones are IntelliJ and VSCode. +They both offer rich IDE features, but you can still use [many other editors.](https://scalameta.org/metals/docs/editors/overview.html) + +### Using IntelliJ + +1. Download and install [IntelliJ Community Edition](https://www.jetbrains.com/idea/download/) +1. Install the Scala plugin by following [the instructions on how to install IntelliJ plugins](https://www.jetbrains.com/help/idea/managing-plugins.html) +1. Open the `build.sbt` file then choose *Open as a project* + +### Using VSCode with metals + +1. Download [VSCode](https://code.visualstudio.com/Download) +1. Install the Metals extension from [the Marketplace](https://marketplace.visualstudio.com/items?itemName=scalameta.metals) +1. Next, open the directory containing a `build.sbt` file (this should be the directory `hello-world` if you followed the previous instructions). When prompted to do so, select *Import build*. + +>[Metals](https://scalameta.org/metals) is a “Scala language server” that provides support for writing Scala code in VS Code and other editors like [Atom, Sublime Text, and more](https://scalameta.org/metals/docs/editors/overview.html), using the Language Server Protocol. +> +> Under the hood, Metals communicates with the build tool by using +> the [Build Server Protocol (BSP)](https://build-server-protocol.github.io/). For details on how Metals works, see, [“Write Scala in VS Code, Vim, Emacs, Atom and Sublime Text with Metals”](https://www.scala-lang.org/2019/04/16/metals.html). + +### Play with the source code + +View these two files in your IDE: + +- _build.sbt_ +- _src/main/scala/Main.scala_ + +When you run your project in the next step, the configuration in _build.sbt_ will be used to run the code in _src/main/scala/Main.scala_. + +## Run Hello World + +If you’re comfortable using your IDE, you can run the code in _Main.scala_ from your IDE. + +Otherwise, you can run the application from a terminal with these steps: + +1. `cd` into `hello-world`. +1. Run `sbt`. This opens up the sbt console. +1. Type `~run`. The `~` is optional and causes sbt to re-run on every file save, + allowing for a fast edit/run/debug cycle. sbt will also generate a `target` directory + which you can ignore. + +When you’re finished experimenting with this project, press `[Enter]` to interrupt the `run` command. +Then type `exit` or press `[Ctrl+D]` to exit sbt and return to your command line prompt. + +## Next Steps + +Once you've finished the above tutorials, consider checking out: + +* [The Scala Book](/scala3/book/introduction.html) (see the Scala 2 version [here](/overviews/scala-book/introduction.html)), which provides a set of short lessons introducing Scala’s main features. +* [The Tour of Scala](/tour/tour-of-scala.html) for bite-sized introductions to Scala's features. +* [Learning Resources](/learn.html), which includes online interactive tutorials and courses. +* [Our list of some popular Scala books](/books.html). +* [The migration guide](/scala3/guides/migration/compatibility-intro.html) helps you to migrate your existing Scala 2 code base to Scala 3. + +## Getting Help +There are a multitude of mailing lists and real-time chat rooms in case you want to quickly connect with other Scala users. Check out our [community](https://scala-lang.org/community/) page for a list of these resources, and for where to reach out for help. From 79e2f5a4b4257b88082b424266e827de796737d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC?= Date: Mon, 5 Sep 2022 19:28:40 +0300 Subject: [PATCH 02/13] Add getting-started in russian --- _ru/_getting-started/index.md | 77 ++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/_ru/_getting-started/index.md b/_ru/_getting-started/index.md index e365fa7553..d66caea61b 100644 --- a/_ru/_getting-started/index.md +++ b/_ru/_getting-started/index.md @@ -26,29 +26,33 @@ newcomer_resources: {% endaltDetails %} -## Resources For Newcomers +## Ресурсы для новичков {% include inner-documentation-sections.html links=page.newcomer_resources %} -## Install Scala on your computer +## Установка Scala на компьютер -Installing Scala means installing various command-line tools such as the Scala compiler and build tools. -We recommend using the Scala installer tool "Coursier" that automatically installs all the requirements, but you can still manually install each tool. +Установка Scala означает установку различных инструментов командной строки, +таких как компилятор Scala и инструменты сборки. +Мы рекомендуем использовать инструмент установки "Coursier", +который автоматически устанавливает все зависимости, +но также возможно по отдельности установить каждый инструмент вручную. -### Using the Scala Installer (recommended way) +### Использование Scala Installer (рекомендованный путь) -The Scala installer is a tool named [Coursier](https://get-coursier.io/docs/cli-overview), whose main command is named `cs`. -It ensures that a JVM and standard Scala tools are installed on your system. -Install it on your system with the following instructions. +Установщик Scala — это инструмент [Coursier](https://get-coursier.io/docs/cli-overview), +основная команда которого называется `cs`. +Он гарантирует, что в системе установлены JVM и стандартные инструменты Scala. +Установите его в своей системе, следуя следующим инструкциям. {% tabs install-cs-setup-tabs class=platform-os-options %} {% tab macOS for=install-cs-setup-tabs %} -Run the following command in your terminal, following the on-screen instructions: +Запустите в терминале следующую команду, следуя инструкциям на экране: {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-brew %} -{% altDetails cs-setup-macos-nobrew "Alternatively, if you don't use Homebrew:" %} +{% altDetails cs-setup-macos-nobrew "В качестве альтернативы, если вы не используете Homebrew:" %} {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-default %} {% endaltDetails %} {% endtab %} @@ -56,25 +60,25 @@ Run the following command in your terminal, following the on-screen instructions {% tab Linux for=install-cs-setup-tabs %} - Run the following command in your terminal, following the on-screen instructions: + Запустите в терминале следующую команду, следуя инструкциям на экране: {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.linux %} {% endtab %} {% tab Windows for=install-cs-setup-tabs %} - Download and execute [the Scala installer for Windows]({{site.data.setup-scala.windows-link}}) - based on Coursier, and follow the on-screen instructions. + Загрузите и запустите [установщик Scala для Windows]({{site.data.setup-scala.windows-link}}) + на базе Coursier и следуйте инструкциям на экране. {% endtab %} -{% tab Other for=install-cs-setup-tabs defaultTab %} +{% tab Иное for=install-cs-setup-tabs defaultTab %} - Follow the documentation from Coursier on - [how to install and run `cs setup`](https://get-coursier.io/docs/cli-installation). + Следуйте документации Coursier о том, + [как установить и запустить `cs setup`](https://get-coursier.io/docs/cli-installation). {% endtab %} @@ -82,36 +86,35 @@ Run the following command in your terminal, following the on-screen instructions -{% altDetails testing-your-setup 'Testing your setup' %} -Check your setup with the command `scala -version`, which should output: +{% altDetails testing-your-setup 'Тестирование установки' %} +Проверьте корректность установки с помощью команды `scala -version`, которая должна вывести: ```bash $ scala -version Scala code runner version {{site.scala-3-version}} -- Copyright 2002-2022, LAMP/EPFL ``` -If that does not work, you may need to log out and log back in (or reboot) in order for the changes to take effect. +Если сообщение не выдано, вам может потребоваться перезайти в терминал (или перезагрузиться), +чтобы изменения вступили в силу. {% endaltDetails %} +Наряду с JVM `cs setup` также устанавливает полезные инструменты командной строки: -Along with managing JVMs, `cs setup` also installs useful command-line tools: +| Commands | Description | +|---------------|--------------------------------------------------------------------------------------| +| `scalac` | компилятор Scala | +| `scala` | Scala REPL и средство запуска сценариев | +| `scala-cli` | [Scala CLI](https://scala-cli.virtuslab.org), интерактивный инструментарий для Scala | +| `sbt`, `sbtn` | Инструмент сборки [sbt](https://www.scala-sbt.org/) | +| `amm` | [Ammonite](https://ammonite.io/) — улучшенный REPL | +| `scalafmt` | [Scalafmt](https://scalameta.org/scalafmt/) - средство форматирования кода Scala | -| Commands | Description | -|----------|-------------| -| `scalac` | the Scala compiler | -| `scala` | the Scala REPL and script runner | -| `scala-cli`| [Scala CLI](https://scala-cli.virtuslab.org), interactive toolkit for Scala | -| `sbt`, `sbtn` | The [sbt](https://www.scala-sbt.org/) build tool | -| `amm` | [Ammonite](https://ammonite.io/) is an enhanced REPL | -| `scalafmt` | [Scalafmt](https://scalameta.org/scalafmt/) is the Scala code formatter | +Дополнительная информация о cs [доступна по ссылке](https://get-coursier.io/docs/cli-overview). -For more information about `cs`, read -[coursier-cli documentation](https://get-coursier.io/docs/cli-overview). - -> `cs setup` installs the Scala 3 compiler and runner by default (the `scalac` and -> `scala` commands, respectively). Whether you intend to use Scala 2 or 3, -> this is usually not an issue because most projects use a build tool that will -> use the correct version of Scala irrespective of the one installed "globally". -> Nevertheless, you can always launch a specific version of Scala using +> `cs setup` по умолчанию устанавливает компилятор и исполняющую программу Scala 3 +> (команды `scalac` и `scala` соответственно). Независимо от того, собираетесь ли вы использовать Scala 2 или 3, +> обычно это не проблема, потому что в большинстве проектов используется инструмент сборки, +> который будет использовать правильную версию Scala независимо от того, какая версия установлена "глобально". +> Тем не менее, вы всегда можете запустить конкретную версию Scala, используя > ``` > $ cs launch scala:{{ site.scala-version }} > $ cs launch scalac:{{ site.scala-version }} @@ -121,7 +124,7 @@ For more information about `cs`, read > $ cs install scala:{{ site.scala-version }} scalac:{{ site.scala-version }} > ``` -### ...or manually +### ...или вручную You only need two tools to compile, run, test, and package a Scala project: Java 8 or 11, and sbt. From 9d3c0477a16feec5f97d753e4b60a013357299e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC?= Date: Tue, 6 Sep 2022 09:25:57 +0300 Subject: [PATCH 03/13] Add getting-started in russian --- .../building-a-scala-project-with-intellij-and-sbt.md | 2 +- .../intellij-track/getting-started-with-scala-in-intellij.md | 2 +- .../intellij-track/testing-scala-in-intellij-with-scalatest.md | 2 +- .../getting-started-with-scala-and-sbt-on-the-command-line.md | 2 +- .../sbt-track/testing-scala-with-sbt-on-the-command-line.md | 2 +- _ru/index.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/_getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md b/_getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md index c335e94af2..32c76a97c5 100644 --- a/_getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md +++ b/_getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md @@ -2,7 +2,7 @@ title: Building a Scala Project with IntelliJ and sbt layout: singlepage-overview partof: building-a-scala-project-with-intellij-and-sbt -languages: [ja, uk] +languages: [ja, ru, uk] disqus: true previous-page: getting-started/intellij-track/getting-started-with-scala-in-intellij next-page: testing-scala-in-intellij-with-scalatest diff --git a/_getting-started/intellij-track/getting-started-with-scala-in-intellij.md b/_getting-started/intellij-track/getting-started-with-scala-in-intellij.md index cc7eb73add..1e0f1d685c 100644 --- a/_getting-started/intellij-track/getting-started-with-scala-in-intellij.md +++ b/_getting-started/intellij-track/getting-started-with-scala-in-intellij.md @@ -2,7 +2,7 @@ title: Getting Started with Scala in IntelliJ layout: singlepage-overview partof: getting-started-with-scala-in-intellij -languages: [ja, uk] +languages: [ja, ru, uk] disqus: true next-page: building-a-scala-project-with-intellij-and-sbt diff --git a/_getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md b/_getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md index 1b765824b6..3fbd8cb28a 100644 --- a/_getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md +++ b/_getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md @@ -2,7 +2,7 @@ title: Testing Scala in IntelliJ with ScalaTest layout: singlepage-overview partof: testing-scala-in-intellij-with-scalatest -languages: [ja, uk] +languages: [ja, ru, uk] disqus: true previous-page: building-a-scala-project-with-intellij-and-sbt diff --git a/_getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.md b/_getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.md index 46734762d9..c977031737 100644 --- a/_getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.md +++ b/_getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.md @@ -2,7 +2,7 @@ title: Getting Started with Scala and sbt on the Command Line layout: singlepage-overview partof: getting-started-with-scala-and-sbt-on-the-command-line -languages: [ja, uk] +languages: [ja, ru, uk] disqus: true next-page: testing-scala-with-sbt-on-the-command-line diff --git a/_getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md b/_getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md index 6a2db51a93..9a446b1c76 100644 --- a/_getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md +++ b/_getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md @@ -2,7 +2,7 @@ title: Testing Scala with sbt and ScalaTest on the Command Line layout: singlepage-overview partof: testing-scala-with-sbt-on-the-command-line -languages: [ja, uk] +languages: [ja, ru, uk] disqus: true previous-page: getting-started-with-scala-and-sbt-on-the-command-line diff --git a/_ru/index.md b/_ru/index.md index dcb6f28eb4..9cb99c58df 100644 --- a/_ru/index.md +++ b/_ru/index.md @@ -14,7 +14,7 @@ sections: - title: "Самое начало" description: "Установка Scala на ваш компьютер и написание пробного Scala кода!" icon: "fa fa-rocket" - link: /getting-started.html + link: /ru/getting-started.html - title: "Тур по Scala" description: "Вступительный обзор по основным возможностям языка." icon: "fa fa-flag" From 59dec68d9f4d6f3c6f7988b611367d7abb048885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC?= Date: Thu, 8 Sep 2022 08:56:15 +0300 Subject: [PATCH 04/13] Add getting-started in russian --- _ru/_getting-started/index.md | 237 --------------------------------- _ru/getting-started/index.md | 243 ++++++++++++++++++++++++++++++++++ 2 files changed, 243 insertions(+), 237 deletions(-) delete mode 100644 _ru/_getting-started/index.md create mode 100644 _ru/getting-started/index.md diff --git a/_ru/_getting-started/index.md b/_ru/_getting-started/index.md deleted file mode 100644 index d66caea61b..0000000000 --- a/_ru/_getting-started/index.md +++ /dev/null @@ -1,237 +0,0 @@ ---- -layout: singlepage-overview -title: Начало работы -partof: getting-started -language: ru -includeTOC: true - -newcomer_resources: - - title: Вы пришли с Java? - description: Что нужно знать, чтобы ускорить работу со Scala после первоначального запуска. - icon: "fa fa-coffee" - link: /tutorials/scala-for-java-programmers.html - - title: Scala в браузере - description: > - Чтобы сразу начать экспериментировать со Scala, используйте "Scastie" в своем браузере. - icon: "fa fa-cloud" - link: https://scastie.scala-lang.org/pEBYc5VMT02wAGaDrfLnyw ---- - -Приведенные ниже инструкции охватывают как Scala 3, так и Scala 2. - -
-{% altDetails need-help-info-box 'Нужна помощь?' class=help-info %} -*Если у вас возникли проблемы с настройкой Scala, смело обращайтесь за помощью в канал `#scala-users` -[нашего Discord](https://discord.com/invite/scala).* -{% endaltDetails %} -
- -## Ресурсы для новичков - -{% include inner-documentation-sections.html links=page.newcomer_resources %} - -## Установка Scala на компьютер - -Установка Scala означает установку различных инструментов командной строки, -таких как компилятор Scala и инструменты сборки. -Мы рекомендуем использовать инструмент установки "Coursier", -который автоматически устанавливает все зависимости, -но также возможно по отдельности установить каждый инструмент вручную. - -### Использование Scala Installer (рекомендованный путь) - -Установщик Scala — это инструмент [Coursier](https://get-coursier.io/docs/cli-overview), -основная команда которого называется `cs`. -Он гарантирует, что в системе установлены JVM и стандартные инструменты Scala. -Установите его в своей системе, следуя следующим инструкциям. - - -{% tabs install-cs-setup-tabs class=platform-os-options %} - - -{% tab macOS for=install-cs-setup-tabs %} -Запустите в терминале следующую команду, следуя инструкциям на экране: -{% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-brew %} -{% altDetails cs-setup-macos-nobrew "В качестве альтернативы, если вы не используете Homebrew:" %} - {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-default %} -{% endaltDetails %} -{% endtab %} - - - -{% tab Linux for=install-cs-setup-tabs %} - Запустите в терминале следующую команду, следуя инструкциям на экране: - {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.linux %} -{% endtab %} - - - -{% tab Windows for=install-cs-setup-tabs %} - Загрузите и запустите [установщик Scala для Windows]({{site.data.setup-scala.windows-link}}) - на базе Coursier и следуйте инструкциям на экране. -{% endtab %} - - - -{% tab Иное for=install-cs-setup-tabs defaultTab %} - - Следуйте документации Coursier о том, - [как установить и запустить `cs setup`](https://get-coursier.io/docs/cli-installation). -{% endtab %} - - -{% endtabs %} - - - -{% altDetails testing-your-setup 'Тестирование установки' %} -Проверьте корректность установки с помощью команды `scala -version`, которая должна вывести: -```bash -$ scala -version -Scala code runner version {{site.scala-3-version}} -- Copyright 2002-2022, LAMP/EPFL -``` -Если сообщение не выдано, вам может потребоваться перезайти в терминал (или перезагрузиться), -чтобы изменения вступили в силу. -{% endaltDetails %} - - -Наряду с JVM `cs setup` также устанавливает полезные инструменты командной строки: - -| Commands | Description | -|---------------|--------------------------------------------------------------------------------------| -| `scalac` | компилятор Scala | -| `scala` | Scala REPL и средство запуска сценариев | -| `scala-cli` | [Scala CLI](https://scala-cli.virtuslab.org), интерактивный инструментарий для Scala | -| `sbt`, `sbtn` | Инструмент сборки [sbt](https://www.scala-sbt.org/) | -| `amm` | [Ammonite](https://ammonite.io/) — улучшенный REPL | -| `scalafmt` | [Scalafmt](https://scalameta.org/scalafmt/) - средство форматирования кода Scala | - -Дополнительная информация о cs [доступна по ссылке](https://get-coursier.io/docs/cli-overview). - -> `cs setup` по умолчанию устанавливает компилятор и исполняющую программу Scala 3 -> (команды `scalac` и `scala` соответственно). Независимо от того, собираетесь ли вы использовать Scala 2 или 3, -> обычно это не проблема, потому что в большинстве проектов используется инструмент сборки, -> который будет использовать правильную версию Scala независимо от того, какая версия установлена "глобально". -> Тем не менее, вы всегда можете запустить конкретную версию Scala, используя -> ``` -> $ cs launch scala:{{ site.scala-version }} -> $ cs launch scalac:{{ site.scala-version }} -> ``` -> If you prefer Scala 2 to be run by default, you can force that version to be installed with: -> ``` -> $ cs install scala:{{ site.scala-version }} scalac:{{ site.scala-version }} -> ``` - -### ...или вручную - -You only need two tools to compile, run, test, and package a Scala project: Java 8 or 11, -and sbt. -To install them manually: - -1. if you don't have Java 8 or 11 installed, download - Java from [Oracle Java 8](https://www.oracle.com/java/technologies/javase-jdk8-downloads.html), [Oracle Java 11](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html), - or [AdoptOpenJDK 8/11](https://adoptopenjdk.net/). Refer to [JDK Compatibility](/overviews/jdk-compatibility/overview.html) for Scala/Java compatibility detail. -1. Install [sbt](https://www.scala-sbt.org/download.html) - -## Create a "Hello World" project with sbt - -Once you have installed sbt, you are ready to create a Scala project, which -is explained in the following sections. - -To create a project, you can either use the command line or an IDE. -If you are familiar with the command line, we recommend that approach. - -### Using the command line - -sbt is a build tool for Scala. sbt compiles, runs, -and tests your Scala code. (It can also publish libraries and do many other tasks.) - -To create a new Scala project with sbt: - -1. `cd` to an empty folder. -1. Run the command `sbt new scala/scala3.g8` to create a Scala 3 project, or `sbt new scala/hello-world.g8` to create a Scala 2 project. - This pulls a project template from GitHub. - It will also create a `target` folder, which you can ignore. -1. When prompted, name the application `hello-world`. This will - create a project called "hello-world". -1. Let's take a look at what just got generated: - -``` -- hello-world - - project (sbt uses this for its own files) - - build.properties - - build.sbt (sbt's build definition file) - - src - - main - - scala (all of your Scala code goes here) - - Main.scala (Entry point of program) <-- this is all we need for now -``` - -More documentation about sbt can be found in the [Scala Book](/scala3/book/tools-sbt.html) (see [here](/overviews/scala-book/scala-build-tool-sbt.html) for the Scala 2 version) -and in the official sbt [documentation](https://www.scala-sbt.org/1.x/docs/index.html) - -### With an IDE - -You can skip the rest of this page and go directly to [Building a Scala Project with IntelliJ and sbt](/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.html) - - -## Open hello-world project - -Let's use an IDE to open the project. The most popular ones are IntelliJ and VSCode. -They both offer rich IDE features, but you can still use [many other editors.](https://scalameta.org/metals/docs/editors/overview.html) - -### Using IntelliJ - -1. Download and install [IntelliJ Community Edition](https://www.jetbrains.com/idea/download/) -1. Install the Scala plugin by following [the instructions on how to install IntelliJ plugins](https://www.jetbrains.com/help/idea/managing-plugins.html) -1. Open the `build.sbt` file then choose *Open as a project* - -### Using VSCode with metals - -1. Download [VSCode](https://code.visualstudio.com/Download) -1. Install the Metals extension from [the Marketplace](https://marketplace.visualstudio.com/items?itemName=scalameta.metals) -1. Next, open the directory containing a `build.sbt` file (this should be the directory `hello-world` if you followed the previous instructions). When prompted to do so, select *Import build*. - ->[Metals](https://scalameta.org/metals) is a “Scala language server” that provides support for writing Scala code in VS Code and other editors like [Atom, Sublime Text, and more](https://scalameta.org/metals/docs/editors/overview.html), using the Language Server Protocol. -> -> Under the hood, Metals communicates with the build tool by using -> the [Build Server Protocol (BSP)](https://build-server-protocol.github.io/). For details on how Metals works, see, [“Write Scala in VS Code, Vim, Emacs, Atom and Sublime Text with Metals”](https://www.scala-lang.org/2019/04/16/metals.html). - -### Play with the source code - -View these two files in your IDE: - -- _build.sbt_ -- _src/main/scala/Main.scala_ - -When you run your project in the next step, the configuration in _build.sbt_ will be used to run the code in _src/main/scala/Main.scala_. - -## Run Hello World - -If you’re comfortable using your IDE, you can run the code in _Main.scala_ from your IDE. - -Otherwise, you can run the application from a terminal with these steps: - -1. `cd` into `hello-world`. -1. Run `sbt`. This opens up the sbt console. -1. Type `~run`. The `~` is optional and causes sbt to re-run on every file save, - allowing for a fast edit/run/debug cycle. sbt will also generate a `target` directory - which you can ignore. - -When you’re finished experimenting with this project, press `[Enter]` to interrupt the `run` command. -Then type `exit` or press `[Ctrl+D]` to exit sbt and return to your command line prompt. - -## Next Steps - -Once you've finished the above tutorials, consider checking out: - -* [The Scala Book](/scala3/book/introduction.html) (see the Scala 2 version [here](/overviews/scala-book/introduction.html)), which provides a set of short lessons introducing Scala’s main features. -* [The Tour of Scala](/tour/tour-of-scala.html) for bite-sized introductions to Scala's features. -* [Learning Resources](/learn.html), which includes online interactive tutorials and courses. -* [Our list of some popular Scala books](/books.html). -* [The migration guide](/scala3/guides/migration/compatibility-intro.html) helps you to migrate your existing Scala 2 code base to Scala 3. - -## Getting Help -There are a multitude of mailing lists and real-time chat rooms in case you want to quickly connect with other Scala users. Check out our [community](https://scala-lang.org/community/) page for a list of these resources, and for where to reach out for help. diff --git a/_ru/getting-started/index.md b/_ru/getting-started/index.md new file mode 100644 index 0000000000..b5c54da05a --- /dev/null +++ b/_ru/getting-started/index.md @@ -0,0 +1,243 @@ +--- +layout: singlepage-overview +title: Начало работы +partof: getting-started +language: ru +includeTOC: true + +newcomer_resources: + - title: Вы пришли с Java? + description: Что нужно знать, чтобы ускорить работу со Scala после первоначального запуска. + icon: "fa fa-coffee" + link: /tutorials/scala-for-java-programmers.html + - title: Scala в браузере + description: > + Чтобы сразу начать экспериментировать со Scala, используйте "Scastie" в своем браузере. + icon: "fa fa-cloud" + link: https://scastie.scala-lang.org/pEBYc5VMT02wAGaDrfLnyw +--- + +Приведенные ниже инструкции охватывают как Scala 3, так и Scala 2. + +
+{% altDetails need-help-info-box 'Нужна помощь?' class=help-info %} +*Если у вас возникли проблемы с настройкой Scala, смело обращайтесь за помощью в канал `#scala-users` +[нашего Discord](https://discord.com/invite/scala).* +{% endaltDetails %} +
+ +## Ресурсы для новичков + +{% include inner-documentation-sections.html links=page.newcomer_resources %} + +## Установка Scala на компьютер + +Установка Scala означает установку различных инструментов командной строки, +таких как компилятор Scala и инструменты сборки. +Мы рекомендуем использовать инструмент установки "Coursier", +который автоматически устанавливает все зависимости, +но также возможно по отдельности установить каждый инструмент вручную. + +### Использование Scala Installer (рекомендованный путь) + +Установщик Scala — это инструмент [Coursier](https://get-coursier.io/docs/cli-overview), +основная команда которого называется `cs`. +Он гарантирует, что в системе установлены JVM и стандартные инструменты Scala. +Установите его в своей системе, следуя следующим инструкциям. + + +{% tabs install-cs-setup-tabs class=platform-os-options %} + + +{% tab macOS for=install-cs-setup-tabs %} +Запустите в терминале следующую команду, следуя инструкциям на экране: +{% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-brew %} +{% altDetails cs-setup-macos-nobrew "В качестве альтернативы, если вы не используете Homebrew:" %} + {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.macOS-default %} +{% endaltDetails %} +{% endtab %} + + + +{% tab Linux for=install-cs-setup-tabs %} + Запустите в терминале следующую команду, следуя инструкциям на экране: + {% include code-snippet.html language='bash' codeSnippet=site.data.setup-scala.linux %} +{% endtab %} + + + +{% tab Windows for=install-cs-setup-tabs %} + Загрузите и запустите [установщик Scala для Windows]({{site.data.setup-scala.windows-link}}) + на базе Coursier и следуйте инструкциям на экране. +{% endtab %} + + + +{% tab Иное for=install-cs-setup-tabs defaultTab %} + + Следуйте документации Coursier о том, + [как установить и запустить `cs setup`](https://get-coursier.io/docs/cli-installation). +{% endtab %} + + +{% endtabs %} + + + +{% altDetails testing-your-setup 'Тестирование установки' %} +Проверьте корректность установки с помощью команды `scala -version`, которая должна вывести: +```bash +$ scala -version +Scala code runner version {{site.scala-3-version}} -- Copyright 2002-2022, LAMP/EPFL +``` +Если сообщение не выдано, возможно, необходимо перезайти в терминал (или перезагрузиться), +чтобы изменения вступили в силу. +{% endaltDetails %} + + +Наряду с JVM `cs setup` также устанавливает полезные инструменты командной строки: + +| Commands | Description | +|---------------|--------------------------------------------------------------------------------------| +| `scalac` | компилятор Scala | +| `scala` | Scala REPL и средство запуска сценариев | +| `scala-cli` | [Scala CLI](https://scala-cli.virtuslab.org), интерактивный инструментарий для Scala | +| `sbt`, `sbtn` | Инструмент сборки [sbt](https://www.scala-sbt.org/) | +| `amm` | [Ammonite](https://ammonite.io/) — улучшенный REPL | +| `scalafmt` | [Scalafmt](https://scalameta.org/scalafmt/) - средство форматирования кода Scala | + +Дополнительная информация о cs [доступна по ссылке](https://get-coursier.io/docs/cli-overview). + +> `cs setup` по умолчанию устанавливает компилятор и исполняющую программу Scala 3 +> (команды `scalac` и `scala` соответственно). Независимо от того, собираетесь ли вы использовать Scala 2 или 3, +> обычно это не проблема, потому что в большинстве проектов используется инструмент сборки, +> который будет использовать правильную версию Scala независимо от того, какая версия установлена "глобально". +> Тем не менее, вы всегда можете запустить конкретную версию Scala, используя +> ``` +> $ cs launch scala:{{ site.scala-version }} +> $ cs launch scalac:{{ site.scala-version }} +> ``` +> Если предпочтительно, чтобы по умолчанию запускалась Scala 2, вы можете принудительно установить эту версию с помощью: +> ``` +> $ cs install scala:{{ site.scala-version }} scalac:{{ site.scala-version }} +> ``` + +### ...или вручную + +Для компиляции, запуска, тестирования и упаковки проекта Scala нужны только два инструмента: +Java 8 или 11 и sbt. +Чтобы установить их вручную: + +1. если не установлена Java 8 или 11, загрузите Java из + [Oracle Java 8](https://www.oracle.com/java/technologies/javase-jdk8-downloads.html), [Oracle Java 11](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html), + или [AdoptOpenJDK 8/11](https://adoptopenjdk.net/). + Подробную информацию о совместимости Scala/Java см. в разделе [Совместимость с JDK](/overviews/jdk-compatibility/overview.html). +1. установить [sbt](https://www.scala-sbt.org/download.html) + +## Создание проекта "Hello World" с помощью sbt + +В следующих разделах объясняется как создавать проект Scala после того, как установлен sbt. + +Для создания проекта можно использовать командную строку или IDE. +Если вы знакомы с командной строкой, мы рекомендуем этот подход. + +### Использование командной строки + +sbt — это инструмент сборки для Scala. sbt компилирует, запускает и тестирует Scala код +(он также может публиковать библиотеки и выполнять множество других задач). + +Чтобы создать новый проект Scala с помощью sbt: + +1. `cd` в пустую папку. +1. Запустите команду `sbt new scala/scala3.g8`, чтобы создать проект на Scala 3, + или `sbt new scala/hello-world.g8` для создания проекта на Scala 2. + Она извлекает шаблон проекта из GitHub. + Эта команда также создает папку `target`, которую вы можете игнорировать. +1. При появлении запроса назовите приложение `hello-world`. + Это создаст проект под названием "hello-world". +1. Будет сгенерировано следующее: + +``` +- hello-world + - project (sbt использует эту папку для собственных файлов) + - build.properties + - build.sbt (файл определения сборки sbt) + - src + - main + - scala (здесь весь Scala code) + - Main.scala (точка входа в программу) <-- это все, что сейчас нужно +``` + +Дополнительную документацию по sbt можно найти в [Scala Book](/scala3/book/tools-sbt.html) +(см. [здесь](/overviews/scala-book/scala-build-tool-sbt.html) для версии Scala 2) +и в официальной [документации sbt](https://www.scala-sbt.org/1.x/docs/index.html). + +### С интегрированной средой разработки (IDE) + +Вы можете пропустить оставшуюся часть страницы и сразу перейти к [созданию проекта Scala с помощью IntelliJ и sbt](/ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.html). + + +## Открыть проект hello-world + +Давайте используем IDE, чтобы открыть проект. Самые популярные из них — IntelliJ и VSCode. +Оба предлагают обширные возможности, но вы по-прежнему можете использовать [множество других редакторов](https://scalameta.org/metals/docs/editors/overview.html). + + +### Использование IntelliJ + +1. Загрузите и установите [IntelliJ Community Edition](https://www.jetbrains.com/idea/download/) +1. Установите Scala plugin, следуя [инструкциям по установке плагинов IntelliJ](https://www.jetbrains.com/help/idea/managing-plugins.html) +1. Откройте файл `build.sbt`, затем выберете *Open as a project* + +### Использование VSCode с metals + +1. Загрузите [VSCode](https://code.visualstudio.com/Download) +1. Установите расширение Metals из [Marketplace](https://marketplace.visualstudio.com/items?itemName=scalameta.metals) +1. Затем откройте каталог, содержащий файл `build.sbt` (это должен быть каталог `hello-world`, если вы следовали предыдущим инструкциям). Когда будет предложено, выберите *Import build*. + +> [Metals](https://scalameta.org/metals) — это “языковой сервер Scala”, обеспечивающий поддержку написания кода Scala в VS Code и других редакторах, +> таких как [Atom, Sublime Text и других](https://scalameta.org/metals/docs/editors/overview.html), использующих Language Server Protocol. +> +> Под капотом Metals взаимодействует со средством сборки с помощью +> [Build Server Protocol (BSP)](https://build-server-protocol.github.io/). +> Подробнее о том, как работает Metals, см. [“Написание Scala в VS Code, Vim, Emacs, Atom и Sublime Text с помощью Metals”](https://www.scala-lang.org/2019/04/16/metals.html). + +### Знакомство с исходным кодом + +Просмотрите эти два файла в своей IDE: + +- _build.sbt_ +- _src/main/scala/Main.scala_ + +При запуске проекта на следующем шаге, конфигурация в _build.sbt_ будет использована для запуска кода в _src/main/scala/Main.scala_. + +## Запуск Hello World + +Код в _Main.scala_ можно запускать из IDE, если удобно. + +Но также вы можете запустить приложение из терминала, выполнив следующие действия: + +1. `cd` в `hello-world`. +1. Запустить `sbt`. Эта команда открывает sbt-консоль. +1. В консоле введите `~run`. `~` является необязательным, но заставляет sbt повторно запускаться при каждом сохранении файла, + обеспечивая быстрый цикл редактирования/запуска/отладки. sbt также создаст директорию `target`, которую пока можно игнорировать. + +После окончания экспериментирования с проектом, нажмите `[Enter]`, чтобы прервать команду `run`. +Затем введите `exit` или нажмите `[Ctrl+D]`, чтобы выйти из sbt и вернуться в командную строку. + +## Следующие шаги + +После того как пройдете приведенные выше обучающие материалы, подумайте о том, чтобы проверить: + +* [The Scala Book](/scala3/book/introduction.html) (см. версию для Scala 2 [здесь](/overviews/scala-book/introduction.html)), которая содержит набор коротких уроков, знакомящих с основными функциями Scala. +* [The Tour of Scala](/tour/tour-of-scala.html) для краткого ознакомления с функциями Scala. +* [Обучающие ресурсы](/learn.html), которые включают в себя интерактивные онлайн-учебники и курсы. +* [Наш список некоторых популярных книг по Scala](/books.html). +* [Руководство по миграции](/scala3/guides/migration/compatibility-intro.html) поможет перенести существующую кодовую базу Scala 2 на Scala 3. + +## Получение помощи + +Существует множество рассылок и real-time чатов на случай, если вы хотите быстро связаться с другими пользователями Scala. +Посетите страницу [нашего сообщества](https://scala-lang.org/community/), чтобы ознакомиться со списком этих ресурсов и узнать, куда можно обратиться за помощью. From ee9bfa20cb737821f394625c798130a2ac29f7f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC?= Date: Thu, 8 Sep 2022 09:15:13 +0300 Subject: [PATCH 05/13] Add getting-started in russian --- _ru/getting-started/index.md | 4 +- ...g-a-scala-project-with-intellij-and-sbt.md | 109 ++++++++++++++++ .../getting-started-with-scala-in-intellij.md | 119 ++++++++++++++++++ ...esting-scala-in-intellij-with-scalatest.md | 79 ++++++++++++ ...-with-scala-and-sbt-on-the-command-line.md | 115 +++++++++++++++++ ...ting-scala-with-sbt-on-the-command-line.md | 107 ++++++++++++++++ 6 files changed, 531 insertions(+), 2 deletions(-) create mode 100644 _ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md create mode 100644 _ru/getting-started/intellij-track/getting-started-with-scala-in-intellij.md create mode 100644 _ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md create mode 100644 _ru/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.md create mode 100644 _ru/getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md diff --git a/_ru/getting-started/index.md b/_ru/getting-started/index.md index b5c54da05a..dab45082ea 100644 --- a/_ru/getting-started/index.md +++ b/_ru/getting-started/index.md @@ -217,7 +217,7 @@ sbt — это инструмент сборки для Scala. sbt компил Код в _Main.scala_ можно запускать из IDE, если удобно. -Но также вы можете запустить приложение из терминала, выполнив следующие действия: +Но вы также можете запустить приложение из терминала, выполнив следующие действия: 1. `cd` в `hello-world`. 1. Запустить `sbt`. Эта команда открывает sbt-консоль. @@ -232,7 +232,7 @@ sbt — это инструмент сборки для Scala. sbt компил После того как пройдете приведенные выше обучающие материалы, подумайте о том, чтобы проверить: * [The Scala Book](/scala3/book/introduction.html) (см. версию для Scala 2 [здесь](/overviews/scala-book/introduction.html)), которая содержит набор коротких уроков, знакомящих с основными функциями Scala. -* [The Tour of Scala](/tour/tour-of-scala.html) для краткого ознакомления с функциями Scala. +* [The Tour of Scala](/ru/tour/tour-of-scala.html) для краткого ознакомления с функциями Scala. * [Обучающие ресурсы](/learn.html), которые включают в себя интерактивные онлайн-учебники и курсы. * [Наш список некоторых популярных книг по Scala](/books.html). * [Руководство по миграции](/scala3/guides/migration/compatibility-intro.html) поможет перенести существующую кодовую базу Scala 2 на Scala 3. diff --git a/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md b/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md new file mode 100644 index 0000000000..b73d8faeb0 --- /dev/null +++ b/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md @@ -0,0 +1,109 @@ +--- +title: Создание проекта Scala с IntelliJ и sbt +layout: singlepage-overview +partof: building-a-scala-project-with-intellij-and-sbt +language: ru +disqus: true +previous-page: /ru/getting-started/intellij-track/getting-started-with-scala-in-intellij +next-page: /ru/testing-scala-in-intellij-with-scalatest +--- + +In this tutorial, we'll see how to build a Scala project using [sbt](https://www.scala-sbt.org/1.x/docs/index.html). sbt is a popular tool for compiling, running, and testing Scala projects of any +size. Using a build tool such as sbt (or Maven/Gradle) becomes essential once you create projects with dependencies +or more than one code file. + We assume you've completed the +[first tutorial](getting-started-with-scala-in-intellij.html). + +## Creating the project +In this section, we'll show you how to create the project in IntelliJ. However, if you're +comfortable with the command line, we recommend you try [Getting +Started with Scala and sbt on the Command Line]({{site.baseurl}}/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.html) and then come back + here to the section "Writing Scala code". + +1. If you didn't create the project from the command line, open up IntelliJ and select "Create New Project" + * On the left panel, select Scala and on the right panel, select sbt + * Click **Next** + * Name the project "SbtExampleProject" +1. If you already created the project on the command line, open up IntelliJ, select *Import Project* and open the `build.sbt` file for your project +1. Make sure the **JDK version** is 1.8 and the **sbt version** is at least 0.13.13 +1. Select **Use auto-import** so dependencies are automatically downloaded when available +1. Select **Finish** + +## Understanding the directory structure +sbt creates many directories which can be useful once you start building +more complex projects. You can ignore most of them for now +but here's a glance at what everything is for: + +``` +- .idea (IntelliJ files) +- project (plugins and additional settings for sbt) +- src (source files) + - main (application code) + - java (Java source files) + - scala (Scala source files) <-- This is all we need for now + - scala-2.12 (Scala 2.12 specific files) + - test (unit tests) +- target (generated files) +- build.sbt (build definition file for sbt) +``` + + +## Writing Scala code +1. On the **Project** panel on the left, expand `SbtExampleProject` => `src` +=> `main` +1. Right-click `scala` and select **New** => **Package** +1. Name the package `example` and click **OK** (or just press the Enter or Return key). +1. Right-click the package `example` and select **New** => **Scala class** (if you don't see this option, right-click the `SbtExampleProject`, click **Add Frameworks Support**, select **Scala** and proceed) +1. Name the class `Main` and change the **Kind** to `Object`. +1. Change the code in the class to the following: + +``` +object Main extends App { + val ages = Seq(42, 75, 29, 64) + println(s"The oldest person is ${ages.max}") +} +``` + +Note: IntelliJ has its own implementation of the Scala compiler, and sometimes your +code is correct even though IntelliJ indicates otherwise. You can always check +to see if sbt can run your project on the command line. + +## Running the project +1. From the **Run** menu, select **Edit configurations** +1. Click the **+** button and select **sbt Task**. +1. Name it `Run the program`. +1. In the **Tasks** field, type `~run`. The `~` causes sbt to rebuild and rerun the project +when you save changes to a file in the project. +1. Click **OK**. +1. On the **Run** menu. Click **Run 'Run the program'**. +1. In the code, change `75` to `61` +and look at the updated output in the console. + +## Adding a dependency +Changing gears a bit, let's look at how to use published libraries to add +extra functionality to our apps. +1. Open up `build.sbt` and add the following line: + +``` +libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2" +``` +Here, `libraryDependencies` is a set of dependencies, and by using `+=`, +we're adding the [scala-parser-combinators](https://github.com/scala/scala-parser-combinators) dependency to the set of dependencies that sbt will go +and fetch when it starts up. Now, in any Scala file, you can import classes, +objects, etc, from scala-parser-combinators with a regular import. + +You can find more published libraries on +[Scaladex](https://index.scala-lang.org/), the Scala library index, where you +can also copy the above dependency information for pasting into your `build.sbt` +file. + +## Next steps + +Continue to the next tutorial in the _getting started with IntelliJ_ series, and learn about [testing Scala code in IntelliJ with ScalaTest](testing-scala-in-intellij-with-scalatest.html). + +**or** + +* [The Scala Book](/overviews/scala-book/introduction.html), which provides a set of short lessons introducing Scala’s main features. +* [The Tour of Scala](/tour/tour-of-scala.html) for bite-sized introductions to Scala's features. +- Continue learning Scala interactively online on + [Scala Exercises](https://www.scala-exercises.org/scala_tutorial). diff --git a/_ru/getting-started/intellij-track/getting-started-with-scala-in-intellij.md b/_ru/getting-started/intellij-track/getting-started-with-scala-in-intellij.md new file mode 100644 index 0000000000..6585987127 --- /dev/null +++ b/_ru/getting-started/intellij-track/getting-started-with-scala-in-intellij.md @@ -0,0 +1,119 @@ +--- +title: Начало работы со Scala в IntelliJ +layout: singlepage-overview +partof: getting-started-with-scala-in-intellij +language: ru +disqus: true +next-page: /ru/building-a-scala-project-with-intellij-and-sbt +--- + +In this tutorial, we'll see how to build a minimal Scala project using IntelliJ +IDE with the Scala plugin. In this guide, IntelliJ will download Scala for you. + +## Installation +1. Make sure you have the Java 8 JDK (also known as 1.8) + * Run `javac -version` on the command line and make sure you see + `javac 1.8.___` + * If you don't have version 1.8 or higher, [install the JDK](https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) +1. Next, download and install [IntelliJ Community Edition](https://www.jetbrains.com/idea/download/) +1. Then, after starting up IntelliJ, you can download and install the Scala plugin by following the instructions on +[how to install IntelliJ plugins](https://www.jetbrains.com/help/idea/installing-updating-and-uninstalling-repository-plugins.html) (search for "Scala" in the plugins menu.) + +When we create the project, we'll install the latest version of Scala. +Note: If you want to open an existing Scala project, you can click **Open** +when you start IntelliJ. + +## Creating the Project +1. Open up IntelliJ and click **File** => **New** => **Project** +1. On the left panel, select Scala. On the right panel, select IDEA. +1. Name the project **HelloWorld** +1. Assuming this is your first time creating a Scala project with IntelliJ, +you'll need to install a Scala SDK. To the right of the Scala SDK field, +click the **Create** button. +1. Select the highest version number (e.g. {{ site.scala-version }}) and click **Download**. This might +take a few minutes but subsequent projects can use the same SDK. +1. Once the SDK is created, and you're back to the "New Project" window, click **Finish**. + + +## Writing code + +1. On the **Project** pane on the left, right-click `src` and select +**New** => **Scala class**. If you don't see **Scala class**, right-click on **HelloWorld** and click on **Add Framework Support...**, select **Scala** and proceed. If you see **Error: library is not specified**, you can either click download button, or select the library path manually. If you only see **Scala Worksheet** try expanding the `src` folder and its `main` subfolder, and right-click on the `scala` folder. +1. Name the class `Hello` and change the **Kind** to `object`. +1. Change the code in the file to the following: + +{% tabs hello-world-entry-point class=tabs-scala-version %} + +{% tab 'Scala 2' for=hello-world-entry-point %} + +``` +object Hello extends App { + println("Hello, World!") +} +``` + +{% endtab %} + +{% tab 'Scala 3' for=hello-world-entry-point %} + +``` +@main def hello(): Unit = + println("Hello, World!") +``` + +In Scala 3, you can remove the object `Hello` and define a top-level method +`hello` instead, which you annotate with `@main`. + +{% endtab %} + +{% endtabs %} + +## Running it + +{% tabs hello-world-run class=tabs-scala-version %} + +{% tab 'Scala 2' for=hello-world-run %} + +* Right click on `Hello` in your code and select **Run 'Hello'**. +* You're done! + +{% endtab %} + +{% tab 'Scala 3' for=hello-world-run %} + +* Right click on `hello` in your code and select **Run 'hello'**. +* You're done! + +{% endtab %} + +{% endtabs %} + +## Experimenting with Scala +A good way to try out code samples is with Scala Worksheets + +1. In the project pane on the left, right click +`src` and select **New** => **Scala Worksheet**. +2. Name your new Scala worksheet "Mathematician". +3. Enter the following code into the worksheet: + +{% tabs square %} +{% tab 'Scala 2 and 3' for=square %} +``` +def square(x: Int): Int = x * x + +square(2) +``` +{% endtab %} +{% endtabs %} + +As you change your code, you'll notice that it gets evaluated +in the right pane. If you do not see a right pane, right-click on your Scala worksheet in the Project pane, and click on Evaluate Worksheet. + +## Next Steps + +Now you know how to create a simple Scala project which can be used +for starting to learn the language. In the next tutorial, we'll introduce +an important build tool called sbt which can be used for simple projects +and production apps. + +Up Next: [Building a Scala Project with IntelliJ and sbt](building-a-scala-project-with-intellij-and-sbt.html) diff --git a/_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md b/_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md new file mode 100644 index 0000000000..ca2b961ee7 --- /dev/null +++ b/_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md @@ -0,0 +1,79 @@ +--- +title: Тестирование Scala в IntelliJ с помощью ScalaTest +layout: singlepage-overview +partof: testing-scala-in-intellij-with-scalatest +language: ru +disqus: true +previous-page: /ru/building-a-scala-project-with-intellij-and-sbt +--- + +There are multiple libraries and testing methodologies for Scala, +but in this tutorial, we'll demonstrate one popular option from the ScalaTest framework +called [FunSuite](https://www.scalatest.org/getting_started_with_fun_suite). + +This assumes you know [how to build a project in IntelliJ](building-a-scala-project-with-intellij-and-sbt.html). + +## Setup +1. Create an sbt project in IntelliJ. +1. Add the ScalaTest dependency: + 1. Add the ScalaTest dependency to your `build.sbt` file: + ``` + libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.11" % Test + ``` + 1. If you get a notification "build.sbt was changed", select **auto-import**. + 1. These two actions will cause `sbt` to download the ScalaTest library. + 1. Wait for the `sbt` sync to finish; otherwise, `AnyFunSuite` and `test()` will be + unrecognized. +1. On the project pane on the left, expand `src` => `main`. +1. Right-click on `scala` and select **New** => **Scala class**. +1. Call it `CubeCalculator`, change the **Kind** to `object`, and hit enter or double-click on `object`. +1. Replace the code with the following: + ``` + object CubeCalculator extends App { + def cube(x: Int) = { + x * x * x + } + } + ``` + +## Creating a test +1. On the project pane on the left, expand `src` => `test`. +1. Right-click on `scala` and select **New** => **Scala class**. +1. Name the class `CubeCalculatorTest` and hit enter or double-click on `class`. +1. Replace the code with the following: + ``` + import org.scalatest.funsuite.AnyFunSuite + + class CubeCalculatorTest extends AnyFunSuite { + test("CubeCalculator.cube") { + assert(CubeCalculator.cube(3) === 27) + } + } + ``` +1. In the source code, right-click `CubeCalculatorTest` and select + **Run 'CubeCalculatorTest'**. + +## Understanding the code + +Let's go over this line by line: + +* `class CubeCalculatorTest` means we are testing the object `CubeCalculator` +* `extends AnyFunSuite` lets us use functionality of ScalaTest's AnyFunSuite class +such as the `test` function +* `test` is a function that comes from the FunSuite library that collects +results from assertions within the function body. +* `"CubeCalculator.cube"` is a name for the test. You can call it anything but +one convention is "ClassName.methodName". +* `assert` takes a boolean condition and determines whether the test passes or fails. +* `CubeCalculator.cube(3) === 27` checks whether the output of the `cube` function is +indeed 27. The `===` is part of ScalaTest and provides clean error messages. + +## Adding another test case +1. Add another `assert` statement after the first one that checks for the cube + of `0`. +1. Re-run the test again by right-clicking `CubeCalculatorTest` and selecting + 'Run **CubeCalculatorTest**'. + +## Conclusion +You've seen one way to test your Scala code. You can learn more about ScalaTest's +FunSuite on the [official website](https://www.scalatest.org/getting_started_with_fun_suite). diff --git a/_ru/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.md b/_ru/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.md new file mode 100644 index 0000000000..99fbbfc27e --- /dev/null +++ b/_ru/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.md @@ -0,0 +1,115 @@ +--- +title: Начало работы со Scala и sbt в командной строке +layout: singlepage-overview +partof: getting-started-with-scala-and-sbt-on-the-command-line +language: ru +disqus: true +next-page: /ru/testing-scala-with-sbt-on-the-command-line +--- + +In this tutorial, you'll see how to create a Scala project from +a template. You can use this as a starting point for your own +projects. We'll use [sbt](https://www.scala-sbt.org/1.x/docs/index.html), the de facto build tool for Scala. sbt compiles, +runs, and tests your projects among other related tasks. +We assume you know how to use a terminal. + +## Installation +1. Make sure you have the Java 8 JDK (also known as 1.8) + * Run `javac -version` in the command line and make sure you see + `javac 1.8.___` + * If you don't have version 1.8 or higher, [install the JDK](https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) +1. Install sbt + * [Mac](https://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Mac.html) + * [Windows](https://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Windows.html) + * [Linux](https://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Linux.html) + +## Create the project + +{% tabs sbt-welcome-1 class=tabs-scala-version %} +{% tab 'Scala 2' for=sbt-welcome-1 %} + +1. `cd` to an empty folder. +1. Run the following command `sbt new scala/hello-world.g8`. +This pulls the 'hello-world' template from GitHub. +It will also create a `target` folder, which you can ignore. +1. When prompted, name the application `hello-world`. This will +create a project called "hello-world". +1. Let's take a look at what just got generated: + +{% endtab %} +{% tab 'Scala 3' for=sbt-welcome-1 %} + +1. `cd` to an empty folder. +1. Run the following command `sbt new scala/scala3.g8`. +This pulls the 'scala3' template from GitHub. +It will also create a `target` folder, which you can ignore. +1. When prompted, name the application `hello-world`. This will +create a project called "hello-world". +1. Let's take a look at what just got generated: + +{% endtab %} +{% endtabs %} + + +``` +- hello-world + - project (sbt uses this to install and manage plugins and dependencies) + - build.properties + - src + - main + - scala (All of your scala code goes here) + - Main.scala (Entry point of program) <-- this is all we need for now + - build.sbt (sbt's build definition file) +``` + +After you build your project, sbt will create more `target` directories +for generated files. You can ignore these. + +## Running the project +1. `cd` into `hello-world`. +1. Run `sbt`. This will open up the sbt console. +1. Type `~run`. The `~` is optional and causes sbt to re-run on every file save, +allowing for a fast edit/run/debug cycle. sbt will also generate a `target` directory +which you can ignore. + +## Modifying the code +1. Open the file `src/main/scala/Main.scala` in your favorite text editor. +1. Change "Hello, World!" to "Hello, New York!" +1. If you haven't stopped the sbt command, you should see "Hello, New York!" +printed to the console. +1. You can continue to make changes and see the results in the console. + +## Adding a dependency +Changing gears a bit, let's look at how to use published libraries to add +extra functionality to our apps. + +1. Open up `build.sbt` and add the following line: + +``` +libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2" +``` +Here, `libraryDependencies` is a set of dependencies, and by using `+=`, +we're adding the [scala-parser-combinators](https://github.com/scala/scala-parser-combinators) dependency to the set of dependencies that sbt will go +and fetch when it starts up. Now, in any Scala file, you can import classes, +objects, etc, from `scala-parser-combinators` with a regular import. + +You can find more published libraries on +[Scaladex](https://index.scala-lang.org/), the Scala library index, where you +can also copy the above dependency information for pasting into your `build.sbt` +file. + +> **Note for Java Libraries:** For a regular Java library, you should only use one percent (`%`) between the +> organization name and artifact name. Double percent (`%%`) is a specialisation for Scala libraries. +> You can learn more about the reason for this in the [sbt documentation][sbt-docs-lib-dependencies]. + +## Next steps + +Continue to the next tutorial in the _getting started with sbt_ series, and learn about [testing Scala code with sbt in the command line](testing-scala-with-sbt-on-the-command-line.html). + +**or** + +- Continue learning Scala interactively online on + [Scala Exercises](https://www.scala-exercises.org/scala_tutorial). +- Learn about Scala's features in bite-sized pieces by stepping through our [Tour of Scala]({{ site.baseurl }}/tour/tour-of-scala.html). + +[sbt-docs-lib-dependencies]: https://www.scala-sbt.org/1.x/docs/Library-Dependencies.html#Getting+the+right+Scala+version+with diff --git a/_ru/getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md b/_ru/getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md new file mode 100644 index 0000000000..2819efcaa0 --- /dev/null +++ b/_ru/getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md @@ -0,0 +1,107 @@ +--- +title: Тестирование Scala c sbt и ScalaTest в командной строке +layout: singlepage-overview +partof: testing-scala-with-sbt-on-the-command-line +language: ru +disqus: true +previous-page: /ru/getting-started-with-scala-and-sbt-on-the-command-line +--- + +There are multiple libraries and testing methodologies for Scala, +but in this tutorial, we'll demonstrate one popular option from the ScalaTest framework +called [AnyFunSuite](https://www.scalatest.org/scaladoc/3.2.2/org/scalatest/funsuite/AnyFunSuite.html). +We assume you know [how to create a Scala project with sbt](getting-started-with-scala-and-sbt-on-the-command-line.html). + +## Setup +1. On the command line, create a new directory somewhere. +1. `cd` into the directory and run `sbt new scala/scalatest-example.g8` +1. Name the project `ScalaTestTutorial`. +1. The project comes with ScalaTest as a dependency in the `build.sbt` file. +1. `cd` into the directory and run `sbt test`. This will run the test suite +`CubeCalculatorTest` with a single test called `CubeCalculator.cube`. + +``` +sbt test +[info] Loading global plugins from /Users/username/.sbt/0.13/plugins +[info] Loading project definition from /Users/username/workspace/sandbox/my-something-project/project +[info] Set current project to scalatest-example (in build file:/Users/username/workspace/sandbox/my-something-project/) +[info] CubeCalculatorTest: +[info] - CubeCalculator.cube +[info] Run completed in 267 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: 1 s, completed Feb 2, 2017 7:37:31 PM +``` + +## Understanding tests +1. Open up two files in a text editor: + * `src/main/scala/CubeCalculator.scala` + * `src/test/scala/CubeCalculatorTest.scala` +1. In the file `CubeCalculator.scala`, you'll see how we define the function `cube`. +1. In the file `CubeCalculatorTest.scala`, you'll see that we have a class +named after the object we're testing. + +``` + import org.scalatest.funsuite.AnyFunSuite + + class CubeCalculatorTest extends AnyFunSuite { + test("CubeCalculator.cube") { + assert(CubeCalculator.cube(3) === 27) + } + } +``` + +Let's go over this line by line. + +* `class CubeCalculatorTest` means we are testing the object `CubeCalculator` +* `extends AnyFunSuite` lets us use functionality of ScalaTest's AnyFunSuite class +such as the `test` function +* `test` is function that comes from AnyFunSuite that collects +results from assertions within the function body. +* `"CubeCalculator.cube"` is a name for the test. You can call it anything but +one convention is "ClassName.methodName". +* `assert` takes a boolean condition and determines whether the test passes or fails. +* `CubeCalculator.cube(3) === 27` checks whether the output of the `cube` function is +indeed 27. The `===` is part of ScalaTest and provides clean error messages. + +## Adding another test case +1. Add another test block with its own `assert` statement that checks for the cube of `0`. + + ``` + import org.scalatest.funsuite.AnyFunSuite + + class CubeCalculatorTest extends AnyFunSuite { + test("CubeCalculator.cube 3 should be 27") { + assert(CubeCalculator.cube(3) === 27) + } + + test("CubeCalculator.cube 0 should be 0") { + assert(CubeCalculator.cube(0) === 0) + } + } + ``` + +1. Execute `sbt test` again to see the results. + + ``` + sbt test + [info] Loading project definition from C:\projects\scalaPlayground\scalatestpractice\project + [info] Loading settings for project root from build.sbt ... + [info] Set current project to scalatest-example (in build file:/C:/projects/scalaPlayground/scalatestpractice/) + [info] Compiling 1 Scala source to C:\projects\scalaPlayground\scalatestpractice\target\scala-2.13\test-classes ... + [info] CubeCalculatorTest: + [info] - CubeCalculator.cube 3 should be 27 + [info] - CubeCalculator.cube 0 should be 0 + [info] Run completed in 257 milliseconds. + [info] Total number of tests run: 2 + [info] Suites: completed 1, aborted 0 + [info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0 + [info] All tests passed. + [success] Total time: 3 s, completed Dec 4, 2019 10:34:04 PM + ``` + +## Conclusion +You've seen one way to test your Scala code. You can learn more about +ScalaTest's FunSuite on the [official website](https://www.scalatest.org/getting_started_with_fun_suite). You can also check out other testing frameworks such as [ScalaCheck](https://www.scalacheck.org/) and [Specs2](https://etorreborre.github.io/specs2/). From 91a488b54d499b2d95f5a0cf4437b2306de0e158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC?= Date: Sat, 10 Sep 2022 09:34:49 +0300 Subject: [PATCH 06/13] Add getting-started in russian --- .../getting-started-with-scala-in-intellij.md | 111 +++++++++--------- 1 file changed, 58 insertions(+), 53 deletions(-) diff --git a/_ru/getting-started/intellij-track/getting-started-with-scala-in-intellij.md b/_ru/getting-started/intellij-track/getting-started-with-scala-in-intellij.md index 6585987127..65337bc058 100644 --- a/_ru/getting-started/intellij-track/getting-started-with-scala-in-intellij.md +++ b/_ru/getting-started/intellij-track/getting-started-with-scala-in-intellij.md @@ -7,40 +7,44 @@ disqus: true next-page: /ru/building-a-scala-project-with-intellij-and-sbt --- -In this tutorial, we'll see how to build a minimal Scala project using IntelliJ -IDE with the Scala plugin. In this guide, IntelliJ will download Scala for you. +В этом руководстве мы увидим, как создать минимальный проект Scala с помощью IntelliJ IDE со Scala плагином. +В этом руководстве IntelliJ загрузит Scala за вас. -## Installation -1. Make sure you have the Java 8 JDK (also known as 1.8) - * Run `javac -version` on the command line and make sure you see +## Установка + +1. Убедитесь, что у вас установлена Java 8 JDK (также известная как 1.8) + * Запустите `javac -version` в командной строке и убедитесь, что выдается `javac 1.8.___` - * If you don't have version 1.8 or higher, [install the JDK](https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) -1. Next, download and install [IntelliJ Community Edition](https://www.jetbrains.com/idea/download/) -1. Then, after starting up IntelliJ, you can download and install the Scala plugin by following the instructions on -[how to install IntelliJ plugins](https://www.jetbrains.com/help/idea/installing-updating-and-uninstalling-repository-plugins.html) (search for "Scala" in the plugins menu.) - -When we create the project, we'll install the latest version of Scala. -Note: If you want to open an existing Scala project, you can click **Open** -when you start IntelliJ. - -## Creating the Project -1. Open up IntelliJ and click **File** => **New** => **Project** -1. On the left panel, select Scala. On the right panel, select IDEA. -1. Name the project **HelloWorld** -1. Assuming this is your first time creating a Scala project with IntelliJ, -you'll need to install a Scala SDK. To the right of the Scala SDK field, -click the **Create** button. -1. Select the highest version number (e.g. {{ site.scala-version }}) and click **Download**. This might -take a few minutes but subsequent projects can use the same SDK. -1. Once the SDK is created, and you're back to the "New Project" window, click **Finish**. - - -## Writing code - -1. On the **Project** pane on the left, right-click `src` and select -**New** => **Scala class**. If you don't see **Scala class**, right-click on **HelloWorld** and click on **Add Framework Support...**, select **Scala** and proceed. If you see **Error: library is not specified**, you can either click download button, or select the library path manually. If you only see **Scala Worksheet** try expanding the `src` folder and its `main` subfolder, and right-click on the `scala` folder. -1. Name the class `Hello` and change the **Kind** to `object`. -1. Change the code in the file to the following: + * Если у вас нет версии 1.8 или выше, [установите JDK](https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) +1. Затем загрузите и установите [IntelliJ Community Edition](https://www.jetbrains.com/idea/download/) +1. Затем, после запуска IntelliJ, вы можете загрузить и установить Scala плагин, следуя + [инструкции по установке плагинов IntelliJ](https://www.jetbrains.com/help/idea/installing-updating-and-uninstalling-repository-plugins.html) (найдите "Scala" в меню плагинов). + +Когда мы создадим проект, то установим последнюю версию Scala. +Примечание: Если вы хотите открыть существующий проект Scala, вы можете нажать **Open** +при запуске IntelliJ. + +## Создание проекта + +1. Откройте IntelliJ и нажмите **File** => **New** => **Project** +1. На левой панели выберите Scala. На правой панели - IDEA. +1. Назовите проект **HelloWorld** +1. Если вы впервые создаете Scala проект с помощью IntelliJ, вам необходимо установить Scala SDK. + Справа от поля Scala SDK нажмите кнопку **Create**. +1. Выберите последний номер версии (например, {{ site.scala-version }}) и нажмите **Download**. +Это может занять несколько минут, но тот же пакет SDK могут использовать последующие проекты. +1. Когда SDK будет установлен и вы вернетесь в окно "New Project", нажмите **Finish**. + +## Написание кода + +1. На левой панели **Project** щелкните правой кнопкой мыши на папке `src` и выберите +**New** => **Scala class**. Если вы не видите **Scala class**, щелкните правой кнопкой мыши на **HelloWorld** +и выберите **Add Framework Support...**, затем - **Scala** и продолжить. +Если вы видите ошибку **Error: library is not specified**, вы можете либо нажать кнопку загрузки, +либо выбрать путь к библиотеке вручную. Если вы видите только **Scala Worksheet** попробуйте развернуть папку `src` +и её подпапку `main`, а затем правой кнопкой мыши на папке `scala`. +1. Назовите класс `Hello` и измените **Kind** на `object`. +1. Вставьте следующий код: {% tabs hello-world-entry-point class=tabs-scala-version %} @@ -61,40 +65,41 @@ object Hello extends App { println("Hello, World!") ``` -In Scala 3, you can remove the object `Hello` and define a top-level method -`hello` instead, which you annotate with `@main`. +В Scala 3 вы можете удалить объект `Hello` и вместо него определить метод верхнего уровня `hello` +с аннотацией `@main`. {% endtab %} {% endtabs %} -## Running it +## Запуск {% tabs hello-world-run class=tabs-scala-version %} {% tab 'Scala 2' for=hello-world-run %} -* Right click on `Hello` in your code and select **Run 'Hello'**. -* You're done! +* Щелкните правой кнопкой мыши на `Hello` в своем коде и выберите **Run 'Hello'**. +* Готово! {% endtab %} {% tab 'Scala 3' for=hello-world-run %} -* Right click on `hello` in your code and select **Run 'hello'**. -* You're done! +* Щелкните правой кнопкой мыши на `hello` в своем коде и выберите **Run 'hello'**. +* Готово! {% endtab %} {% endtabs %} -## Experimenting with Scala -A good way to try out code samples is with Scala Worksheets +## Эксперименты со Скалой + +Хороший способ попробовать примеры кода — использовать Scala Worksheets. -1. In the project pane on the left, right click -`src` and select **New** => **Scala Worksheet**. -2. Name your new Scala worksheet "Mathematician". -3. Enter the following code into the worksheet: +1. В левой панели проекта щелкните правой кнопкой мыши на +`src` и выберите **New** => **Scala Worksheet**. +2. Назовите новый Scala worksheet "Mathematician". +3. Введите следующий код в worksheet: {% tabs square %} {% tab 'Scala 2 and 3' for=square %} @@ -106,14 +111,14 @@ square(2) {% endtab %} {% endtabs %} -As you change your code, you'll notice that it gets evaluated -in the right pane. If you do not see a right pane, right-click on your Scala worksheet in the Project pane, and click on Evaluate Worksheet. +После запуска кода вы заметите, что результаты его выполнения выводятся на правой панели. +Если вы не видите правую панель, щелкните правой кнопкой мыши на вашем Scala worksheet на панели "Проект" +и выберите "Evaluate Worksheet". -## Next Steps +## Следующие шаги -Now you know how to create a simple Scala project which can be used -for starting to learn the language. In the next tutorial, we'll introduce -an important build tool called sbt which can be used for simple projects -and production apps. +Теперь вы знаете, как создать простой Scala проект, который можно использовать для изучения языка. +В следующем уроке мы представим важный инструмент сборки под названием sbt, +который можно использовать для простых проектов и рабочих приложений. -Up Next: [Building a Scala Project with IntelliJ and sbt](building-a-scala-project-with-intellij-and-sbt.html) +Далее: [Создание проекта Scala с IntelliJ и sbt](building-a-scala-project-with-intellij-and-sbt.html) From 831d6f342c5d4f03af4e9b15887f2a2a00171378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC?= Date: Sat, 10 Sep 2022 11:22:35 +0300 Subject: [PATCH 07/13] Add getting-started in russian --- ...g-a-scala-project-with-intellij-and-sbt.md | 5 +- ...g-a-scala-project-with-intellij-and-sbt.md | 3 +- ...g-a-scala-project-with-intellij-and-sbt.md | 151 +++++++++--------- ...g-a-scala-project-with-intellij-and-sbt.md | 5 +- 4 files changed, 78 insertions(+), 86 deletions(-) diff --git a/_getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md b/_getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md index 32c76a97c5..6dc397f089 100644 --- a/_getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md +++ b/_getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md @@ -60,10 +60,9 @@ but here's a glance at what everything is for: 1. Change the code in the class to the following: ``` -object Main extends App { +@main def run() = val ages = Seq(42, 75, 29, 64) println(s"The oldest person is ${ages.max}") -} ``` Note: IntelliJ has its own implementation of the Scala compiler, and sometimes your @@ -105,7 +104,7 @@ Continue to the next tutorial in the _getting started with IntelliJ_ series, and **or** -* [The Scala Book](/overviews/scala-book/introduction.html), which provides a set of short lessons introducing Scala’s main features. +* [The Scala Book](/scala3/book/introduction.html), which provides a set of short lessons introducing Scala’s main features. * [The Tour of Scala](/tour/tour-of-scala.html) for bite-sized introductions to Scala's features. - Continue learning Scala interactively online on [Scala Exercises](https://www.scala-exercises.org/scala_tutorial). diff --git a/_ja/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md b/_ja/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md index ae7573edba..e701b837f0 100644 --- a/_ja/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md +++ b/_ja/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md @@ -56,10 +56,9 @@ sbt は、より複雑なプロジェクトを構築すだしたら便利にな 1. クラスのコードを次おように変更します。 ``` -object Main extends App { +@main def run() = val ages = Seq(42, 75, 29, 64) println(s"The oldest person is ${ages.max}") -} ``` 注:Intellij は Scala コンパイラーの独自実装を持っており、コードが間違っていると Intellij が示しても正しい場合がときどきあります。 diff --git a/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md b/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md index b73d8faeb0..0b65302a48 100644 --- a/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md +++ b/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md @@ -8,102 +8,97 @@ previous-page: /ru/getting-started/intellij-track/getting-started-with-scala-in- next-page: /ru/testing-scala-in-intellij-with-scalatest --- -In this tutorial, we'll see how to build a Scala project using [sbt](https://www.scala-sbt.org/1.x/docs/index.html). sbt is a popular tool for compiling, running, and testing Scala projects of any -size. Using a build tool such as sbt (or Maven/Gradle) becomes essential once you create projects with dependencies -or more than one code file. - We assume you've completed the -[first tutorial](getting-started-with-scala-in-intellij.html). - -## Creating the project -In this section, we'll show you how to create the project in IntelliJ. However, if you're -comfortable with the command line, we recommend you try [Getting -Started with Scala and sbt on the Command Line]({{site.baseurl}}/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.html) and then come back - here to the section "Writing Scala code". - -1. If you didn't create the project from the command line, open up IntelliJ and select "Create New Project" - * On the left panel, select Scala and on the right panel, select sbt - * Click **Next** - * Name the project "SbtExampleProject" -1. If you already created the project on the command line, open up IntelliJ, select *Import Project* and open the `build.sbt` file for your project -1. Make sure the **JDK version** is 1.8 and the **sbt version** is at least 0.13.13 -1. Select **Use auto-import** so dependencies are automatically downloaded when available -1. Select **Finish** - -## Understanding the directory structure -sbt creates many directories which can be useful once you start building -more complex projects. You can ignore most of them for now -but here's a glance at what everything is for: +В этом руководстве мы увидим, как создать проект Scala с помощью [sbt](https://www.scala-sbt.org/1.x/docs/index.html). +sbt — популярный инструмент для компиляции, запуска и тестирования проектов Scala любой сложности. +Использование инструмента сборки, такого как sbt (или Maven/Gradle), становится необходимым, +если вы создаете проекты с зависимостями или несколькими файлами кода. +Мы предполагаем, что вы прочитали [первое руководство](getting-started-with-scala-in-intellij.html). + +## Создание проекта +В этом разделе мы покажем вам, как создать проект в IntelliJ. +Однако, если вы знакомы с командной строкой, мы рекомендуем вам попробовать +[Начало работы со Scala и sbt в командной строке]({{site.baseurl}}/ru/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.html) +а затем вернуться к разделу "Написание Scala кода". + +1. Если вы не создавали проект из командной строки, откройте IntelliJ и выберите "Create New Project" + * На левой панели выберите Scala, а на правой панели - sbt + * Нажмите **Next** + * Назовите проект "SbtExampleProject" +1. Если вы уже создали проект в командной строке, откройте IntelliJ, выберите *Import Project* и откройте `build.sbt` файл вашего проекта +1. Убедитесь, что ваша **JDK version** - это 1.8, а **sbt version** не ниже 0.13.13 +1. Выберите **Use auto-import**, чтобы доступные зависимости загружались автоматически. +1. Выберите **Finish** + +## Разбор структуры каталогов +sbt создает множество каталогов, которые могут быть полезны, когда вы начнете создавать более сложные проекты. +На данный момент вы можете игнорировать большинство из них, но вот объяснение, для чего все это: ``` -- .idea (IntelliJ files) -- project (plugins and additional settings for sbt) -- src (source files) - - main (application code) - - java (Java source files) - - scala (Scala source files) <-- This is all we need for now - - scala-2.12 (Scala 2.12 specific files) - - test (unit tests) -- target (generated files) -- build.sbt (build definition file for sbt) +- .idea (файлы IntelliJ) +- project (плагины и дополнительные настройки sbt) +- src (исходные файлы) + - main (код приложения) + - java (исходные файлы Java) + - scala (исходные файлы Scala) <-- это все, что вам сейчас нужно + - scala-2.12 (файлы, специфичные для Scala 2.12) + - test (модульные тесты) +- target (сгенерированные файлы) +- build.sbt (файл определения сборки для sbt) ``` -## Writing Scala code -1. On the **Project** panel on the left, expand `SbtExampleProject` => `src` -=> `main` -1. Right-click `scala` and select **New** => **Package** -1. Name the package `example` and click **OK** (or just press the Enter or Return key). -1. Right-click the package `example` and select **New** => **Scala class** (if you don't see this option, right-click the `SbtExampleProject`, click **Add Frameworks Support**, select **Scala** and proceed) -1. Name the class `Main` and change the **Kind** to `Object`. -1. Change the code in the class to the following: +## Написание Scala-кода +1. На панели слева **Project**, разверните `SbtExampleProject` => `src` => `main` +1. Щелкните правой кнопкой мыши на `scala` и выберете **New** => **Package** +1. Назовите пакет `example` и нажмите **OK** (или просто нажмите клавишу **Enter** или **Return**). +1. Щелкните правой кнопкой мыши на пакете `example` и выберите **New** => **Scala class** +(если вы не видите эту опцию, щелкните правой кнопкой мыши на `SbtExampleProject`, кликните на **Add Frameworks Support**, выберете **Scala** и продолжите) +1. Назовите класс `Main` и измените **Kind** на `Object`. +1. Вставьте следующий код: ``` -object Main extends App { +@main def run() = val ages = Seq(42, 75, 29, 64) println(s"The oldest person is ${ages.max}") -} ``` -Note: IntelliJ has its own implementation of the Scala compiler, and sometimes your -code is correct even though IntelliJ indicates otherwise. You can always check -to see if sbt can run your project on the command line. - -## Running the project -1. From the **Run** menu, select **Edit configurations** -1. Click the **+** button and select **sbt Task**. -1. Name it `Run the program`. -1. In the **Tasks** field, type `~run`. The `~` causes sbt to rebuild and rerun the project -when you save changes to a file in the project. -1. Click **OK**. -1. On the **Run** menu. Click **Run 'Run the program'**. -1. In the code, change `75` to `61` -and look at the updated output in the console. - -## Adding a dependency -Changing gears a bit, let's look at how to use published libraries to add -extra functionality to our apps. -1. Open up `build.sbt` and add the following line: +Примечание: IntelliJ имеет собственную реализацию компилятора Scala, +и иногда ваш код верен, даже если IntelliJ указывает обратное. +Вы всегда можете проверить, может ли sbt запустить ваш проект в командной строке. + +## Запуск проекта +1. В меню **Run**, выберите **Edit configurations** +1. Нажмите кнопку **+** и выберите **sbt Task**. +1. Назовите задачу `Run the program`. +1. В поле **Tasks**, введите `~run`. `~` заставляет sbt перекомпилировать +и повторно запускать проект при каждом сохранении изменений в файле проекта. +1. Нажмите **OK**. +1. В меню **Run** нажмите **'Run the program'**. +1. В коде измените `75` на `61` и посмотрите на обновленные результаты в консоли. + +## Добавление зависимости +Немного меняя тему, давайте посмотрим, как использовать опубликованные библиотеки +для добавления дополнительных функций в наши приложения. +1. Откройте `build.sbt` и добавьте следующую строку: ``` libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2" ``` -Here, `libraryDependencies` is a set of dependencies, and by using `+=`, -we're adding the [scala-parser-combinators](https://github.com/scala/scala-parser-combinators) dependency to the set of dependencies that sbt will go -and fetch when it starts up. Now, in any Scala file, you can import classes, -objects, etc, from scala-parser-combinators with a regular import. +Здесь `libraryDependencies` представляет набор зависимостей, +и с помощью `+=` мы добавляем зависимость [scala-parser-combinators](https://github.com/scala/scala-parser-combinators) +к набору зависимостей, которые sbt будет загружать при запуске. +Теперь в любой файл Scala можно импортировать классы, объекты и т.д. из `scala-parser-combinators` с помощью обычного импорта. -You can find more published libraries on -[Scaladex](https://index.scala-lang.org/), the Scala library index, where you -can also copy the above dependency information for pasting into your `build.sbt` -file. +Вы можете найти больше опубликованных библиотек на [Scaladex](https://index.scala-lang.org/), каталоге библиотек Scala, +где вы также можете скопировать указанную выше информацию о зависимостях для вставки в свой файл `build.sbt`. -## Next steps +## Следующие шаги -Continue to the next tutorial in the _getting started with IntelliJ_ series, and learn about [testing Scala code in IntelliJ with ScalaTest](testing-scala-in-intellij-with-scalatest.html). +Перейдите к следующему руководству из серии _getting started with IntelliJ_ и узнайте, как [тестировать Scala в IntelliJ с помощью ScalaTest](testing-scala-in-intellij-with-scalatest.html). -**or** +**или** -* [The Scala Book](/overviews/scala-book/introduction.html), which provides a set of short lessons introducing Scala’s main features. -* [The Tour of Scala](/tour/tour-of-scala.html) for bite-sized introductions to Scala's features. -- Continue learning Scala interactively online on +* [The Scala Book](/scala3/book/introduction.html), содержащая набор коротких уроков, знакомящих с основными функциями Scala. +* [The Tour of Scala](/ru/tour/tour-of-scala.html) для краткого ознакомления с возможностями Scala. +- Продолжайте изучать Scala в интерактивном режиме на [Scala Exercises](https://www.scala-exercises.org/scala_tutorial). diff --git a/_uk/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md b/_uk/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md index 18da5a8ea5..9a9d303f47 100644 --- a/_uk/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md +++ b/_uk/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md @@ -54,10 +54,9 @@ sbt — популярний інструмент для компіляції, 1. Змініть код у класі на наступний: ``` -object Main extends App { +@main def run() = val ages = Seq(42, 75, 29, 64) println(s"The oldest person is ${ages.max}") -} ``` Примітка: IntelliJ має власну реалізацію компілятора Scala, тому іноді ваш код є правильним, навіть якщо IntelliJ вказує інше. @@ -95,7 +94,7 @@ libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % **або** -* [Книга по Scala](/overviews/scala-book/introduction.html), що є набором коротких вступних уроків з основних особливостей. +* [Книга по Scala](/scala3/book/introduction.html), що є набором коротких вступних уроків з основних особливостей. * [Тур по Scala](/tour/tour-of-scala.html) серія коротких оглядових статей про можливості Scala. * Продовжить вчити Scala інтерактивно виконуючи [вправи зі Scala](https://www.scala-exercises.org/scala_tutorial). \ No newline at end of file From 439602ab5421436d1cfef92bfc975997e43e26ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC?= Date: Sat, 10 Sep 2022 12:11:21 +0300 Subject: [PATCH 08/13] Add getting-started in russian --- ...esting-scala-in-intellij-with-scalatest.md | 9 +- ...esting-scala-in-intellij-with-scalatest.md | 11 +-- ...g-a-scala-project-with-intellij-and-sbt.md | 2 +- ...esting-scala-in-intellij-with-scalatest.md | 89 +++++++++---------- ...esting-scala-in-intellij-with-scalatest.md | 9 +- 5 files changed, 52 insertions(+), 68 deletions(-) diff --git a/_getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md b/_getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md index 3fbd8cb28a..e7af916a8d 100644 --- a/_getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md +++ b/_getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md @@ -31,11 +31,9 @@ This assumes you know [how to build a project in IntelliJ](building-a-scala-proj 1. Call it `CubeCalculator`, change the **Kind** to `object`, and hit enter or double-click on `object`. 1. Replace the code with the following: ``` - object CubeCalculator extends App { - def cube(x: Int) = { + object CubeCalculator: + def cube(x: Int) = x * x * x - } - } ``` ## Creating a test @@ -46,11 +44,10 @@ This assumes you know [how to build a project in IntelliJ](building-a-scala-proj ``` import org.scalatest.funsuite.AnyFunSuite - class CubeCalculatorTest extends AnyFunSuite { + class CubeCalculatorTest extends AnyFunSuite: test("CubeCalculator.cube") { assert(CubeCalculator.cube(3) === 27) } - } ``` 1. In the source code, right-click `CubeCalculatorTest` and select **Run 'CubeCalculatorTest'**. diff --git a/_ja/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md b/_ja/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md index 62814e914a..2af1906295 100644 --- a/_ja/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md +++ b/_ja/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md @@ -26,11 +26,9 @@ Scala には複数のライブラリとテスト方法がありますが、こ 1. クラスに `CubeCalculator` と名前をつけて、**Kind** を `object` に変更し、**OK** をクリックします。 1. コードを次の通り置き換えます。 ``` - object CubeCalculator extends App { - def cube(x: Int) = { + object CubeCalculator: + def cube(x: Int) = x * x * x - } - } ``` ## テストを作成 @@ -39,13 +37,12 @@ Scala には複数のライブラリとテスト方法がありますが、こ 1. クラスに `CubeCalculatorTest` と名前を付けて、**OK** をクリックします。 1. コードを次の通り置き換えます。 ``` - import org.scalatest.FunSuite + import org.scalatest.funsuite.AnyFunSuite - class CubeCalculatorTest extends FunSuite { + class CubeCalculatorTest extends AnyFunSuite: test("CubeCalculator.cube") { assert(CubeCalculator.cube(3) === 27) } - } ``` 1. `CubeCalculatorTest` のソースコード内で右クリックし、**Run 'CubeCalculatorTest'** を選択します。 diff --git a/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md b/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md index 0b65302a48..6f4d29195d 100644 --- a/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md +++ b/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md @@ -73,7 +73,7 @@ sbt создает множество каталогов, которые мог 1. В поле **Tasks**, введите `~run`. `~` заставляет sbt перекомпилировать и повторно запускать проект при каждом сохранении изменений в файле проекта. 1. Нажмите **OK**. -1. В меню **Run** нажмите **'Run the program'**. +1. В меню **Run** нажмите **Run 'Run the program'**. 1. В коде измените `75` на `61` и посмотрите на обновленные результаты в консоли. ## Добавление зависимости diff --git a/_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md b/_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md index ca2b961ee7..cd1ee0809f 100644 --- a/_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md +++ b/_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md @@ -7,73 +7,66 @@ disqus: true previous-page: /ru/building-a-scala-project-with-intellij-and-sbt --- -There are multiple libraries and testing methodologies for Scala, -but in this tutorial, we'll demonstrate one popular option from the ScalaTest framework -called [FunSuite](https://www.scalatest.org/getting_started_with_fun_suite). +Для Scala существует множество библиотек и методологий тестирования, +но в этом руководстве мы продемонстрируем один популярный вариант из фреймворка ScalaTest +под названием [FunSuite](https://www.scalatest.org/getting_started_with_fun_suite). -This assumes you know [how to build a project in IntelliJ](building-a-scala-project-with-intellij-and-sbt.html). +Это предполагает, что вы знаете, [как создать проект в IntelliJ](building-a-scala-project-with-intellij-and-sbt.html). -## Setup -1. Create an sbt project in IntelliJ. -1. Add the ScalaTest dependency: - 1. Add the ScalaTest dependency to your `build.sbt` file: +## Настройка +1. Создайте sbt проект в IntelliJ. +1. Добавьте зависимость ScalaTest: + 1. Добавьте зависимость ScalaTest в свой файл `build.sbt`: ``` libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.11" % Test ``` - 1. If you get a notification "build.sbt was changed", select **auto-import**. - 1. These two actions will cause `sbt` to download the ScalaTest library. - 1. Wait for the `sbt` sync to finish; otherwise, `AnyFunSuite` and `test()` will be - unrecognized. -1. On the project pane on the left, expand `src` => `main`. -1. Right-click on `scala` and select **New** => **Scala class**. -1. Call it `CubeCalculator`, change the **Kind** to `object`, and hit enter or double-click on `object`. -1. Replace the code with the following: + 1. Если вы получили уведомление "build.sbt was changed", выберите **auto-import**. + 1. Эти два действия заставят `sbt` подгрузить библиотеки ScalaTest. + 1. Дождитесь окончания синхронизации `sbt`; в противном случае, `AnyFunSuite` и `test()` не будет распознаны. +1. На панели проекта слева разверните `src` => `main`. +1. Щелкните правой кнопкой мыши на `scala` и выберите **New** => **Scala class**. +1. Назовите новый класс `CubeCalculator`, измените **Kind** на `object`, или дважды щелкните на `object`. +1. Вставьте следующий код: ``` - object CubeCalculator extends App { - def cube(x: Int) = { + object CubeCalculator: + def cube(x: Int) = x * x * x - } - } ``` -## Creating a test -1. On the project pane on the left, expand `src` => `test`. -1. Right-click on `scala` and select **New** => **Scala class**. -1. Name the class `CubeCalculatorTest` and hit enter or double-click on `class`. -1. Replace the code with the following: +## Создание теста +1. На панели проекта слева разверните `src` => `test`. +1. Щелкните правой кнопкой мыши на `scala` и выберите **New** => **Scala class**. +1. Назовите новый класс `CubeCalculatorTest` и нажмите **Enter** или дважды щелкните на `class`. +1. Вставьте следующий код: ``` import org.scalatest.funsuite.AnyFunSuite - class CubeCalculatorTest extends AnyFunSuite { + class CubeCalculatorTest extends AnyFunSuite: test("CubeCalculator.cube") { assert(CubeCalculator.cube(3) === 27) } - } ``` -1. In the source code, right-click `CubeCalculatorTest` and select +1. В исходном коде щелкните правой кнопкой мыши на `CubeCalculatorTest` и выберите **Run 'CubeCalculatorTest'**. -## Understanding the code +## Разбор кода -Let's go over this line by line: +Давайте разберем код построчно: -* `class CubeCalculatorTest` means we are testing the object `CubeCalculator` -* `extends AnyFunSuite` lets us use functionality of ScalaTest's AnyFunSuite class -such as the `test` function -* `test` is a function that comes from the FunSuite library that collects -results from assertions within the function body. -* `"CubeCalculator.cube"` is a name for the test. You can call it anything but -one convention is "ClassName.methodName". -* `assert` takes a boolean condition and determines whether the test passes or fails. -* `CubeCalculator.cube(3) === 27` checks whether the output of the `cube` function is -indeed 27. The `===` is part of ScalaTest and provides clean error messages. +* `class CubeCalculatorTest` означает, что мы тестируем `CubeCalculator` +* `extends AnyFunSuite` позволяет нам использовать функциональность класса AnyFunSuite из ScalaTest, + такую как функция `test` +* `test` это функция из библиотеки FunSuite, которая собирает результаты проверок в теле функции. +* `"CubeCalculator.cube"` - это имя для теста. Вы можете называть тест как угодно, но по соглашению используется имя — "ClassName.methodName". +* `assert` принимает логическое условие и определяет, пройден тест или нет. +* `CubeCalculator.cube(3) === 27` проверяет, действительно ли вывод функции `cube` равен 27. + `===` является частью ScalaTest и предоставляет понятные сообщения об ошибках. -## Adding another test case -1. Add another `assert` statement after the first one that checks for the cube - of `0`. -1. Re-run the test again by right-clicking `CubeCalculatorTest` and selecting - 'Run **CubeCalculatorTest**'. +## Добавление еще одного теста +1. Добавьте еще один оператор `assert` после первого, который проверяет 0 в кубе. +1. Перезапустите тест `CubeCalculatorTest`, кликнув правой кнопкой мыши и выбрав + **Run 'CubeCalculatorTest'**. -## Conclusion -You've seen one way to test your Scala code. You can learn more about ScalaTest's -FunSuite on the [official website](https://www.scalatest.org/getting_started_with_fun_suite). +## Резюме +Вы видели один из способов тестирования Scala кода. +Узнать больше о FunSuite от ScalaTest можно на [официальном сайте](https://www.scalatest.org/getting_started_with_fun_suite). diff --git a/_uk/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md b/_uk/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md index 87c8c09bdd..de7135cf1b 100644 --- a/_uk/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md +++ b/_uk/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md @@ -28,11 +28,9 @@ previous-page: /uk/building-a-scala-project-with-intellij-and-sbt 1. Назвіть його `CubeCalculator` та змініть **Kind** на `object` та натисніть Enter або двічі клацніть на `object`. 1. Замініть код на наступний: ``` - object CubeCalculator extends App { - def cube(x: Int) = { + object CubeCalculator: + def cube(x: Int) = x * x * x - } - } ``` ## Створення тесту @@ -43,11 +41,10 @@ previous-page: /uk/building-a-scala-project-with-intellij-and-sbt ``` import org.scalatest.funsuite.AnyFunSuite - class CubeCalculatorTest extends AnyFunSuite { + class CubeCalculatorTest extends AnyFunSuite: test("CubeCalculator.cube") { assert(CubeCalculator.cube(3) === 27) } - } ``` 1. У початковому коді клацніть правою кнопкою миші на `CubeCalculatorTest` та оберіть **Run 'CubeCalculatorTest'**. From 08887b2a6134ba9a2f9dcee3e2fec660db07f411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC?= Date: Sat, 10 Sep 2022 12:43:18 +0300 Subject: [PATCH 09/13] Add getting-started in russian --- ...g-a-scala-project-with-intellij-and-sbt.md | 2 +- ...-with-scala-and-sbt-on-the-command-line.md | 124 +++++++++--------- 2 files changed, 61 insertions(+), 65 deletions(-) diff --git a/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md b/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md index 6f4d29195d..fa9bc15f8c 100644 --- a/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md +++ b/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md @@ -87,7 +87,7 @@ libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % Здесь `libraryDependencies` представляет набор зависимостей, и с помощью `+=` мы добавляем зависимость [scala-parser-combinators](https://github.com/scala/scala-parser-combinators) к набору зависимостей, которые sbt будет загружать при запуске. -Теперь в любой файл Scala можно импортировать классы, объекты и т.д. из `scala-parser-combinators` с помощью обычного импорта. +Теперь в любом файле Scala можно импортировать классы, объекты и т.д. из `scala-parser-combinators` с помощью обычного импорта. Вы можете найти больше опубликованных библиотек на [Scaladex](https://index.scala-lang.org/), каталоге библиотек Scala, где вы также можете скопировать указанную выше информацию о зависимостях для вставки в свой файл `build.sbt`. diff --git a/_ru/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.md b/_ru/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.md index 99fbbfc27e..f404e3daf8 100644 --- a/_ru/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.md +++ b/_ru/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.md @@ -7,45 +7,43 @@ disqus: true next-page: /ru/testing-scala-with-sbt-on-the-command-line --- -In this tutorial, you'll see how to create a Scala project from -a template. You can use this as a starting point for your own -projects. We'll use [sbt](https://www.scala-sbt.org/1.x/docs/index.html), the de facto build tool for Scala. sbt compiles, -runs, and tests your projects among other related tasks. -We assume you know how to use a terminal. - -## Installation -1. Make sure you have the Java 8 JDK (also known as 1.8) - * Run `javac -version` in the command line and make sure you see +В этом руководстве вы увидите, как создавать проекты Scala из шаблона. +Это можно использовать как отправную точку для своих собственных проектов. +Мы будем использовать [sbt](https://www.scala-sbt.org/1.x/docs/index.html), де-факто инструмент сборки для Scala. +sbt компилирует, запускает и тестирует ваши проекты среди других связанных задач. +Мы предполагаем, что вы знаете, как пользоваться терминалом. + +## Установка +1. Убедитесь, что у вас установлена Java 8 JDK (также известная как 1.8) + * Запустите `javac -version` в командной строке и убедитесь, что выдается `javac 1.8.___` - * If you don't have version 1.8 or higher, [install the JDK](https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) -1. Install sbt + * Если у вас нет версии 1.8 или выше, [установите JDK](https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) +1. Установите sbt * [Mac](https://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Mac.html) * [Windows](https://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Windows.html) * [Linux](https://www.scala-sbt.org/1.x/docs/Installing-sbt-on-Linux.html) -## Create the project +## Создание проекта {% tabs sbt-welcome-1 class=tabs-scala-version %} {% tab 'Scala 2' for=sbt-welcome-1 %} -1. `cd` to an empty folder. -1. Run the following command `sbt new scala/hello-world.g8`. -This pulls the 'hello-world' template from GitHub. -It will also create a `target` folder, which you can ignore. -1. When prompted, name the application `hello-world`. This will -create a project called "hello-world". -1. Let's take a look at what just got generated: +1. `cd` в пустую папку. +1. Запустите следующую команду `sbt new scala/hello-world.g8`. + Она извлекает шаблон 'hello-world' из GitHub. + Она также создаст папку `target`, которую пока можно игнорировать. +1. При появлении запроса назовите приложение `hello-world`. Это создаст проект под названием "hello-world". +1. Давайте взглянем на то, что только что было сгенерировано: {% endtab %} {% tab 'Scala 3' for=sbt-welcome-1 %} -1. `cd` to an empty folder. -1. Run the following command `sbt new scala/scala3.g8`. -This pulls the 'scala3' template from GitHub. -It will also create a `target` folder, which you can ignore. -1. When prompted, name the application `hello-world`. This will -create a project called "hello-world". -1. Let's take a look at what just got generated: +1. `cd` в пустую папку. +1. Запустите следующую команду `sbt new scala/scala3.g8`. + Она извлекает шаблон 'scala3' из GitHub. + Она также создаст папку `target`, которую пока можно игнорировать. +1. При появлении запроса назовите приложение `hello-world`. Это создаст проект под названием "hello-world". +1. Давайте взглянем на то, что только что было сгенерировано: {% endtab %} {% endtabs %} @@ -53,63 +51,61 @@ create a project called "hello-world". ``` - hello-world - - project (sbt uses this to install and manage plugins and dependencies) + - project (sbt использует эту папку для установки и настройки плагинов и зависимостей) - build.properties - src - main - - scala (All of your scala code goes here) - - Main.scala (Entry point of program) <-- this is all we need for now - - build.sbt (sbt's build definition file) + - scala (весь Scala код находится в этой папке) + - Main.scala (точка входа в программу) <-- это все, что вам сейчас нужно + - build.sbt (файл определения сборки для sbt) ``` -After you build your project, sbt will create more `target` directories -for generated files. You can ignore these. +После того как вы создадите свой проект, sbt создаст дополнительные каталоги `target` для сгенерированных файлов. +Вы можете игнорировать их. -## Running the project -1. `cd` into `hello-world`. -1. Run `sbt`. This will open up the sbt console. -1. Type `~run`. The `~` is optional and causes sbt to re-run on every file save, -allowing for a fast edit/run/debug cycle. sbt will also generate a `target` directory -which you can ignore. +## Запуск проекта +1. `cd` в `hello-world`. +1. Запустите `sbt`. Эта команда запустит sbt console. +1. Запустите `~run`. `~` опциональна и заставляет sbt перекомпилировать + и повторно запускать проект при каждом сохранении изменений в файле проекта + для быстрого цикла редактирование/запуск/отладка. + sbt также сгенерит директорию `target`, которую можно игнорировать. -## Modifying the code -1. Open the file `src/main/scala/Main.scala` in your favorite text editor. -1. Change "Hello, World!" to "Hello, New York!" -1. If you haven't stopped the sbt command, you should see "Hello, New York!" -printed to the console. -1. You can continue to make changes and see the results in the console. +## Доработка кода +1. Откройте файл `src/main/scala/Main.scala` в вашем любимом текстовом редакторе. +1. Измените "Hello, World!" на "Hello, New York!" +1. Если вы не остановили команду sbt, то должны увидеть "Hello, New York!", напечатанным в консоли. +1. Вы можете продолжить вносить изменения и видеть результаты доработки в консоли. -## Adding a dependency -Changing gears a bit, let's look at how to use published libraries to add -extra functionality to our apps. +## Добавление зависимости +Немного меняя тему, давайте посмотрим, как использовать опубликованные библиотеки +для добавления дополнительных функций в наши приложения. -1. Open up `build.sbt` and add the following line: +1. Откройте `build.sbt` и добавьте следующую строку: ``` libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2" ``` -Here, `libraryDependencies` is a set of dependencies, and by using `+=`, -we're adding the [scala-parser-combinators](https://github.com/scala/scala-parser-combinators) dependency to the set of dependencies that sbt will go -and fetch when it starts up. Now, in any Scala file, you can import classes, -objects, etc, from `scala-parser-combinators` with a regular import. +Здесь `libraryDependencies` представляет набор зависимостей, +и с помощью `+=` мы добавляем зависимость [scala-parser-combinators](https://github.com/scala/scala-parser-combinators) +к набору зависимостей, которые sbt будет загружать при запуске. +Теперь в любом файле Scala можно импортировать классы, объекты и т.д. из `scala-parser-combinators` с помощью обычного импорта. -You can find more published libraries on -[Scaladex](https://index.scala-lang.org/), the Scala library index, where you -can also copy the above dependency information for pasting into your `build.sbt` -file. +Вы можете найти больше опубликованных библиотек на [Scaladex](https://index.scala-lang.org/), каталоге библиотек Scala, +где вы также можете скопировать указанную выше информацию о зависимостях для вставки в свой файл `build.sbt`. -> **Note for Java Libraries:** For a regular Java library, you should only use one percent (`%`) between the -> organization name and artifact name. Double percent (`%%`) is a specialisation for Scala libraries. -> You can learn more about the reason for this in the [sbt documentation][sbt-docs-lib-dependencies]. +> **Примечание для Java библиотек:** Для обычной библиотеки Java следует использовать только один знак процента (`%`) +> между названием организации и именем артефакта. Двойной процент (`%%`) — это специализация Scala библиотек. +> Подробнее об этом можно узнать в [документации sbt][sbt-docs-lib-dependencies]. -## Next steps +## Следующие шаги -Continue to the next tutorial in the _getting started with sbt_ series, and learn about [testing Scala code with sbt in the command line](testing-scala-with-sbt-on-the-command-line.html). +Перейдите к следующему учебнику из серии _getting started with sbt_ и узнайте, как [тестировать Scala c sbt и ScalaTest в командной строке](testing-scala-with-sbt-on-the-command-line.html). -**or** +**или** -- Continue learning Scala interactively online on +- Продолжайте изучать Scala в интерактивном режиме на [Scala Exercises](https://www.scala-exercises.org/scala_tutorial). -- Learn about Scala's features in bite-sized pieces by stepping through our [Tour of Scala]({{ site.baseurl }}/tour/tour-of-scala.html). +- Узнайте о возможностях Scala с помощью небольших статей, ознакомившись с нашим [туром по Scala]({{ site.baseurl }}/ru/tour/tour-of-scala.html). [sbt-docs-lib-dependencies]: https://www.scala-sbt.org/1.x/docs/Library-Dependencies.html#Getting+the+right+Scala+version+with From 3aad8bd7837a8cb70981de72bfcf12b75d88721e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC?= Date: Sat, 10 Sep 2022 14:50:50 +0300 Subject: [PATCH 10/13] Add getting-started in russian --- ...esting-scala-in-intellij-with-scalatest.md | 7 +- ...ting-scala-with-sbt-on-the-command-line.md | 68 +++++++++---------- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md b/_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md index cd1ee0809f..e9f2c4260b 100644 --- a/_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md +++ b/_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md @@ -9,7 +9,7 @@ previous-page: /ru/building-a-scala-project-with-intellij-and-sbt Для Scala существует множество библиотек и методологий тестирования, но в этом руководстве мы продемонстрируем один популярный вариант из фреймворка ScalaTest -под названием [FunSuite](https://www.scalatest.org/getting_started_with_fun_suite). +под названием [AnyFunSuite](https://www.scalatest.org/getting_started_with_fun_suite). Это предполагает, что вы знаете, [как создать проект в IntelliJ](building-a-scala-project-with-intellij-and-sbt.html). @@ -67,6 +67,7 @@ previous-page: /ru/building-a-scala-project-with-intellij-and-sbt 1. Перезапустите тест `CubeCalculatorTest`, кликнув правой кнопкой мыши и выбрав **Run 'CubeCalculatorTest'**. -## Резюме +## Заключение Вы видели один из способов тестирования Scala кода. -Узнать больше о FunSuite от ScalaTest можно на [официальном сайте](https://www.scalatest.org/getting_started_with_fun_suite). +Узнать больше о AnyFunSuite от ScalaTest можно на [официальном сайте](https://www.scalatest.org/getting_started_with_fun_suite). +Вы также можете использовать другие тестовые фреймворки, такие как [ScalaCheck](https://www.scalacheck.org/) и [Specs2](https://etorreborre.github.io/specs2/). diff --git a/_ru/getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md b/_ru/getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md index 2819efcaa0..577bc65cf5 100644 --- a/_ru/getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md +++ b/_ru/getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md @@ -7,18 +7,19 @@ disqus: true previous-page: /ru/getting-started-with-scala-and-sbt-on-the-command-line --- -There are multiple libraries and testing methodologies for Scala, -but in this tutorial, we'll demonstrate one popular option from the ScalaTest framework -called [AnyFunSuite](https://www.scalatest.org/scaladoc/3.2.2/org/scalatest/funsuite/AnyFunSuite.html). -We assume you know [how to create a Scala project with sbt](getting-started-with-scala-and-sbt-on-the-command-line.html). +Для Scala существует множество библиотек и методологий тестирования, +но в этом руководстве мы продемонстрируем один популярный вариант из фреймворка ScalaTest +под названием [AnyFunSuite](https://www.scalatest.org/getting_started_with_fun_suite). -## Setup -1. On the command line, create a new directory somewhere. -1. `cd` into the directory and run `sbt new scala/scalatest-example.g8` -1. Name the project `ScalaTestTutorial`. -1. The project comes with ScalaTest as a dependency in the `build.sbt` file. -1. `cd` into the directory and run `sbt test`. This will run the test suite -`CubeCalculatorTest` with a single test called `CubeCalculator.cube`. +Это предполагает, что вы знаете, [как создать проект с sbt](getting-started-with-scala-and-sbt-on-the-command-line.html). + +## Настройка +1. Используя командную строку создайте новую директорию. +1. Перейдите (`cd`) в этот каталог и запустите `sbt new scala/scalatest-example.g8`. +1. Назовите проект `ScalaTestTutorial`. +1. Проект поставляется с зависимостью ScalaTest в файле `build.sbt`. +1. Перейдите (`cd`) в этот каталог и запустите `sbt test`. Это запустит набор тестов +`CubeCalculatorTest` с одним тестом под названием `CubeCalculator.cube`. ``` sbt test @@ -35,39 +36,35 @@ sbt test [success] Total time: 1 s, completed Feb 2, 2017 7:37:31 PM ``` -## Understanding tests -1. Open up two files in a text editor: +## Разбор кода +1. Откройте два файла в текстовом редакторе: * `src/main/scala/CubeCalculator.scala` * `src/test/scala/CubeCalculatorTest.scala` -1. In the file `CubeCalculator.scala`, you'll see how we define the function `cube`. -1. In the file `CubeCalculatorTest.scala`, you'll see that we have a class -named after the object we're testing. +1. В файле `CubeCalculator.scala` увидите определение функции `cube`. +1. В файле `CubeCalculatorTest.scala` тестируемый класс, названный так же как и объект. ``` import org.scalatest.funsuite.AnyFunSuite - class CubeCalculatorTest extends AnyFunSuite { + class CubeCalculatorTest extends AnyFunSuite: test("CubeCalculator.cube") { assert(CubeCalculator.cube(3) === 27) } - } ``` -Let's go over this line by line. +Давайте разберем код построчно: -* `class CubeCalculatorTest` means we are testing the object `CubeCalculator` -* `extends AnyFunSuite` lets us use functionality of ScalaTest's AnyFunSuite class -such as the `test` function -* `test` is function that comes from AnyFunSuite that collects -results from assertions within the function body. -* `"CubeCalculator.cube"` is a name for the test. You can call it anything but -one convention is "ClassName.methodName". -* `assert` takes a boolean condition and determines whether the test passes or fails. -* `CubeCalculator.cube(3) === 27` checks whether the output of the `cube` function is -indeed 27. The `===` is part of ScalaTest and provides clean error messages. +* `class CubeCalculatorTest` означает, что мы тестируем `CubeCalculator` +* `extends AnyFunSuite` позволяет нам использовать функциональность класса AnyFunSuite из ScalaTest, + такую как функция `test` +* `test` это функция из библиотеки FunSuite, которая собирает результаты проверок в теле функции. +* `"CubeCalculator.cube"` - это имя для теста. Вы можете называть тест как угодно, но по соглашению используется имя — "ClassName.methodName". +* `assert` принимает логическое условие и определяет, пройден тест или нет. +* `CubeCalculator.cube(3) === 27` проверяет, действительно ли вывод функции `cube` равен 27. + `===` является частью ScalaTest и предоставляет понятные сообщения об ошибках. -## Adding another test case -1. Add another test block with its own `assert` statement that checks for the cube of `0`. +## Добавление еще одного теста +1. Добавьте еще один тестовый блок с собственным оператором assert, который проверяет 0 в кубе. ``` import org.scalatest.funsuite.AnyFunSuite @@ -83,7 +80,7 @@ indeed 27. The `===` is part of ScalaTest and provides clean error messages. } ``` -1. Execute `sbt test` again to see the results. +1. Запустите `sbt test` еще раз, чтобы увидеть результаты. ``` sbt test @@ -102,6 +99,7 @@ indeed 27. The `===` is part of ScalaTest and provides clean error messages. [success] Total time: 3 s, completed Dec 4, 2019 10:34:04 PM ``` -## Conclusion -You've seen one way to test your Scala code. You can learn more about -ScalaTest's FunSuite on the [official website](https://www.scalatest.org/getting_started_with_fun_suite). You can also check out other testing frameworks such as [ScalaCheck](https://www.scalacheck.org/) and [Specs2](https://etorreborre.github.io/specs2/). +## Заключение +Вы видели один из способов тестирования Scala кода. +Узнать больше о AnyFunSuite от ScalaTest можно на [официальном сайте](https://www.scalatest.org/getting_started_with_fun_suite). +Вы также можете использовать другие тестовые фреймворки, такие как [ScalaCheck](https://www.scalacheck.org/) и [Specs2](https://etorreborre.github.io/specs2/). From 54697ccaaba8488e6cc0ca0d0df4c5ecc82f2ca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC?= Date: Sat, 10 Sep 2022 14:51:15 +0300 Subject: [PATCH 11/13] Add getting-started in russian --- .../intellij-track/testing-scala-in-intellij-with-scalatest.md | 2 +- .../sbt-track/testing-scala-with-sbt-on-the-command-line.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md b/_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md index e9f2c4260b..6de67726fb 100644 --- a/_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md +++ b/_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md @@ -70,4 +70,4 @@ previous-page: /ru/building-a-scala-project-with-intellij-and-sbt ## Заключение Вы видели один из способов тестирования Scala кода. Узнать больше о AnyFunSuite от ScalaTest можно на [официальном сайте](https://www.scalatest.org/getting_started_with_fun_suite). -Вы также можете использовать другие тестовые фреймворки, такие как [ScalaCheck](https://www.scalacheck.org/) и [Specs2](https://etorreborre.github.io/specs2/). +Вы также можете использовать другие тестовые фреймворки, такие, как [ScalaCheck](https://www.scalacheck.org/) и [Specs2](https://etorreborre.github.io/specs2/). diff --git a/_ru/getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md b/_ru/getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md index 577bc65cf5..a74aa92a19 100644 --- a/_ru/getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md +++ b/_ru/getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md @@ -102,4 +102,4 @@ sbt test ## Заключение Вы видели один из способов тестирования Scala кода. Узнать больше о AnyFunSuite от ScalaTest можно на [официальном сайте](https://www.scalatest.org/getting_started_with_fun_suite). -Вы также можете использовать другие тестовые фреймворки, такие как [ScalaCheck](https://www.scalacheck.org/) и [Specs2](https://etorreborre.github.io/specs2/). +Вы также можете использовать другие тестовые фреймворки, такие, как [ScalaCheck](https://www.scalacheck.org/) и [Specs2](https://etorreborre.github.io/specs2/). From 334f98fd3b2f861bc513f62a0920f4c67c9cdf6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC?= Date: Sat, 10 Sep 2022 15:01:18 +0300 Subject: [PATCH 12/13] Fix the link to a future page --- _ru/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_ru/index.md b/_ru/index.md index 9cb99c58df..dcb6f28eb4 100644 --- a/_ru/index.md +++ b/_ru/index.md @@ -14,7 +14,7 @@ sections: - title: "Самое начало" description: "Установка Scala на ваш компьютер и написание пробного Scala кода!" icon: "fa fa-rocket" - link: /ru/getting-started.html + link: /getting-started.html - title: "Тур по Scala" description: "Вступительный обзор по основным возможностям языка." icon: "fa fa-flag" From e4ad98eda4b98f613de79b5946babfd4169ee701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC?= Date: Tue, 13 Sep 2022 19:24:10 +0300 Subject: [PATCH 13/13] Fix the review's comments --- _ru/getting-started/index.md | 8 ++++---- .../building-a-scala-project-with-intellij-and-sbt.md | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/_ru/getting-started/index.md b/_ru/getting-started/index.md index dab45082ea..4d49594778 100644 --- a/_ru/getting-started/index.md +++ b/_ru/getting-started/index.md @@ -35,8 +35,8 @@ newcomer_resources: Установка Scala означает установку различных инструментов командной строки, таких как компилятор Scala и инструменты сборки. Мы рекомендуем использовать инструмент установки "Coursier", -который автоматически устанавливает все зависимости, -но также возможно по отдельности установить каждый инструмент вручную. +который автоматически устанавливает все зависимости. +Также возможно установить по отдельности каждый инструмент вручную. ### Использование Scala Installer (рекомендованный путь) @@ -140,8 +140,8 @@ Java 8 или 11 и sbt. В следующих разделах объясняется как создавать проект Scala после того, как установлен sbt. -Для создания проекта можно использовать командную строку или IDE. -Если вы знакомы с командной строкой, мы рекомендуем этот подход. +Для создания проекта можно использовать командную строку или IDE. +Мы рекомендуем командную строку, если вы с ней знакомы. ### Использование командной строки diff --git a/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md b/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md index fa9bc15f8c..dd13a44443 100644 --- a/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md +++ b/_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md @@ -99,6 +99,6 @@ libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % **или** * [The Scala Book](/scala3/book/introduction.html), содержащая набор коротких уроков, знакомящих с основными функциями Scala. -* [The Tour of Scala](/ru/tour/tour-of-scala.html) для краткого ознакомления с возможностями Scala. +* [Тур по Scala](/ru/tour/tour-of-scala.html) для краткого ознакомления с возможностями Scala. - Продолжайте изучать Scala в интерактивном режиме на [Scala Exercises](https://www.scala-exercises.org/scala_tutorial).