From aa146cdd5f18771cc491771fa6af75a2fc5334c2 Mon Sep 17 00:00:00 2001 From: Michael H Date: Wed, 29 Mar 2023 23:57:43 +0200 Subject: [PATCH] Add Folia devbundle extension --- .../PaperweightUserDependenciesExtension.kt | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/PaperweightUserDependenciesExtension.kt b/paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/PaperweightUserDependenciesExtension.kt index e16e931..1c26289 100644 --- a/paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/PaperweightUserDependenciesExtension.kt +++ b/paperweight-userdev/src/main/kotlin/io/papermc/paperweight/userdev/PaperweightUserDependenciesExtension.kt @@ -63,6 +63,36 @@ abstract class PaperweightUserDependenciesExtension( return dep } + /** + * Adds a dependency on Folia's dev bundle to the dev bundle [org.gradle.api.artifacts.Configuration]. + * + * @param version dependency version + * @param group dependency group + * @param artifactId dependency artifactId + * @param configuration dependency configuration + * @param classifier dependency classifier + * @param ext dependency extension + * @param devBundleConfigurationName name of the dev bundle [org.gradle.api.artifacts.Configuration] + * @param configurationAction action configuring the dependency + * @return dependency + */ + @JvmOverloads + fun foliaDevBundle( + version: String? = null, + group: String = "dev.folia", + artifactId: String = "dev-bundle", + configuration: String? = null, + classifier: String? = null, + ext: String? = null, + devBundleConfigurationName: String = DEV_BUNDLE_CONFIG, + configurationAction: Action = nullAction() + ): ExternalModuleDependency { + val dep = dependencies.create(group, artifactId, version, configuration, classifier, ext) + configurationAction(dep) + dependencies.add(devBundleConfigurationName, dep) + return dep + } + /** * Adds a dependency to the dev bundle [org.gradle.api.artifacts.Configuration]. * @@ -125,6 +155,49 @@ abstract class PaperweightUserDependenciesExtension( dependencies.addProvider(DEV_BUNDLE_CONFIG, version.map { "io.papermc.paper:dev-bundle:$it" }, configurationAction) } + /** + * Adds a dependency on the Folia dev bundle to the [DEV_BUNDLE_CONFIG] configuration. + * + * Intended for use with Gradle version catalogs. + * + * @param version version provider + * @param configurationAction action configuring the dependency + */ + @JvmOverloads + fun foliaDevBundle( + version: Provider, + configurationAction: Action = nullAction() + ) { + dependencies.addProvider(DEV_BUNDLE_CONFIG, version.map { "dev.folia:dev-bundle:$it" }, configurationAction) + } + + /** + * Creates a Folia dev bundle dependency without adding it to any configurations. + * + * @param version dependency version + * @param group dependency group + * @param artifactId dependency artifactId + * @param configuration dependency configuration + * @param classifier dependency classifier + * @param ext dependency extension + * @param configurationAction action configuring the dependency + * @return dependency + */ + @JvmOverloads + fun foliaDevBundleDependency( + version: String? = null, + group: String = "dev.folia", + artifactId: String = "dev-bundle", + configuration: String? = null, + classifier: String? = null, + ext: String? = null, + configurationAction: Action = nullAction() + ): ExternalModuleDependency { + val dep = dependencies.create(group, artifactId, version, configuration, classifier, ext) + configurationAction(dep) + return dep + } + /** * Creates a Paper dev bundle dependency without adding it to any configurations. *