0Pricing
Scala for Backend Engineering & Functional Programming · Ders

SBT Projesi Kurulumu ve Temelleri

Yeni SBT projelerini başlatmayı, ayarları tanımlamayı ve yaygın derleme görevlerini yürütmeyi öğrenin.

SBT Projesi Kurulumu ve Temelleri, CoddyKit'te ücretsiz bir Scala for Backend Engineering & Functional Programming dersidir. Bu, 3 dersinin 1. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Scala for Backend Engineering & Functional Programming öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Scala for Backend Engineering & Functional Programming kursu toplamda 3 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Welcome to SBT!

Hello! Today we're diving into SBT, the standard build tool for Scala projects. Think of it as your project's manager, handling everything from compiling code to running tests and packaging your application.

SBT stands for Scala Build Tool. It simplifies complex tasks and ensures your projects are set up correctly.

Why Use SBT?

SBT brings several benefits to Scala development:

  • Dependency Management: Easily add external libraries your project needs.
  • Project Structure: Enforces a standard layout, making projects easy to navigate.
  • Task Automation: Automate compilation, testing, packaging, and more with simple commands.
  • Consistency: Ensures everyone on a team builds and runs the project in the same way.

Getting SBT Installed

Before we can use SBT, we need to install it. The recommended way is often through a package manager like Coursier or Homebrew (on macOS/Linux) or by downloading the official launcher.

Once installed, you can verify it by checking the version in your terminal:

sbt --version

Creating a New Project

SBT provides a convenient way to create new projects using templates. We'll use the sbt new command with a basic Scala seed template.

This command will set up the necessary directories and files for a simple Scala application:

sbt new scala/scala-seed.g8 --name my-first-sbt-app

Exploring Project Structure

After creating my-first-sbt-app, you'll see a standard directory structure:

  • src/main/scala/: Your main Scala source code goes here.
  • src/test/scala/: For your test files.
  • project/: Contains project-specific SBT configurations.
  • build.sbt: The main configuration file for your project.

The build.sbt file is where you define project settings.

Basic build.sbt Configuration

The build.sbt file uses a simple syntax to define project settings. Here's a basic example:

  • name := "my-first-sbt-app": Sets your project's name.
  • version := "0.1.0-SNAPSHOT": Defines the project's version.
  • scalaVersion := "2.13.12": Specifies the Scala version to use.

These are key-value pairs where := assigns a value to a setting.

name := "my-first-sbt-app"
version := "0.1.0-SNAPSHOT"
scalaVersion := "2.13.12"

Your First Scala Program

Let's add a simple Scala program to our project. Inside src/main/scala/, create a file named Main.scala. This program will just print a greeting.

SBT will automatically find and compile this file when you run commands like compile or run.

object Main {
  def main(args: Array[String]): Unit = {
    println("Hello from SBT!")
  }
}

Running Your Application

With your Main.scala file in place, navigate to your project's root directory in the terminal (e.g., cd my-first-sbt-app).

You can then use the sbt run command. SBT will compile your code and execute the main method it finds.

sbt run

The SBT Interactive Shell

You can also enter the SBT interactive shell by just typing sbt in your project's root directory. This keeps SBT running, making subsequent commands faster.

Inside the shell, you can type commands like compile, run, or test directly. Type exit to leave the shell.

sbt

> compile
> run
> exit

Quick Check: SBT Basics

Which of the following settings is typically used in build.sbt to specify the Scala version for your project?

SBT Journey Continues!

Great job! You've taken your first steps with SBT.

We covered:

  • What SBT is and why it's essential.
  • How to set up a new SBT project.
  • Understanding the basic project structure.
  • Configuring fundamental settings in build.sbt.
  • Running your first Scala application using SBT commands.

Next, we'll explore how to manage external libraries and use SBT plugins to extend your project's capabilities!

Sıkça Sorulan Sorular

“SBT Projesi Kurulumu ve Temelleri” dersi ücretsiz mi?

Evet — “SBT Projesi Kurulumu ve Temelleri” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Scala for Backend Engineering & Functional Programming kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Scala for Backend Engineering & Functional Programming kursu toplamda 3 dersten oluşur.

“SBT Projesi Kurulumu ve Temelleri” dersinde ne öğreneceğim?

Yeni SBT projelerini başlatmayı, ayarları tanımlamayı ve yaygın derleme görevlerini yürütmeyi öğrenin. Scala for Backend Engineering & Functional Programming ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Scala for Backend Engineering & Functional Programming öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Scala for Backend Engineering & Functional Programming, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 3 dersinin 1. dersidir.

“SBT Projesi Kurulumu ve Temelleri” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Scala for Backend Engineering & Functional Programming dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Scala for Backend Engineering & Functional Programming dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. SBT Projesi Kurulumu ve Temelleri
  2. Bağımlılık Yönetimi ve Eklentiler
  3. Çok Projeli Derlemeler ve Dağıtım
← Scala for Backend Engineering & Functional Programming Sayfasına Dön