From b2989202e8cb22e0a9fdf24dac7efd837a3245eb Mon Sep 17 00:00:00 2001 From: Revxrsal Date: Sat, 21 Dec 2024 21:52:43 +0300 Subject: [PATCH] add examples for both java and kotlin --- examples/build.gradle.kts | 10 ++++++ examples/bukkit-java/build.gradle | 30 ++++++++++++++++ .../main/java/com/example/ExamplePlugin.java | 16 +++++++++ .../bukkit-java/src/main/resources/plugin.yml | 4 +++ examples/bukkit-kotlin/build.gradle.kts | 35 +++++++++++++++++++ .../main/java/com/example/ExamplePlugin.kt | 19 ++++++++++ .../src/main/resources/plugin.yml | 4 +++ settings.gradle.kts | 20 +++++++++++ 8 files changed, 138 insertions(+) create mode 100644 examples/build.gradle.kts create mode 100644 examples/bukkit-java/build.gradle create mode 100644 examples/bukkit-java/src/main/java/com/example/ExamplePlugin.java create mode 100644 examples/bukkit-java/src/main/resources/plugin.yml create mode 100644 examples/bukkit-kotlin/build.gradle.kts create mode 100644 examples/bukkit-kotlin/src/main/java/com/example/ExamplePlugin.kt create mode 100644 examples/bukkit-kotlin/src/main/resources/plugin.yml diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts new file mode 100644 index 0000000..81fb5ef --- /dev/null +++ b/examples/build.gradle.kts @@ -0,0 +1,10 @@ +plugins { + id("java") +} + +group = "com.example" +version = "0.0.0" + +repositories { + mavenCentral() +} diff --git a/examples/bukkit-java/build.gradle b/examples/bukkit-java/build.gradle new file mode 100644 index 0000000..d01d36c --- /dev/null +++ b/examples/bukkit-java/build.gradle @@ -0,0 +1,30 @@ +plugins { + id 'io.freefair.lombok' version '8.11' + id 'com.gradleup.shadow' version '8.3.2' + id 'io.github.revxrsal.zapper' version '1.0.0' +} + +group = 'com.example' +version = '0.0.0' + +repositories { + mavenCentral() + maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' } + maven { url = 'https://oss.sonatype.org/content/repositories/central' } + maven { url = 'https://hub.spigotmc.org/nexus/content/groups/public/' } +} + +dependencies { + zap 'com.zaxxer:HikariCP:6.2.1' + compileOnly 'org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT' +} + +zapper { + libsFolder = 'libs' + relocationPrefix = 'com.example.plugin.libs' + + repositories { includeProjectRepositories() } + + // relocation path is com.example.plugin.libs.hikaricp + relocate 'com.zaxxer.hikari', 'hikaricp' +} diff --git a/examples/bukkit-java/src/main/java/com/example/ExamplePlugin.java b/examples/bukkit-java/src/main/java/com/example/ExamplePlugin.java new file mode 100644 index 0000000..c461a9a --- /dev/null +++ b/examples/bukkit-java/src/main/java/com/example/ExamplePlugin.java @@ -0,0 +1,16 @@ +package com.example; + +import com.zaxxer.hikari.HikariConfig; +import revxrsal.zapper.ZapperJavaPlugin; + +public class ExamplePlugin extends ZapperJavaPlugin { + + @Override + public void onEnable() { + System.out.println(HikariConfig.class); + } + + @Override + public void onDisable() { + } +} diff --git a/examples/bukkit-java/src/main/resources/plugin.yml b/examples/bukkit-java/src/main/resources/plugin.yml new file mode 100644 index 0000000..a6b566b --- /dev/null +++ b/examples/bukkit-java/src/main/resources/plugin.yml @@ -0,0 +1,4 @@ +name: ExamplePlugin +main: com.example.ExamplePlugin +version: 0.0.0 +author: Example Author \ No newline at end of file diff --git a/examples/bukkit-kotlin/build.gradle.kts b/examples/bukkit-kotlin/build.gradle.kts new file mode 100644 index 0000000..3df4b08 --- /dev/null +++ b/examples/bukkit-kotlin/build.gradle.kts @@ -0,0 +1,35 @@ +plugins { + id("io.freefair.lombok") version "8.11" + id("com.gradleup.shadow") version "8.3.2" + id("io.github.revxrsal.zapper") version "1.0.0" + kotlin("jvm") +} + +group = "com.example" +version = "0.0.0" + +repositories { + mavenCentral() + maven(url = "https://oss.sonatype.org/content/repositories/snapshots") + maven(url = "https://oss.sonatype.org/content/repositories/central") + maven(url = "https://hub.spigotmc.org/nexus/content/groups/public/") +} + +dependencies { + zap(kotlin("stdlib-jdk8")) + compileOnly("org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT") +} + +zapper { + libsFolder = "libs" + relocationPrefix = "com.example.plugin.libs" + + repositories { includeProjectRepositories() } + + // relocation path is com.example.plugin.libs.kotlin + relocate("kotlin", "kotlin") +} + +kotlin { + jvmToolchain(8) +} \ No newline at end of file diff --git a/examples/bukkit-kotlin/src/main/java/com/example/ExamplePlugin.kt b/examples/bukkit-kotlin/src/main/java/com/example/ExamplePlugin.kt new file mode 100644 index 0000000..a60bd03 --- /dev/null +++ b/examples/bukkit-kotlin/src/main/java/com/example/ExamplePlugin.kt @@ -0,0 +1,19 @@ +package com.example + +import revxrsal.zapper.ZapperJavaPlugin + +class ExamplePlugin : ZapperJavaPlugin() { + + companion object { + init { + println("Kotlin is already loaded!") + } + } + + override fun onEnable() { + println("Hello from Kotlin!") + } + + override fun onDisable() { + } +} diff --git a/examples/bukkit-kotlin/src/main/resources/plugin.yml b/examples/bukkit-kotlin/src/main/resources/plugin.yml new file mode 100644 index 0000000..a6b566b --- /dev/null +++ b/examples/bukkit-kotlin/src/main/resources/plugin.yml @@ -0,0 +1,4 @@ +name: ExamplePlugin +main: com.example.ExamplePlugin +version: 0.0.0 +author: Example Author \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index c838bb5..cadc901 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -6,5 +6,25 @@ pluginManagement { } } +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" +} + include("api") include("gradle-plugin") + +/* + * -------- Example projects -------- + */ + +include("examples") + +val exampleProjects = listOf( + "bukkit-java", + "bukkit-kotlin", +) + +exampleProjects.forEach { project -> + include("examples:$project") + findProject(":examples:$project")?.name = project +}