42

What is the purpose of using .kts files in Kotlin? Are these files included in the app bundle when releasing the app?

enter image description here

Abhimanyu
  • 11,351
  • 7
  • 51
  • 121
Sweta Jain
  • 3,248
  • 6
  • 30
  • 50

2 Answers2

59

.kt — normal source files, .kts — script files

You don't need the main function in a .kts file, It will be executed line by line just like a bash/python script.

The .kts files don't need separate compilation. You run them using the following command:

kotlinc -script <filename>.kts
hippietrail
  • 15,848
  • 18
  • 99
  • 158
Govinda Sakhare
  • 5,009
  • 6
  • 33
  • 74
11

.Kt and .Kts

  • They are all kotlin files that contain kotlin source code.
  • .kt file are assumed to be compiled by the kotlin compiler.
  • .Kts files are assumed to be executed by kotlin scriting support.

As Explained in kolinConf18

Paulodhiambo
  • 111
  • 1
  • 6