1 /* 2 * Copyright 2021 Google LLC 3 * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 @file:Suppress("DataClassPrivateConstructor") 18 19 package com.google.devtools.ksp.gradle.testing 20 21 /** 22 * Value class to hold a plugin declaration information. 23 * 24 * When the project runner is created, [KspIntegrationTestRule] makes necessary updates on the 25 * gradle files to add the plugin. 26 * 27 * To create an instance, use the helper methods in the companion. 28 */ 29 data class PluginDeclaration private constructor( 30 val text: String, 31 val version: String 32 ) { toCodenull33 fun toCode() = text 34 35 companion object { 36 /** 37 * Creates a plugin declaration with the given id and version. 38 */ 39 fun id(id: String, version: String) = PluginDeclaration("id(\"$id\")", version) 40 41 /** 42 * Creates a kotlin plugin declaration with the given id and version. 43 */ 44 fun kotlin(id: String, version: String) = PluginDeclaration("kotlin(\"$id\")", version) 45 } 46 } 47