Skip to content

Commit d3e7dd2

Browse files
authored
Use jpenilla/resource-factory to generate plugin.yml file (#66)
* Remove unused gradle-download-task dependency * Read defaults from existing plugin.yml * Apply JavaPlugin only if JavaBasePlugin wasn't applied before * Revise the quick start guide
1 parent f45fbd3 commit d3e7dd2

21 files changed

+839
-799
lines changed

CHANGELOG.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@
1010
Refactor development server implementation to use [jpenilla/run-task](https://github.com/jpenilla/run-task/) plugin and integrate run-paper for server execution,
1111
improving maintainability and compatibility with various server versions.
1212
- **Breaking change!**
13-
Rename `bukkit.meta { ... }` to `bukkit.plugin { ... }`.
14-
- Task `:parsePluginMetaFile` and `:mergePluginMeta` renamed to `:parsePluginYaml` and `:mergePluginYaml` respectively.
15-
- `bukkit.disableMetaGeneration()` replaced by `bukkit.plugin.disablePluginYamlGeneration()`
16-
- Package `.meta` renamed to `.plugin` to reflect this change
13+
Use [jpenilla/resource-factory](https://github.com/jpenilla/resource-factory) to generate `plugin.yml`.
14+
This change comes with some renames:
15+
- Configuration block `bukkit.meta { ... }` -> `bukkit.plugin { ... }`
16+
- Property `bukkit.plugin.url` -> `bukkit.plugin.website`
17+
- Task `:parsePluginMetaFile` -> `:parsePluginYaml`
18+
- Task `:mergePluginMeta` has been dropped. Use `:mainResourceFactory` instead
19+
- Package `ru.endlesscode.bukkitgradle.meta` -> `ru.endlesscode.bukkitgradle.plugin`
20+
- Change API for disabling `plugin.yml` generation:
21+
```diff
22+
-bukkit.disableMetaGeneration()
23+
+bukkit.generatePluginYaml.set(false)
24+
```
1725
- Set the default [JVM toolchain](https://docs.gradle.org/current/userguide/toolchains.html) version
1826
instead of setting JVM target and source compatibility to 1.8.
1927
By default, the minimal supported JVM version compatible with the specified `bukkit.server.version` is used.

README.md

Lines changed: 76 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gradle utilities to simplify Bukkit/Spigot plugins writing and debugging.
99

1010

1111
- [Installation](#installation)
12-
- [First steps](#first-steps)
12+
- [Quick Start](#quick-start)
1313
- [Configuration](#configuration)
1414
- [Repositories and Dependencies](#repositories-and-dependencies)
1515
- [Running Dev server](#running-dev-server)
@@ -21,7 +21,6 @@ Gradle utilities to simplify Bukkit/Spigot plugins writing and debugging.
2121
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
2222

2323
#### Features:
24-
- Automatically applies plugin: java
2524
- Sets up compiler encoding to UTF-8
2625
- Sets archivesBaseName to plugin name
2726
- Supports APIs: Bukkit, CraftBukkit, Spigot, Paper
@@ -35,33 +34,22 @@ Gradle utilities to simplify Bukkit/Spigot plugins writing and debugging.
3534

3635
## Installation
3736

38-
[BukkitGradle on plugins.gradle.org](https://plugins.gradle.org/plugin/ru.endlesscode.bukkitgradle)
39-
> **Note:** Gradle 8.0+ is required
37+
> [!NOTE]
38+
> BukkitGradle requires Gradle 8.0+ to run
4039
41-
#### With new plugins mechanism
4240
```kotlin
4341
plugins {
4442
id("ru.endlesscode.bukkitgradle") version "0.10.1"
4543
}
4644
```
4745

48-
#### With buildscript and apply
49-
```groovy
50-
buildscript {
51-
repositories {
52-
mavenCentral()
53-
}
54-
dependencies {
55-
classpath("gradle.plugin.ru.endlesscode:bukkit-gradle:0.10.1")
56-
}
57-
}
46+
[BukkitGradle on plugins.gradle.org](https://plugins.gradle.org/plugin/ru.endlesscode.bukkitgradle)
5847

59-
apply(plugin: "ru.endlesscode.bukkitgradle")
60-
```
48+
<details>
6149

62-
#### Snapshots
50+
<summary>Using snapshots</summary>
6351

64-
If you want to use snapshots, you can add jitpack repository to `settings.gradle` and use version `develop-SNAPSHOT`:
52+
To use snapshots, add jitpack repository to the `settings.gradle.kts` and specify version `develop-SNAPSHOT`:
6553
```kotlin
6654
// settings.gradle
6755

@@ -82,88 +70,86 @@ plugins {
8270
}
8371
```
8472

85-
### First steps
86-
Simple `build.gradle` file that use BukkitGradle:
73+
</details>
74+
75+
### Quick Start
76+
77+
Apply the plugin and configure project's `group`, `description` and `version`.
78+
These values will be used to generate the `plugin.yml` file:
79+
8780
```kotlin
8881
plugins {
8982
id("ru.endlesscode.bukkitgradle") version "0.10.1"
9083
}
91-
92-
// Project information
84+
9385
group = "com.example.myplugin"
94-
description = "My first Bukkit plugin with Gradle"
86+
description = "My first Bukkit plugin built by Gradle"
9587
version = "0.1"
9688

97-
// Let's add needed API to project
89+
bukkit {
90+
apiVersion = "1.16.5"
91+
}
92+
93+
// Add the necessary API to the project
9894
dependencies {
9995
compileOnly(bukkitApi())
100-
// see section 'Dependencies' for more info
96+
// See the 'Dependencies' section for more info
10197
}
10298
```
103-
> **Note:** `compileOnly` - it's like `provided` scope in Maven.
104-
It means that this dependency will not be included to your final jar.
10599

106-
It's enough!
107-
Will be hooked the latest version of Bukkit and automatically generated `plugin.yml` with next content:
100+
That's it!
101+
During the plugin compilation `plugin.yml` will be generated with the following content:
102+
108103
```yaml
104+
api-version: '1.16'
109105
name: MyPlugin
110-
description: My first Bukkit plugin with Gradle
106+
version: '0.1'
111107
main: com.example.myplugin.MyPlugin
112-
version: 0.1
113-
api-version: 1.16
108+
description: My first Bukkit plugin built by Gradle
114109
```
115-
> **Note:** Main class built by following pattern: `<groupId>.<name>`
110+
111+
> [!NOTE]
112+
> By default, main class is built by the following pattern: `<groupId>.<name>`
113+
114+
Next, you might need to [configure](#configuration) `plugin.yml` content or [run dev server](#running-dev-server).
116115

117116
## Configuration
118-
You can configure attributes that will be placed to `plugin.yml`:
117+
118+
The `plugin.yml` content can be configured using `bukkit.plugin { ... }` block.
119+
119120
```kotlin
120-
// Override default configurations
121121
bukkit {
122-
// Version of API (if you will not set this property, will be used latest version at moment of BukkitGradle release)
122+
// Version of API. By default, 1.16.5 is used
123123
apiVersion = "1.15.2"
124124
125-
// Attributes for plugin.yml
125+
// Configure plugin.yml content
126126
plugin {
127-
name.set("MyPlugin")
128-
description.set("My amazing plugin, that doing nothing")
129-
main.set("com.example.plugin.MyPlugin")
130-
version.set("1.0")
131-
url.set("http://www.example.com") // Attribute website
132-
authors.set(["OsipXD", "Contributors"])
127+
name = "MyPlugin"
128+
description = "My amazing plugin"
129+
main = "com.example.plugin.MyPlugin"
130+
version = "1.0"
131+
authors = listOf("osipxd", "contributors")
132+
depend = listOf("Vault", "Mimic")
133133
}
134134
}
135135
```
136136

137-
Will be generated `plugin.yml` file:
138-
```yaml
139-
name: MyPlugin
140-
description: My amazing plugin, that doing nothing
141-
main: com.example.plugin.MyPlugin
142-
version: 1.0
143-
api-version: 1.15
144-
website: http://www.example.com
145-
authors: [OsipXD, Contributors]
146-
```
147-
148-
If you want to add unsupported by BukkitGradle attributes, like a `depend`, `commands` etc.
149-
Create `plugin.yml` file and put custom attributes there.
150-
151137
## Repositories and Dependencies
152-
BukkitGradle provides short extension-functions to add common repositories and dependencies.
153-
There are list of its.
154138

155-
Usage example:
139+
BukkitGradle provides shortcuts to add common repositories and dependencies:
140+
156141
```kotlin
157142
repositories {
158-
spigot() // Adds spigot repo
143+
spigot()
159144
}
160145
161146
dependencies {
162-
compileOnly(paperApi()) // Adds paper-api dependency
147+
compileOnly(paperApi())
163148
}
164149
```
165150

166-
#### Repositories:
151+
#### Repositories
152+
167153
Name | Url
168154
----------------|-------------------------------------------------------------------
169155
spigot | https://hub.spigotmc.org/nexus/content/repositories/snapshots/
@@ -176,7 +162,8 @@ dependencies {
176162
aikar | https://repo.aikar.co/content/groups/aikar/
177163
codemc | https://repo.codemc.org/repository/maven-public/
178164

179-
#### Dependencies:
165+
#### Dependencies
166+
180167
Some dependencies also add a repository needed for them.
181168

182169
Name | Signature | Adds repository
@@ -188,7 +175,7 @@ Some dependencies also add a repository needed for them.
188175

189176
**Note:** `$apiVersion` - is `${version}-R0.1-SNAPSHOT` (where `$version` is `bukkit.version`)
190177

191-
If you need more extension-functions, [create issue][issue].
178+
If you need more extension-functions, [file an issue][issue].
192179

193180
## Running Dev server
194181

@@ -263,29 +250,37 @@ bukkit {
263250

264251
## Migration Guide
265252

266-
### Upgrade from 0.8.x
253+
### Upgrade from 0.10.x
267254

268-
1. Update gradle to 6.6 or newer:
269-
```shell
270-
$ ./gradlew wrapper --gradle-version 6.7.1
271-
```
272-
1. Use syntax `.set` in `bukkit.meta` instead of `=`:
255+
1. Update Gradle to 8.0 or newer (the latest version is recommended):
256+
```shell
257+
./gradlew wrapper --gradle-version 8.13
258+
```
259+
260+
2. Replace deprecated and removed APIs:
273261
```diff
274262
bukkit {
275-
meta {
276-
- desctiption = "My plugin's description"
277-
+ description.set("My plugin's description")
263+
- meta {
264+
+ plugin {
265+
name = "MyPlugin"
266+
- url = "https://example.com/"
267+
+ website = "https://example.com/"
278268
}
279269
}
280-
```
270+
```
271+
272+
3. If you have `plugin.yml`, move it's content to `bukkit.plugin { ... }` block
273+
274+
### Upgrade from 0.8.x
275+
281276
1. Use `bukkit.apiVersion` instead of `bukkit.version`:
282277
```diff
283278
bukkit {
284279
- version = "1.16.4"
285280
+ apiVersion = "1.16.4"
286281
}
287282
```
288-
1. Use `build.server` block instead of `build.run`:
283+
2. Use `build.server` block instead of `build.run`:
289284
```diff
290285
bukkit {
291286
- run {
@@ -294,7 +289,7 @@ bukkit {
294289
}
295290
}
296291
```
297-
1. Update arguments assignment syntax:
292+
3. Update arguments assignment syntax:
298293
```diff
299294
bukkit {
300295
server {
@@ -304,7 +299,7 @@ bukkit {
304299
}
305300
}
306301
```
307-
1. Replace removed APIs:
302+
4. Replace removed APIs:
308303
```diff
309304
repositories {
310305
- destroystokyo()
@@ -319,8 +314,8 @@ bukkit {
319314
+ compileOnly(spigot())
320315
}
321316
```
322-
1. Remove `q` and `qq` functions calls in `meta { ... }`
323-
1. Check generated plugin.yml contents after build.
317+
5. Remove `q` and `qq` functions calls in `meta { ... }`
318+
6. Check generated plugin.yml contents after build.
324319

325320
If there are any problems, [create an issue][issue].
326321

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ repositories {
2929

3030
dependencies {
3131
implementation("xyz.jpenilla.run-paper:xyz.jpenilla.run-paper.gradle.plugin:2.3.1")
32-
implementation("de.undercouch:gradle-download-task:5.6.0")
32+
implementation("xyz.jpenilla.resource-factory:xyz.jpenilla.resource-factory.gradle.plugin:1.2.0")
3333
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1")
3434
implementation("com.charleskorn.kaml:kaml:0.74.0")
3535
testImplementation("junit:junit:4.13.1")

src/main/kotlin/Bukkit.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package ru.endlesscode.bukkitgradle
22

33
import org.gradle.api.provider.Provider
4-
import ru.endlesscode.bukkitgradle.plugin.extension.PluginConfiguration
4+
import ru.endlesscode.bukkitgradle.plugin.plugin
55
import ru.endlesscode.bukkitgradle.server.extension.ServerConfiguration
6+
import xyz.jpenilla.resourcefactory.bukkit.BukkitPluginYaml
67

78
public interface Bukkit {
89

9-
/** Plugin plugin. */
10-
public val plugin: PluginConfiguration
11-
1210
@Deprecated("Use 'plugin' field instead", ReplaceWith("plugin"))
13-
public val meta: PluginConfiguration
11+
public val meta: BukkitPluginYaml
1412
get() = plugin
1513

1614
/** Dev server configuration. */
@@ -20,7 +18,10 @@ public interface Bukkit {
2018
public val apiVersion: Provider<String>
2119

2220
/** Plugin Meta generation enabled. */
23-
@Deprecated("Use 'plugin.generatePluginYaml' instead", ReplaceWith("plugin.generatePluginYaml"))
21+
@Deprecated("Use 'generatePluginYaml' instead", ReplaceWith("generatePluginYaml"))
2422
public val generateMeta: Provider<Boolean>
25-
get() = plugin.generatePluginYaml
23+
get() = generatePluginYaml
24+
25+
/** Whether plugin.yml generation enabled or not. */
26+
public val generatePluginYaml: Provider<Boolean>
2627
}

0 commit comments

Comments
 (0)