Skip to content

Commit

Permalink
add examples for both java and kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
Revxrsal committed Dec 21, 2024
1 parent 63df1d8 commit b298920
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
id("java")
}

group = "com.example"
version = "0.0.0"

repositories {
mavenCentral()
}
30 changes: 30 additions & 0 deletions examples/bukkit-java/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
}
16 changes: 16 additions & 0 deletions examples/bukkit-java/src/main/java/com/example/ExamplePlugin.java
Original file line number Diff line number Diff line change
@@ -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() {
}
}
4 changes: 4 additions & 0 deletions examples/bukkit-java/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: ExamplePlugin
main: com.example.ExamplePlugin
version: 0.0.0
author: Example Author
35 changes: 35 additions & 0 deletions examples/bukkit-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}
19 changes: 19 additions & 0 deletions examples/bukkit-kotlin/src/main/java/com/example/ExamplePlugin.kt
Original file line number Diff line number Diff line change
@@ -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() {
}
}
4 changes: 4 additions & 0 deletions examples/bukkit-kotlin/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: ExamplePlugin
main: com.example.ExamplePlugin
version: 0.0.0
author: Example Author
20 changes: 20 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit b298920

Please sign in to comment.