1 /* 2 * Copyright (c) Meta Platforms, Inc. and affiliates. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 import com.ncorti.ktfmt.gradle.tasks.KtfmtCheckTask 18 import com.ncorti.ktfmt.gradle.tasks.KtfmtFormatTask 19 <lambda>null20plugins { 21 kotlin("jvm") version "1.8.22" 22 id("com.ncorti.ktfmt.gradle") version "0.19.0" 23 } 24 <lambda>null25repositories { 26 mavenLocal() 27 mavenCentral() 28 } 29 30 val ktfmtVersion = rootProject.file("../version.txt").readText().trim() 31 <lambda>null32dependencies { 33 implementation("com.facebook:ktfmt:$ktfmtVersion") 34 implementation(platform("software.amazon.awssdk:bom:2.10.73")) 35 implementation("software.amazon.awssdk:lambda") 36 implementation("com.amazonaws:aws-lambda-java-core:1.2.1") 37 implementation("com.amazonaws:aws-lambda-java-events:2.2.9") 38 implementation("com.google.code.gson:gson:2.8.6") 39 testImplementation(kotlin("test-junit")) 40 } 41 <lambda>null42kotlin { jvmToolchain(17) } 43 <lambda>null44tasks { 45 test { useJUnit() } 46 47 val packageFat by 48 creating(Zip::class) { 49 from(compileKotlin) 50 from(processResources) 51 into("lib") { from(configurations.runtimeClasspath) } 52 dirMode = 0b111101101 // 0755 53 fileMode = 0b111101101 // 0755 54 } 55 56 val packageLibs by 57 creating(Zip::class) { 58 into("java/lib") { from(configurations.runtimeClasspath) } 59 dirMode = 0b111101101 // 0755 60 fileMode = 0b111101101 // 0755 61 } 62 63 val packageSkinny by 64 creating(Zip::class) { 65 from(compileKotlin) 66 from(processResources) 67 } 68 69 build { dependsOn(packageSkinny) } 70 71 // Set up ktfmt formatting tasks 72 val ktfmtFormatKts by 73 creating(KtfmtFormatTask::class) { 74 source = fileTree(rootDir) 75 include("**/*.kts") 76 } 77 val ktfmtCheckKts by 78 creating(KtfmtCheckTask::class) { 79 source = fileTree(rootDir) 80 include("**/*.kts") 81 mustRunAfter("compileKotlin") 82 mustRunAfter("compileTestKotlin") 83 mustRunAfter("test") 84 } 85 val ktfmtFormat by getting { dependsOn(ktfmtFormatKts) } 86 val ktfmtCheck by getting { dependsOn(ktfmtCheckKts) } 87 val check by getting { dependsOn(ktfmtCheck) } 88 } 89