Skip to content

Commit

Permalink
1.1.2: Add/fix Adventure stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
srnyx committed Jul 7, 2023
1 parent 153273d commit fe0ecfa
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
40 changes: 30 additions & 10 deletions src/main/kotlin/xyz/srnyx/gradlegalaxy/data/AdventureDependency.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<ExternalModuleDependency> = 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<AdventureDependency> = 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<AdventureDependency> = arrayOf(
AdventureDependency(AdventureComponent.Text.Serializer.LEGACY, textSerializerLegacyVersion, configuration) {
exclude("org.jetbrains", "annotations")
},
AdventureDependency(AdventureComponent.Platform.BUKKIT, platformBukkitVersion, configuration))
}
}
10 changes: 4 additions & 6 deletions src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,21 @@ fun Project.annoyingAPI(
vararg adventureDependencies: AdventureDependency = emptyArray(),
adventureConfigurationAll: String? = null,
annoyingApiConfiguration: String = "implementation",
configurationAction: Action<ExternalModuleDependency> = 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()
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Scripts.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -248,15 +247,15 @@ 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<String>? = setOf("plugin.yml"),
replacements: Map<String, String>? = getSentinelReplacements(),
textEncoding: String? = "UTF-8",
archiveClassifier: String? = "",
configuration: String = "implementation",
configurationAction: Action<ExternalModuleDependency> = Action {}
configurationAction: ExternalModuleDependency.() -> Unit = {},
): ExternalModuleDependency {
check(hasShadowPlugin()) { "Shadow plugin is required for Annoying API!" }
setupMC(group, version, description, javaVersion, replacementFiles, replacements, textEncoding, archiveClassifier)
Expand Down

0 comments on commit fe0ecfa

Please sign in to comment.