Skip to content

Use jpenilla/resource-factory to generate plugin.yml file #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@
Refactor development server implementation to use [jpenilla/run-task](https://github.com/jpenilla/run-task/) plugin and integrate run-paper for server execution,
improving maintainability and compatibility with various server versions.
- **Breaking change!**
Rename `bukkit.meta { ... }` to `bukkit.plugin { ... }`.
- Task `:parsePluginMetaFile` and `:mergePluginMeta` renamed to `:parsePluginYaml` and `:mergePluginYaml` respectively.
- `bukkit.disableMetaGeneration()` replaced by `bukkit.plugin.disablePluginYamlGeneration()`
- Package `.meta` renamed to `.plugin` to reflect this change
Use [jpenilla/resource-factory](https://github.com/jpenilla/resource-factory) to generate `plugin.yml`.
This change comes with some renames:
- Configuration block `bukkit.meta { ... }` -> `bukkit.plugin { ... }`
- Property `bukkit.plugin.url` -> `bukkit.plugin.website`
- Task `:parsePluginMetaFile` -> `:parsePluginYaml`
- Task `:mergePluginMeta` has been dropped. Use `:mainResourceFactory` instead
- Package `ru.endlesscode.bukkitgradle.meta` -> `ru.endlesscode.bukkitgradle.plugin`
- Change API for disabling `plugin.yml` generation:
```diff
-bukkit.disableMetaGeneration()
+bukkit.generatePluginYaml.set(false)
```
- Set the default [JVM toolchain](https://docs.gradle.org/current/userguide/toolchains.html) version
instead of setting JVM target and source compatibility to 1.8.
By default, the minimal supported JVM version compatible with the specified `bukkit.server.version` is used.
Expand Down
157 changes: 76 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Gradle utilities to simplify Bukkit/Spigot plugins writing and debugging.


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

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

## Installation

[BukkitGradle on plugins.gradle.org](https://plugins.gradle.org/plugin/ru.endlesscode.bukkitgradle)
> **Note:** Gradle 8.0+ is required
> [!NOTE]
> BukkitGradle requires Gradle 8.0+ to run

#### With new plugins mechanism
```kotlin
plugins {
id("ru.endlesscode.bukkitgradle") version "0.10.1"
}
```

#### With buildscript and apply
```groovy
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("gradle.plugin.ru.endlesscode:bukkit-gradle:0.10.1")
}
}
[BukkitGradle on plugins.gradle.org](https://plugins.gradle.org/plugin/ru.endlesscode.bukkitgradle)

apply(plugin: "ru.endlesscode.bukkitgradle")
```
<details>

#### Snapshots
<summary>Using snapshots</summary>

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

Expand All @@ -82,88 +70,86 @@ plugins {
}
```

### First steps
Simple `build.gradle` file that use BukkitGradle:
</details>

### Quick Start

Apply the plugin and configure project's `group`, `description` and `version`.
These values will be used to generate the `plugin.yml` file:

```kotlin
plugins {
id("ru.endlesscode.bukkitgradle") version "0.10.1"
}

// Project information

group = "com.example.myplugin"
description = "My first Bukkit plugin with Gradle"
description = "My first Bukkit plugin built by Gradle"
version = "0.1"

// Let's add needed API to project
bukkit {
apiVersion = "1.16.5"
}

// Add the necessary API to the project
dependencies {
compileOnly(bukkitApi())
// see section 'Dependencies' for more info
// See the 'Dependencies' section for more info
}
```
> **Note:** `compileOnly` - it's like `provided` scope in Maven.
It means that this dependency will not be included to your final jar.

It's enough!
Will be hooked the latest version of Bukkit and automatically generated `plugin.yml` with next content:
That's it!
During the plugin compilation `plugin.yml` will be generated with the following content:

```yaml
api-version: '1.16'
name: MyPlugin
description: My first Bukkit plugin with Gradle
version: '0.1'
main: com.example.myplugin.MyPlugin
version: 0.1
api-version: 1.16
description: My first Bukkit plugin built by Gradle
```
> **Note:** Main class built by following pattern: `<groupId>.<name>`

> [!NOTE]
> By default, main class is built by the following pattern: `<groupId>.<name>`

Next, you might need to [configure](#configuration) `plugin.yml` content or [run dev server](#running-dev-server).

## Configuration
You can configure attributes that will be placed to `plugin.yml`:

The `plugin.yml` content can be configured using `bukkit.plugin { ... }` block.

```kotlin
// Override default configurations
bukkit {
// Version of API (if you will not set this property, will be used latest version at moment of BukkitGradle release)
// Version of API. By default, 1.16.5 is used
apiVersion = "1.15.2"

// Attributes for plugin.yml
// Configure plugin.yml content
plugin {
name.set("MyPlugin")
description.set("My amazing plugin, that doing nothing")
main.set("com.example.plugin.MyPlugin")
version.set("1.0")
url.set("http://www.example.com") // Attribute website
authors.set(["OsipXD", "Contributors"])
name = "MyPlugin"
description = "My amazing plugin"
main = "com.example.plugin.MyPlugin"
version = "1.0"
authors = listOf("osipxd", "contributors")
depend = listOf("Vault", "Mimic")
}
}
```

Will be generated `plugin.yml` file:
```yaml
name: MyPlugin
description: My amazing plugin, that doing nothing
main: com.example.plugin.MyPlugin
version: 1.0
api-version: 1.15
website: http://www.example.com
authors: [OsipXD, Contributors]
```

If you want to add unsupported by BukkitGradle attributes, like a `depend`, `commands` etc.
Create `plugin.yml` file and put custom attributes there.

## Repositories and Dependencies
BukkitGradle provides short extension-functions to add common repositories and dependencies.
There are list of its.

Usage example:
BukkitGradle provides shortcuts to add common repositories and dependencies:

```kotlin
repositories {
spigot() // Adds spigot repo
spigot()
}

dependencies {
compileOnly(paperApi()) // Adds paper-api dependency
compileOnly(paperApi())
}
```

#### Repositories:
#### Repositories

Name | Url
----------------|-------------------------------------------------------------------
spigot | https://hub.spigotmc.org/nexus/content/repositories/snapshots/
Expand All @@ -176,7 +162,8 @@ dependencies {
aikar | https://repo.aikar.co/content/groups/aikar/
codemc | https://repo.codemc.org/repository/maven-public/

#### Dependencies:
#### Dependencies

Some dependencies also add a repository needed for them.

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

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

If you need more extension-functions, [create issue][issue].
If you need more extension-functions, [file an issue][issue].

## Running Dev server

Expand Down Expand Up @@ -263,29 +250,37 @@ bukkit {

## Migration Guide

### Upgrade from 0.8.x
### Upgrade from 0.10.x

1. Update gradle to 6.6 or newer:
```shell
$ ./gradlew wrapper --gradle-version 6.7.1
```
1. Use syntax `.set` in `bukkit.meta` instead of `=`:
1. Update Gradle to 8.0 or newer (the latest version is recommended):
```shell
./gradlew wrapper --gradle-version 8.13
```

2. Replace deprecated and removed APIs:
```diff
bukkit {
meta {
- desctiption = "My plugin's description"
+ description.set("My plugin's description")
- meta {
+ plugin {
name = "MyPlugin"
- url = "https://example.com/"
+ website = "https://example.com/"
}
}
```
```

3. If you have `plugin.yml`, move it's content to `bukkit.plugin { ... }` block

### Upgrade from 0.8.x

1. Use `bukkit.apiVersion` instead of `bukkit.version`:
```diff
bukkit {
- version = "1.16.4"
+ apiVersion = "1.16.4"
}
```
1. Use `build.server` block instead of `build.run`:
2. Use `build.server` block instead of `build.run`:
```diff
bukkit {
- run {
Expand All @@ -294,7 +289,7 @@ bukkit {
}
}
```
1. Update arguments assignment syntax:
3. Update arguments assignment syntax:
```diff
bukkit {
server {
Expand All @@ -304,7 +299,7 @@ bukkit {
}
}
```
1. Replace removed APIs:
4. Replace removed APIs:
```diff
repositories {
- destroystokyo()
Expand All @@ -319,8 +314,8 @@ bukkit {
+ compileOnly(spigot())
}
```
1. Remove `q` and `qq` functions calls in `meta { ... }`
1. Check generated plugin.yml contents after build.
5. Remove `q` and `qq` functions calls in `meta { ... }`
6. Check generated plugin.yml contents after build.

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

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ repositories {

dependencies {
implementation("xyz.jpenilla.run-paper:xyz.jpenilla.run-paper.gradle.plugin:2.3.1")
implementation("de.undercouch:gradle-download-task:5.6.0")
implementation("xyz.jpenilla.resource-factory:xyz.jpenilla.resource-factory.gradle.plugin:1.2.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1")
implementation("com.charleskorn.kaml:kaml:0.74.0")
testImplementation("junit:junit:4.13.1")
Expand Down
15 changes: 8 additions & 7 deletions src/main/kotlin/Bukkit.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package ru.endlesscode.bukkitgradle

import org.gradle.api.provider.Provider
import ru.endlesscode.bukkitgradle.plugin.extension.PluginConfiguration
import ru.endlesscode.bukkitgradle.plugin.plugin
import ru.endlesscode.bukkitgradle.server.extension.ServerConfiguration
import xyz.jpenilla.resourcefactory.bukkit.BukkitPluginYaml

public interface Bukkit {

/** Plugin plugin. */
public val plugin: PluginConfiguration

@Deprecated("Use 'plugin' field instead", ReplaceWith("plugin"))
public val meta: PluginConfiguration
public val meta: BukkitPluginYaml
get() = plugin

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

/** Plugin Meta generation enabled. */
@Deprecated("Use 'plugin.generatePluginYaml' instead", ReplaceWith("plugin.generatePluginYaml"))
@Deprecated("Use 'generatePluginYaml' instead", ReplaceWith("generatePluginYaml"))
public val generateMeta: Provider<Boolean>
get() = plugin.generatePluginYaml
get() = generatePluginYaml

/** Whether plugin.yml generation enabled or not. */
public val generatePluginYaml: Provider<Boolean>
}
Loading
Loading