Course map
Stage 1: Foundation
Stage 2: Intermediate
Stage 3: Advanced
Stage 4: DSA in Kotlin
Stage 5: Specialization

Part 11 / Topic 2 of 9

Project layout: src/main/kotlin, src/test/kotlin

Gradle's Kotlin plugin expects a specific folder shape by convention — follow it and there's nothing to configure; deviate and you're writing extra config to tell Gradle where to look.

project-layout/
├── settings.gradle.kts
├── build.gradle.kts
└── src/
    ├── main/kotlin/com/stepshala/billing/DiscountCalculator.kt
    └── test/kotlin/com/stepshala/billing/
        ├── DiscountCalculatorTest.kt
        └── DiscountCalculatorParamTest.kt
  • src/main/kotlin — the real code: DiscountCalculator.kt's membershipDiscountPercent and finalBill, the Stage 1 discount calculator promoted into its own module.
  • src/test/kotlin — test code only. It's a separate source set: it can see everything in src/main/kotlin, but nothing in src/main/kotlin can see it back, and test code never ships inside the production artifact.
  • The package-matching subfolders (com/stepshala/billing/) aren't required by the compiler the way they are in Java, but Gradle, IDEs, and every real Kotlin project use them anyway — it's how you find a file by its package name instantly.

Full project: examples/project-layout/.

Done here? The practice set for Part 11 — including the solutions — is on the part page.

Search the guide