diff --git a/build.gradle.kts b/build.gradle.kts index f6d5043..ad99962 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,7 @@ plugins { } group = "xyz.srnyx" -version = "1.1.1" +version = "1.1.2" description = "A Gradle plugin to simplify the process of creating projects" val projectId: String = "gradle-galaxy" val vcs: String = "github.com/srnyx/$projectId" diff --git a/src/main/kotlin/xyz/srnyx/gradlegalaxy/data/AdventureDependency.kt b/src/main/kotlin/xyz/srnyx/gradlegalaxy/data/AdventureDependency.kt index 2ca7e63..2d7aeb0 100644 --- a/src/main/kotlin/xyz/srnyx/gradlegalaxy/data/AdventureDependency.kt +++ b/src/main/kotlin/xyz/srnyx/gradlegalaxy/data/AdventureDependency.kt @@ -1,7 +1,7 @@ package xyz.srnyx.gradlegalaxy.data -import org.gradle.api.Action import org.gradle.api.artifacts.ExternalModuleDependency +import org.gradle.kotlin.dsl.exclude import xyz.srnyx.gradlegalaxy.enums.AdventureComponent import xyz.srnyx.gradlegalaxy.enums.Component @@ -15,33 +15,53 @@ import xyz.srnyx.gradlegalaxy.enums.Component * @param configuration The configuration to add the dependency to * @param configurationAction The action to apply to the dependency */ -data class AdventureDependency(val component: Component, val version: String, val configuration: String? = null, val configurationAction: Action = Action {}) { +data class AdventureDependency(val component: Component, val version: String, val configuration: String? = null, val configurationAction: ExternalModuleDependency.() -> Unit = {}) { companion object { /** - * Gets the default dependencies for Adventure for Annoying API + * Gets the default Adventure dependencies for Annoying API (Spigot) * * @param configuration The configuration to add the dependencies to * @param apiVersion The version of [AdventureComponent.API] to depend on * @param textMinimessageVersion The version of [AdventureComponent.Text.MINIMESSAGE] to depend on * @param textSerializerLegacyVersion The version of [AdventureComponent.Text.Serializer.LEGACY] to depend on - * @param platformBungeecordVersion The version of [AdventureComponent.Platform.BUNGEECORD] to depend on + * @param textSerializerPlainVersion The version of [AdventureComponent.Text.Serializer.PLAIN] to depend on + * @param platformBukkitVersion The version of [AdventureComponent.Platform.BUKKIT] to depend on + * @param textLoggerSlf4j The version of [AdventureComponent.Text.Logger.SLF4J] to depend on * - * @return The default dependencies for Adventure for Annoying API + * @return The default Adventure dependencies for Annoying API (Spigot) */ - fun getDefaultAnnoying( + fun getDefaultAnnoyingSpigot( configuration: String = "implementation", apiVersion: String = "4.14.0", textMinimessageVersion: String = "4.14.0", textSerializerLegacyVersion: String = "4.14.0", textSerializerPlainVersion: String = "4.14.0", platformBukkitVersion: String = "4.3.0", - platformBungeecordVersion: String = "4.3.0", + textLoggerSlf4j: String = "4.14.0", ): Array = arrayOf( + *getDefaultAnnoyingPaper(configuration, textSerializerLegacyVersion, platformBukkitVersion), AdventureDependency(AdventureComponent.API, apiVersion, configuration), AdventureDependency(AdventureComponent.Text.MINIMESSAGE, textMinimessageVersion, configuration), - AdventureDependency(AdventureComponent.Text.Serializer.LEGACY, textSerializerLegacyVersion, configuration), AdventureDependency(AdventureComponent.Text.Serializer.PLAIN, textSerializerPlainVersion, configuration), - AdventureDependency(AdventureComponent.Platform.BUKKIT, platformBukkitVersion, configuration), - AdventureDependency(AdventureComponent.Platform.BUNGEECORD, platformBungeecordVersion, configuration)) + AdventureDependency(AdventureComponent.Text.Logger.SLF4J, textLoggerSlf4j, configuration)) + + /** + * Gets the default Adventure dependencies for Annoying API (Paper) + * + * @param configuration The configuration to add the dependencies to + * @param textSerializerLegacyVersion The version of [AdventureComponent.Text.Serializer.LEGACY] to depend on + * @param platformBukkitVersion The version of [AdventureComponent.Platform.BUKKIT] to depend on + * + * @return The default Adventure dependencies for Annoying API (Paper) + */ + fun getDefaultAnnoyingPaper( + configuration: String = "implementation", + textSerializerLegacyVersion: String = "4.14.0", + platformBukkitVersion: String = "4.3.0", + ): Array = arrayOf( + AdventureDependency(AdventureComponent.Text.Serializer.LEGACY, textSerializerLegacyVersion, configuration) { + exclude("org.jetbrains", "annotations") + }, + AdventureDependency(AdventureComponent.Platform.BUKKIT, platformBukkitVersion, configuration)) } } diff --git a/src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Dependencies.kt b/src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Dependencies.kt index bdcde2e..31eec74 100644 --- a/src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Dependencies.kt +++ b/src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Dependencies.kt @@ -120,23 +120,21 @@ fun Project.annoyingAPI( vararg adventureDependencies: AdventureDependency = emptyArray(), adventureConfigurationAll: String? = null, annoyingApiConfiguration: String = "implementation", - configurationAction: Action = Action {} + configurationAction: ExternalModuleDependency.() -> Unit = {} ): ExternalModuleDependency { check(hasJavaPlugin()) { "Java plugin is not applied!" } // Adventure - if (adventureDependencies.isNotEmpty()) { - adventure(*adventureDependencies, configurationAll = adventureConfigurationAll) - if (hasShadowPlugin()) relocate("net.kyori") - } + if (adventureDependencies.isNotEmpty()) adventure(*adventureDependencies, configurationAll = adventureConfigurationAll) // Annoying API repository(Repository.JITPACK) if (hasShadowPlugin()) relocate("xyz.srnyx.annoyingapi") return addDependencyTo(dependencies, annoyingApiConfiguration, "xyz.srnyx:annoying-api:$version") { + exclude("org.reflections") exclude("org.bstats", "bstats-bukkit") exclude("de.tr7zw", "item-nbt-api") - configurationAction.execute(this) + configurationAction() } } diff --git a/src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Scripts.kt b/src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Scripts.kt index fc936b2..60ac621 100644 --- a/src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Scripts.kt +++ b/src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Scripts.kt @@ -1,7 +1,6 @@ package xyz.srnyx.gradlegalaxy.utility import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -import org.gradle.api.Action import org.gradle.api.DefaultTask import org.gradle.api.JavaVersion @@ -248,7 +247,7 @@ fun Project.setupAnnoyingAPI( group: String = project.group.toString(), version: String = project.version.toString(), description: String? = project.description, - vararg adventureDependencies: AdventureDependency = AdventureDependency.getDefaultAnnoying(), + vararg adventureDependencies: AdventureDependency = AdventureDependency.getDefaultAnnoyingSpigot(), adventureConfigurationAll: String? = null, javaVersion: JavaVersion? = null, replacementFiles: Set? = setOf("plugin.yml"), @@ -256,7 +255,7 @@ fun Project.setupAnnoyingAPI( textEncoding: String? = "UTF-8", archiveClassifier: String? = "", configuration: String = "implementation", - configurationAction: Action = Action {} + configurationAction: ExternalModuleDependency.() -> Unit = {}, ): ExternalModuleDependency { check(hasShadowPlugin()) { "Shadow plugin is required for Annoying API!" } setupMC(group, version, description, javaVersion, replacementFiles, replacements, textEncoding, archiveClassifier)