Jeff Gaston | 9cfb0a1 | 2019-11-06 17:50:14 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The Android Open Source Project |
| 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 | def findGradleKotlinDsl() { |
| 18 | // TODO(137044144): After we convert this file to Kotlin (build.gradle.kts), we can just |
| 19 | // directly call the getGradleKotlinDsl() method. |
| 20 | // We're not doing that yet though because Gradle takes more time to process .kts files (at the |
| 21 | // time of writing, adding a .kts file adds roughly 10 addition seconds to build startup time). |
Jeff Gaston | 28add7b | 2019-11-07 14:05:22 -0500 | [diff] [blame^] | 22 | def kotlinDsl = "" + project.gradle.getGradleHomeDir() + "/lib/gradle-kotlin-dsl-" + |
| 23 | project.gradle.getGradleVersion() + ".jar" |
Jeff Gaston | 9cfb0a1 | 2019-11-06 17:50:14 -0500 | [diff] [blame] | 24 | if (!project.file(kotlinDsl).exists()) { |
| 25 | throw new GradleException("Kotlin dsl jar does not exist: " + kotlinDsl) |
| 26 | } |
| 27 | return project.files(kotlinDsl) |
| 28 | } |
| 29 | |
| 30 | ext.findGradleKotlinDsl = this.&findGradleKotlinDsl |