Skip to content

Commit d9ed648

Browse files
committed
Add dynamic library injection for plugin.yml
1 parent 6bfb4f7 commit d9ed648

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎build.gradle.kts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ tasks {
7474
"mcVersion" to mcVersion,
7575
"pluginId" to pluginId,
7676
"author" to author,
77-
"description" to project.description
77+
"description" to project.description,
78+
"bukkitLibraries" to '[' + bukkitLibraries.joinToString(",") { "\"$it\"" } + ']'
7879
)
7980
inputs.properties(props)
8081
filteringCharset = "UTF-8"
@@ -92,12 +93,19 @@ repositories {
9293
}
9394
}
9495

96+
val bukkitLibraries = mutableListOf<String>()
97+
98+
fun DependencyHandlerScope.bukkitLibrary(dependencyNotation: Any): Dependency? {
99+
bukkitLibraries.add(dependencyNotation.toString())
100+
return compileOnly(dependencyNotation)
101+
}
102+
95103
dependencies {
96104
@Suppress("VulnerableLibrariesLocal", "RedundantSuppression")
97105
compileOnly("io.papermc.paper:paper-api:${mcVersion}.build.+")
98106

99-
compileOnly("org.apache.httpcomponents:httpclient:4.5.14")
100-
compileOnly("org.apache.httpcomponents:httpmime:4.5.14")
107+
bukkitLibrary("org.apache.httpcomponents:httpclient:4.5.14")
108+
bukkitLibrary("org.apache.httpcomponents:httpmime:4.5.14")
101109
}
102110

103111
java {

‎src/main/resources/plugin.yml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ main: io.github.kiber2009.plugin.contentapi.ContentApiPlugin
44
api-version: $mcVersion
55
author: $author
66
description: $description
7-
libraries:
8-
- org.apache.httpcomponents:httpmime:4.5.14
7+
libraries: $bukkitLibraries

0 commit comments

Comments
 (0)