# Setting up the environment This is step-by-step guide to prepare your working environment to be ready to work on the programming assignments during the course. ## Git installation ### Git instalation tutorials #### Installing on Ubuntu ```$ sudo apt install git-all``` #### Installing on macOS Check wether git is already installed ```$ git --version``` If not, download from [here](https://git-scm.com/download/mac) and install. #### Installing on Windows Download from [here](https://git-scm.com/download/win) and install. For vore details visit [en](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git), [ru](https://git-scm.com/book/ru/v2/%D0%92%D0%B2%D0%B5%D0%B4%D0%B5%D0%BD%D0%B8%D0%B5-%D0%A3%D1%81%D1%82%D0%B0%D0%BD%D0%BE%D0%B2%D0%BA%D0%B0-Git), [ua](https://git-scm.com/book/uk/v2/%D0%92%D1%81%D1%82%D1%83%D0%BF-%D0%86%D0%BD%D1%81%D1%82%D0%B0%D0%BB%D1%8F%D1%86%D1%96%D1%8F-Git). ## GitHub ### New account Create account on https://github.com/ ### New repository Create new Scala repository ![](https://i.imgur.com/yispjJb.png) You can create public or private repository. If you create the private one then you need to add me to your repository manually. ![](https://i.imgur.com/mCwsiUl.png) ## IntelliJ Idea Installation Install the latest __community__ edition. If you have IntelliJ Idea already installed it's better to remove the older version and install the new one. You can use the previously installed IDE if you use it in a real project as a part of internship or job. ### Downloading * [Downloading](https://www.jetbrains.com/idea/download/#section=linux) on Ubuntu. * [Downloading](https://www.jetbrains.com/idea/download/#section=mac) on macOS. * [Downloading](https://www.jetbrains.com/idea/download/#section=windows) on Windows. ### Installation * Start installation. * Accept JetBrains Privacu Policy ![](https://i.imgur.com/DLBy8uf.png) * Choose a color theme (personally I do prefere the dark one) ![](https://i.imgur.com/n8Ng2Wm.png) * Click next until `Default plugins` page ![](https://i.imgur.com/UXGgCS9.png) * Customize Build Tools Only __Maven__ must be enabled. ![](https://i.imgur.com/U04YMgu.png) Save Changes and Go Back. * Customize Version Controls Only __Git__ must be enabled. ![](https://i.imgur.com/aXRmed2.png) Save Changes and Go Back. * Swing must be disabled. * Disable Android by clicking on `Enable`. * Plugin development must be disabled. * `Download featured plugin` page ![](https://i.imgur.com/ue34TPZ.png) * Install Scala plugin only * Start using IntelliJ IDEA ### Setting up additional functionality * Chose `Configure` and then settings ![](https://i.imgur.com/nXbjefp.png) * Type `Reopen` and remove flag from `Reopen project on startup` ![](https://i.imgur.com/R7uwCPG.png) ## First start and first project * Create new project ![](https://i.imgur.com/BY6T24d.png) * Chose Scala and sbt ![](https://i.imgur.com/kUxESIq.png) * Name your project as `HelloWorld` (without spaces, each word must be started from a capital letter). Be sure that you use JDK 11+, sbt 1.3+ and Scala 2.13+ * Finish setting up the project. ### Project structure Review [Introduction to the Standard Directory Layout](https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html) page ## Adding implementation ![](https://i.imgur.com/guHf85T.png) * Add new package to `scala` folder by right-mouse-button-click then `new` then `Package`. Name package as `ksugc` (Karazin Scala Users' Group Course) ![](https://i.imgur.com/9dQqaIj.png) * Add new Scala class by `new` then `Scala Class`. Name the class as `HelloWorld` * Add the following code to your class: ```[scala] package ksugc object HelloWorld extends App { println("Hello world!") } ``` * Build the project by "green hummer" or `Build` the `Build Project`. It may take up to several minutes (depends on the performance of your notebook) ![](https://i.imgur.com/9PYbB6H.png) * Run the application by clickin on the "green triangle" ![](https://i.imgur.com/IJNwrbK.png) If you faced the error ![](https://i.imgur.com/wiE6cPr.png) then rebuild the project and run again. If it didn't help then manually remove `Target` folder then rebuild and run the project. ![](https://i.imgur.com/0dbzYlu.png) If all works fine then you'll see ![](https://i.imgur.com/HyymgJ4.png) in the console. * .gitignore Create `.gitignore` file (with the dot symbol in front) at the top level of the project. ![](https://i.imgur.com/24rRb66.png) Add following text to the file: ``` *.class *.log # sbt specific .cache/ .history/ .lib/ dist/* target/ lib_managed/ src_managed/ project/boot/ project/plugins/project/ # Scala-IDE specific .scala_dependencies .worksheet .idea .idea/ ``` ![](https://i.imgur.com/E9mMrZm.png) ## Pushing project to GitHub * Open terminal and init git repository by `git init` command ![](https://i.imgur.com/Xcws4Ep.png) * Add all necessary files to the repository (all unnecessary files listed in `.gitignore` won't be added) by `git add .` (dot after `add` is required) ![](https://i.imgur.com/sBHrlkt.png) * Make your first commit by `git commit -m "Init repository"` ![](https://i.imgur.com/CHvmuQU.png) * Visit your repository's page on GitHub and find the following instructions ![](https://i.imgur.com/GelJxm8.png) Copy the console commands and execute them one by one. If needed add your login (email) and password. ![](https://i.imgur.com/XC9eRKK.png)