Skip to content

Commit e763451

Browse files
committed
feat(Meta): Add ability to disable plugin.yml generation
1 parent cc11dcc commit e763451

File tree

5 files changed

+44
-3
lines changed

5 files changed

+44
-3
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ bukkit {
4949
}
5050
```
5151

52+
### Smarter plugin.yml generation
53+
54+
BukkitGradle will not "eat" your existing plugin.yml file.
55+
Its content will be used if you've not configured `bukkit.meta` in BukkitGradle.
56+
57+
If you don't want plugin.yml generation at all, you can disable it:
58+
```kotlin
59+
bukkit {
60+
disableMetaGeneration()
61+
}
62+
```
63+
5264
### Re-written in Kotlin
5365
The plugin has been converted to Kotlin to make support easier.
5466
The plugin still can be configured with Groovy DSL but

src/main/kotlin/Bukkit.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ public interface Bukkit {
1313

1414
/** Bukkit version. */
1515
public val apiVersion: String
16+
17+
/** Plugin Meta generation enabled. */
18+
public val generateMeta: Boolean
1619
}

src/main/kotlin/BukkitExtension.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ import ru.endlesscode.bukkitgradle.server.extension.ServerConfigurationImpl
1212

1313
// TODO 1.0: Remove deprecated fields on release
1414
public open class BukkitExtension(
15-
public override val meta: PluginMetaImpl,
16-
public override val server: ServerConfigurationImpl
15+
public final override val meta: PluginMetaImpl,
16+
public final override val server: ServerConfigurationImpl
1717
) : Bukkit {
1818

19-
public override var apiVersion: String = ServerConstants.DEFAULT_VERSION
19+
public final override var apiVersion: String = ServerConstants.DEFAULT_VERSION
20+
21+
public final override var generateMeta: Boolean = true
22+
private set
2023

2124
private val logger = LoggerFactory.getLogger("BukkitExtension")
2225

@@ -54,6 +57,11 @@ public open class BukkitExtension(
5457
logger.warnSyntaxChanged("bukkit.version = '...'", "bukkit.apiVersion = '...'")
5558
apiVersion = version
5659
}
60+
61+
/** Disabled plugin.yml generation. */
62+
public fun disableMetaGeneration() {
63+
generateMeta = false
64+
}
5765
}
5866

5967
internal val Project.bukkit: Bukkit get() = extensions.getByType()

src/main/kotlin/meta/PluginMetaPlugin.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@ public class PluginMetaPlugin : Plugin<Project> {
3232
this.yaml = yaml
3333
this.meta = project.bukkit.meta as PluginMetaImpl
3434
this.metaFile.set(metaFile)
35+
36+
onlyIf { project.bukkit.generateMeta }
3537
}
3638

3739
val mergePluginMeta = project.tasks.register<MergePluginMeta>("mergePluginMeta") {
3840
this.yaml = yaml
3941
meta = project.bukkit.meta
4042
metaYaml.set(parsePluginMeta.map { it.pluginMetaYaml.get() })
4143
dependsOn(parsePluginMeta)
44+
45+
onlyIf { project.bukkit.generateMeta }
4246
}
4347

4448
project.tasks.named<CopySpec>("processResources").configure {

src/test/groovy/ru/endlesscode/bukkitgradle/meta/task/MergePluginMetaSpec.groovy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ class MergePluginMetaSpec extends PluginSpecification {
3333
taskOutcome(":parsePluginMetaFile") == TaskOutcome.SUCCESS
3434
}
3535

36+
def 'when run processResources - and meta generation disabled - should not run generatePluginMeta'() {
37+
given: "meta generation disabled"
38+
buildFile << "bukkit.disableMetaGeneration()"
39+
40+
when: "run processResources"
41+
run(':processResources')
42+
43+
then: "task generatePluginMeta completed successfully"
44+
taskOutcome(TASK_PATH) == TaskOutcome.SKIPPED
45+
46+
and: "task generatePluginMeta completed successfully"
47+
taskOutcome(":parsePluginMetaFile") == TaskOutcome.SKIPPED
48+
}
49+
3650
def 'when merge meta - should generate default plugin meta successfully'() {
3751
when: "run generate meta task"
3852
run(TASK_PATH)

0 commit comments

Comments
 (0)