kotlin vscode配置
Insatll kotlin
brew update
brew install kotlin
kotlinc -version
info: kotlinc-jvm 1.6.10 (JRE 17.0.2+0)
vscode Install extensions


run code
create hello.kt file
fun main(args: Array<String>) {
    println("Hello, World!")
    println("Hello 简单教程!")
}
run code
[Running] cd "/Users/cookiywang/Desktop/" && kotlinc hello.kt -include-runtime -d hello.jar && java -jar hello.jar
hello.kt:1:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^
Hello, World!
Hello 简单教程!
[Done] exited with code=0 in 6.485 seconds
Run the init task
$ gradle init
Select type of project to generate:
  1: basic
  2: application
  3: library
  4: Gradle plugin
Enter selection (default: basic) [1..4] 2
Select implementation language:
  1: C++
  2: Groovy
  3: Java
  4: Kotlin
  5: Scala
  6: Swift
Enter selection (default: Java) [1..6] 4
Select build script DSL:
  1: Groovy
  2: Kotlin
Enter selection (default: Groovy) [1..2] 1
Project name (default: demo):
Source package (default: demo):
BUILD SUCCESSFUL
2 actionable tasks: 2 executed
Run the application
./gradlew run
> Task :app:run
Hello World!
BUILD SUCCESSFUL in 13s
2 actionable tasks: 2 executed
Install Gradle
❯ java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
brew install gradle
Verifying installation
 gradle -v
------------------------------------------------------------
Gradle 7.4
------------------------------------------------------------
Build time:   2022-02-08 09:58:38 UTC
Revision:     f0d9291c04b90b59445041eaa75b2ee744162586
Kotlin:       1.5.31
Groovy:       3.0.9
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          17.0.2 (Homebrew 17.0.2+0)
OS:           Mac OS X 12.2.1 x86_64
Bundle the application
./gradlew build
BUILD SUCCESSFUL in 3s
8 actionable tasks: 7 executed, 1 up-to-date
Publish a Build Scan
./gradlew build --scan
BUILD SUCCESSFUL in 0s
8 actionable tasks: 8 executed
Publishing a build scan to scans.gradle.com requires accepting the Gradle Terms of Service defined at https://gradle.com/terms-of-service.
Do you accept these terms? [yes, no] yes
Gradle Terms of Service accepted.
Publishing build scan...
https://gradle.com/s/5u4w3gxeurtd2
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号