Skip to content

Commit

Permalink
feat: use new spigradle debug task for running the server
Browse files Browse the repository at this point in the history
* Upgrade to Spigradle 1.4.1
* Use the new build & download Spigot/Paper task from Spigradle. This gets rid of the direct download links and builds spigot with the BuildTool.
  • Loading branch information
Silthus committed Jul 2, 2020
1 parent 5c0c38f commit d7a3f25
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 173 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -12,6 +12,7 @@ build/

# Server
working/*
debug/*
!working/server.properties
/.idea/

Expand Down
21 changes: 0 additions & 21 deletions .idea/runConfigurations/Deploy.xml

This file was deleted.

13 changes: 8 additions & 5 deletions .idea/runConfigurations/Server.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions .idea/runConfigurations/Setup_Server.xml

This file was deleted.

14 changes: 9 additions & 5 deletions Readme.md
Expand Up @@ -21,7 +21,7 @@ The template or better boilerplate comes with a lot of features that are useful

- Ready to use [**Gradle**](https://gradle.org/) project with lots of utility tasks
- Automatic **generation of `plugin.yaml`** based of project properties with [SpiGradle](https://github.com/EntryPointKR/Spigradle/)
- Integrated [**Spigot test server**](https://github.com/Tammo0987/Spigot-Workspace-Template) with a one click build, copy plugin and start debugging in IntelliJ task
- Integrated [**Spigot test server**](https://github.com/EntryPointKR/Spigradle/) with a one click build, copy plugin and start debugging in IntelliJ task
- [**Gradle shadow plugin**](https://imperceptiblethoughts.com/shadow/) to easily ship your needed dependencies with your plugin
- **[JUnit 5](https://junit.org/junit5/docs/current/user-guide/)** test setup including [MockBukkit](https://github.com/seeseemelk/MockBukkit) and [AssertJ](https://joel-costigliola.github.io/assertj/)
- **[Jacoco](https://github.com/jacoco/jacoco) code coverage** report including an upload task to [codecov](https://codecov.io/)
Expand Down Expand Up @@ -62,12 +62,16 @@ gpr.key=YOUR_PERSONAL_ACCESS_TOKEN

## Deploy Task

You can export your plugin to the plugins directory from your working directory with the Gradle **deploy task**. The task will **build and copy** your plugin **automatically**.
You can export your plugin to the plugins directory from your working directory with the Gradle **prepareSpigotPlugins** task. The task will **build and copy** your plugin **automatically** into the `plugins/` directory.

## Debugging the Server

You can use and debug the installed test server by running the Server run configuration. Every time you start the server, the plugin will be deployed. You can disable it, when you edit the Server run configuration.
You can run or debug the `Server` application from within IntelliJ to automatically download the Minecraft server, built it, copy your and dependent plugins into it and start it in debugging mode.

## Important info
This is due to the awesome power of Spigradle's spigot tasks. Find out more on the [Spigradle Github page](https://github.com/spigradle/spigradle).

By using this template and starting the server, you agree to the Minecraft EULA automatically, because in this template is the eula file, because then you dont have to agree manually.
## References

* [Spigradle](https://github.com/spigradle/spigradle/): *provides awesome gradle tasks that make your live a lot easier*
* [semantic-release](https://semantic-release.gitbook.io/semantic-release/): *in my opinion every project should use this!*
* [conventional commit messages](https://www.conventionalcommits.org/): *do commit message the right way*
78 changes: 5 additions & 73 deletions build.gradle
Expand Up @@ -7,7 +7,7 @@ buildscript {

plugins {
id 'com.github.johnrengelman.shadow' version '6.0.0'
id 'kr.entree.spigradle' version '1.2.4'
id 'kr.entree.spigradle' version '1.4.1'
id 'java'
id 'jacoco'
}
Expand Down Expand Up @@ -61,9 +61,6 @@ repositories {
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
}
}

//Add your repositories here
maven { url = "https://repo.aikar.co/content/groups/aikar/" }
}

dependencies {
Expand All @@ -75,10 +72,10 @@ dependencies {
//Add dependencies here

//Test dependencies
testImplementation 'org.junit.jupiter:junit-jupiter:5.6.2'
testImplementation 'org.junit.jupiter:junit-jupiter:5.+'
testImplementation "org.mockito:mockito-core:3.+"
testImplementation 'com.github.seeseemelk:MockBukkit-v1.15:0.3.0-SNAPSHOT'
testImplementation 'org.assertj:assertj-core:3.16.1'
testImplementation mockBukkit()
testImplementation 'org.assertj:assertj-core:3.+'
testImplementation lombok()
testAnnotationProcessor lombok()
}
Expand Down Expand Up @@ -108,69 +105,4 @@ processResources {
expand project.properties
}

task cleanPlugin() {
group 'deploy'
description 'Cleans the plugin in the working directory up'
delete "${rootProject.rootDir}/working/plugins/" + project.property("pluginName") + '*.jar'
}

task copyPluginYaml(type: Copy, dependsOn: spigotPluginYaml) {
from(new File(spigotPluginYaml.temporaryDir, "plugin.yml"))
into(sourceSets.test.resources.srcDirs[0])
}

tasks.test.dependsOn(copyPluginYaml)

task deploy(type: Copy, dependsOn: [
'cleanPlugin',
'jar'
]) {
group 'deploy'
description 'Exports you plugin to the plugin directory in your test server'

def pluginFolder = project.property('pluginFolder').toString()

from shadowJar
into pluginFolder.isEmpty() ? "${rootProject.rootDir}/working/plugins" : pluginFolder
}

task setupServer {
group 'server'
description 'Downloads the server jar'

def server = new File("${rootProject.rootDir}/working/server.jar")

if (server.exists()) {
server.delete()
}

def url = ''
switch (mcVersion) {
case '1.8.8':
url = 'https://cdn.getbukkit.org/spigot/spigot-1.8.8-R0.1-SNAPSHOT-latest.jar'
break

case '1.12.2':
url = 'https://cdn.getbukkit.org/spigot/spigot-1.12.2.jar'
break

case '1.13.2':
url = 'https://cdn.getbukkit.org/spigot/spigot-1.13.2.jar'
break

case '1.14.4':
url = 'https://cdn.getbukkit.org/spigot/spigot-1.14.4.jar'
break
case '1.15.2':
url = 'https://cdn.getbukkit.org/spigot/spigot-1.15.2.jar'
break
}

if (url.isEmpty()) {
throw new GradleException('NOT A SUPPORTED VERSION, PLEASE USE [1.8.8, 1.12.2, 1.13.2, 1.14.4, 1.15.2]!')
}

new URL(url).withInputStream { i -> server.withOutputStream { it << i } }
}

defaultTasks 'build', 'deploy'
defaultTasks 'build'
5 changes: 4 additions & 1 deletion src/main/java/net/silthus/template/TemplatePlugin.java
@@ -1,13 +1,16 @@
package net.silthus.template;

import java.io.File;
import kr.entree.spigradle.Plugin;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader;

import java.io.File;

@Plugin
public class TemplatePlugin extends JavaPlugin implements Listener {

public TemplatePlugin() {}
Expand Down
47 changes: 0 additions & 47 deletions working/server.properties

This file was deleted.

0 comments on commit d7a3f25

Please sign in to comment.