|
| 1 | +/* |
| 2 | + * Run Task Gradle Plugins |
| 3 | + * Copyright (c) 2021-2022 Jason Penilla |
| 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 | +package xyz.jpenilla.runtask.task |
| 18 | + |
| 19 | +import org.gradle.api.file.ConfigurableFileCollection |
| 20 | +import org.gradle.api.file.RegularFile |
| 21 | +import org.gradle.api.provider.Provider |
| 22 | +import org.gradle.api.tasks.Classpath |
| 23 | +import xyz.jpenilla.runtask.RunExtension |
| 24 | +import java.io.File |
| 25 | + |
| 26 | +/** |
| 27 | + * Base task for runs which load a collection of plugin jars. |
| 28 | + * |
| 29 | + * Note that this class does not actually do anything to load |
| 30 | + * the plugins in [pluginJars], it's expected that subclasses |
| 31 | + * will implement this behavior in [preExec]. |
| 32 | + */ |
| 33 | +public abstract class RunWithPlugins : AbstractRun() { |
| 34 | + |
| 35 | + /** |
| 36 | + * The collection of plugin jars to load. |
| 37 | + * |
| 38 | + * @see [RunExtension.detectPluginJar] |
| 39 | + */ |
| 40 | + @get:Classpath |
| 41 | + public abstract val pluginJars: ConfigurableFileCollection |
| 42 | + |
| 43 | + /** |
| 44 | + * Convenience method for easily adding jars to [pluginJars]. |
| 45 | + * |
| 46 | + * @param jars jars to add |
| 47 | + */ |
| 48 | + public fun pluginJars(vararg jars: File) { |
| 49 | + pluginJars.from(jars) |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Convenience method for easily adding jars to [pluginJars]. |
| 54 | + * |
| 55 | + * @param jars jars to add |
| 56 | + */ |
| 57 | + public fun pluginJars(vararg jars: Provider<RegularFile>) { |
| 58 | + pluginJars.from(jars) |
| 59 | + } |
| 60 | +} |
0 commit comments