Skip to content

Commit 9836f8a

Browse files
authored
Update to v0.8.0
2 parents 68a63fb + 88c693b commit 9836f8a

File tree

10 files changed

+405
-135
lines changed

10 files changed

+405
-135
lines changed

PULL_REQUEST_TEMPLATE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
### Checklist:
3+
4+
- [ ] Have you read text of project license?
5+
- [ ] Have you described maked changes in README or wiki?
6+
- [ ] Have you added changelog?

README.md

Lines changed: 109 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
BukkitGradle [![Build Status](https://img.shields.io/travis/EndlessCodeGroup/BukkitGradle.svg)](https://travis-ci.org/EndlessCodeGroup/BukkitGradle) [![license](https://img.shields.io/github/license/EndlessCodeGroup/BukkitGradle.svg)](https://github.com/EndlessCodeGroup/BukkitGradle/blob/master/LICENSE)
1+
BukkitGradle [![Version](https://img.shields.io/github/release/EndlessCodeGroup/BukkitGradle/all.svg?style=flat-square)](https://plugins.gradle.org/plugin/ru.endlesscode.bukkitgradle) [![Build Status](https://img.shields.io/travis/EndlessCodeGroup/BukkitGradle.svg?style=flat-square)](https://travis-ci.org/EndlessCodeGroup/BukkitGradle) [![license](https://img.shields.io/github/license/EndlessCodeGroup/BukkitGradle.svg?style=flat-square)](https://github.com/EndlessCodeGroup/BukkitGradle/blob/master/LICENSE)
22
============
33
Gradle utilities for easier writing Bukkit plugins.
44

@@ -7,30 +7,32 @@ Gradle utilities for easier writing Bukkit plugins.
77
2. [Usage](#usage)
88
1. [First steps](#first-steps)
99
2. [Configuring plugin](#configuring-plugin)
10-
3. [Running Dev server](#running-dev-server)
10+
1. [Quotes around values](#quotes-around-values)
11+
3. [Repositories and Dependencies](#repositories-and-dependencies)
12+
4. [Running Dev server](#running-dev-server)
1113
1. [Server run configurations](#server-run-configurations)
1214

1315
#### Features:
1416
- Automatically applies plugins: java, idea, eclipse
1517
- Sets up compiler encoding to UTF-8
16-
- Adds repositories: mavenCentral, mavenLocal, spigot-repo, sk89q-repo
17-
- Provides short extension-functions to include bukkit/craftbukkit/spigot/spigot-api
18+
- Sets archivesBaseName to plugin name
19+
- Supports APIs: Bukkit, CraftBukkit, Spigot, Paper
20+
- Provides short extension-functions to add common repositories and dependencies
1821
- Generates plugin.yml from Gradle project information
1922
- Allows to run dev server from IDE
23+
- Supports two cores for dev server: Spigot and Paper
24+
- Automatically downloads and updates BuildTools or Paperclip
2025
- Automatically copies your plugin to plugins dir on server running
2126

2227
#### TODO:
23-
- Add extension function for PaperApi
24-
- Add possibility to use Paper/CraftBukkit as dev server core
25-
- Add automatically downloading of BuildTools
2628
- Add smart dependency system
2729

2830
## Apply plugin
2931
[BukkitGradle on plugins.gradle.org](https://plugins.gradle.org/plugin/ru.endlesscode.bukkitgradle)
3032
#### With new plugins mechanism
3133
```groovy
3234
plugins {
33-
id "ru.endlesscode.bukkitgradle" version "0.7.1"
35+
id "ru.endlesscode.bukkitgradle" version "0.8.0"
3436
}
3537
```
3638

@@ -41,7 +43,7 @@ buildscript {
4143
jcenter()
4244
}
4345
dependencies {
44-
classpath "gradle.plugin.ru.endlesscode:bukkit-gradle:0.7.1"
46+
classpath "gradle.plugin.ru.endlesscode:bukkit-gradle:0.8.0"
4547
}
4648
}
4749
@@ -55,18 +57,24 @@ You can clone [this example project](https://github.com/EndlessCodeGroup/BukkitG
5557
Simple `build.gradle` file that use BukkitGradle:
5658
```groovy
5759
plugins {
58-
id "ru.endlesscode.bukkitgradle" version "0.7.1"
60+
id "ru.endlesscode.bukkitgradle" version "0.8.0"
5961
}
6062
6163
// Project information
6264
group "com.example"
6365
description "My first Bukkit plugin with Gradle"
6466
version "0.1"
6567
68+
// Wee need to add some repos
69+
repositories {
70+
spigot()
71+
// see section 'Repositories' for more info
72+
}
73+
6674
// Let's add needed API to project
6775
dependencies {
6876
compileOnly bukkit()
69-
// You also can use craftbukkit(), spigot() and spigotApi()
77+
// see section 'Dependencies' for more info
7078
}
7179
```
7280
`compileOnly` - it's like provided scope in Maven. It means that this dependncy will not included to your final jar.
@@ -84,7 +92,7 @@ You can configure attributes that will be placed to `plugin.yml`:
8492
```groovy
8593
// Override default configurations
8694
bukkit {
87-
// Version of API (latest by default)
95+
// Version of API (if you will not set this property, will be used latest available)
8896
version = "1.12.2"
8997
9098
// Attributes for plugin.yml
@@ -112,17 +120,86 @@ authors: [OsipXD, Contributors]
112120
Also you can add custom (unsupported by BukkitGradle) attributes like a `depend` etc.
113121
Just create `plugin.yml` file and put custom attributes into.
114122

123+
#### Quotes around values
124+
In some cases you may need put meta value in quotes. For this you can use `q` and `qq` functions.
125+
126+
For example we have meta:
127+
```groovy
128+
meta {
129+
name = qq "Double Quoted Name"
130+
description = q "Single quoted description"
131+
url = "http://without.quot.es/"
132+
}
133+
```
134+
135+
And will be generated:
136+
```yaml
137+
name: "Double Quoted Name"
138+
description: 'Single quoted description'
139+
website: http://without.quot.es/
140+
```
141+
142+
**Note:** In Groovy you can use functions in two ways: normal - `q("value")` and without braces - `q "value"`
143+
144+
### Repositories and Dependencies
145+
BukkitGradle provides short extension-functions to add common repositories and dependencies.
146+
There are list of its.
147+
148+
Usage example:
149+
```groovy
150+
repositories {
151+
spigot() // Adds spigot repo
152+
}
153+
154+
dependencies {
155+
compileOnly paperApi() // Adds paper-api dependency
156+
}
157+
```
158+
159+
##### Repositories:
160+
Name | Url
161+
----------------|-------------------------------------------------------------------
162+
spigot | https://hub.spigotmc.org/nexus/content/repositories/snapshots/
163+
sk98q | http://maven.sk89q.com/repo/
164+
destroystokyo | https://repo.destroystokyo.com/repository/maven-public/
165+
dmulloy2 | http://repo.dmulloy2.net/nexus/repository/public/
166+
md5 | http://repo.md-5.net/content/groups/public/
167+
vault | http://nexus.hc.to/content/repositories/pub_releases/
168+
placeholderapi | http://repo.extendedclip.com/content/repositories/placeholderapi/
169+
170+
##### Dependencies:
171+
Some dependencies also applies repo that needed for them.
172+
173+
Name | Signature | Applies repo
174+
-------------|-----------------------------------------------|---------------
175+
spigot | org.spigotmc:spigot:$apiVersion | -
176+
spigotApi | org.spigotmc:spigot-api:$apiVersion | spigot
177+
bukkit | org.bukkit:bukkit:$apiVersion | spigot
178+
craftbukkit | org.bukkit:craftbukkit:$apiVersion | -
179+
paperApi | com.destroystokyo.paper:paper-api:$apiVersion | destroystokyo
180+
181+
**Note:** `$apiVersion` - is `${version}-R0.1-SNAPSHOT` (where `$version` is `bukkit.version`)
182+
183+
If you want more extension-functions - you can [write issue](https://github.com/EndlessCodeGroup/BukkitGradle/issues/new).
184+
115185
### Running Dev server
116-
Before running server you should configure BuildTools and dev server location.
186+
Before running server you should configure dev server location.
117187

118-
You can define it in `local.properties` file (that was automatically created in project root on refresh):
188+
You can define it in `local.properties` file (that was automatically created in project directory on refresh):
119189
```properties
120-
# Absolute path to directory that contains BuildTools.jar
121-
buildtools.dir=/path/to/buildtools/
122190
# Absolute path to dev server
123191
server.dir=/path/to/buildtools/
124192
```
125-
Or you can define it globally (for all projects that uses BukkitGradle) with environment variables `BUKKIT_DEV_SERVER_HOME`
193+
194+
If you use Spigot (see `bukkit.run.core`) you also should specify BuildTools location. For Paper no additional actions
195+
needed.
196+
```properties
197+
# Absolute path to directory that contains BuildTools.jar
198+
buildtools.dir=/path/to/buildtools/
199+
```
200+
If there no BuildTools.jar it will be automatically downloaded.
201+
202+
**TIP:** you can define it globally (for all projects that uses BukkitGradle) with environment variables `BUKKIT_DEV_SERVER_HOME`
126203
and `BUILDTOOLS_HOME`.
127204

128205
##### On IntelliJ IDEA
@@ -132,26 +209,28 @@ server configurations.
132209
![Run Configuration](http://image.prntscr.com/image/1a12a03b8ac54fccb7d5b70a335fa996.png)
133210

134211
##### On other IDEs
135-
Run ':startServer' task.
212+
Run `:startServer` task.
136213

137214
#### Server run configurations
138215
To accept EULA and change settings use `bukkit.run` section:
139216
```groovy
140217
bukkit {
141218
// INFO: Here used default values
142219
run {
143-
// Accept EULA
144-
eula = false
145-
// Set online-mode flag
146-
onlineMode = false
147-
// Debug mode (listen 5005 port, if you use running from IDEA this option will be ignored)
148-
debug = true
149-
// Set server encoding (flag -Dfile.encoding)
150-
encoding = "UTF-8"
151-
// JVM arguments
152-
javaArgs = "-Xmx1G"
153-
// Bukkit arguments
154-
bukkitArgs = ""
220+
// Core type. It can be 'spigot' or 'paper'
221+
core = "spigot"
222+
// Accept EULA
223+
eula = false
224+
// Set online-mode flag
225+
onlineMode = false
226+
// Debug mode (listen 5005 port, if you use running from IDEA this option will be ignored)
227+
debug = true
228+
// Set server encoding (flag -Dfile.encoding)
229+
encoding = "UTF-8"
230+
// JVM arguments
231+
javaArgs = "-Xmx1G"
232+
// Bukkit arguments
233+
bukkitArgs = ""
155234
}
156235
}
157236
```

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
group=ru.endlesscode
22
description=Bukkit Gradle integration plugins
3-
version=0.7.1
3+
version=0.8.0
44
org.gradle.jvmargs=-Xmx3G
55
org.gradle.parallel=true
66
org.gradle.daemon=true

src/main/groovy/ru/endlesscode/bukkitgradle/BukkitGradlePlugin.groovy

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ class BukkitGradlePlugin implements Plugin<Project> {
2525
/**
2626
* Configures project
2727
*/
28-
void configureProject() {
28+
private void configureProject() {
2929
addPlugins()
3030
configureEncoding()
3131
addRepositories()
32-
addDependencies()
32+
addExtensionFunctions()
3333
}
3434

3535
/**
3636
* Adds all needed plugins
3737
*/
38-
void addPlugins() {
38+
private void addPlugins() {
3939
project.with {
4040
plugins.with {
4141
apply('java')
@@ -54,7 +54,7 @@ class BukkitGradlePlugin implements Plugin<Project> {
5454
/**
5555
* Sets force encoding on compile to UTF-8
5656
*/
57-
void configureEncoding() {
57+
private void configureEncoding() {
5858
project.tasks.withType(JavaCompile) {
5959
options.encoding = 'UTF-8'
6060
}
@@ -63,29 +63,22 @@ class BukkitGradlePlugin implements Plugin<Project> {
6363
/**
6464
* Adds needed repositories
6565
*/
66-
void addRepositories() {
67-
project.with {
68-
repositories {
69-
mavenLocal()
70-
mavenCentral()
71-
72-
maven {
73-
name = 'sk89q'
74-
url = 'http://maven.sk89q.com/repo/'
75-
}
76-
77-
maven {
78-
name = 'spigot'
79-
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
80-
}
81-
}
66+
private void addRepositories() {
67+
project.repositories {
68+
mavenLocal()
69+
mavenCentral()
8270
}
8371
}
8472

8573
/**
86-
* Adds needed dependencies
74+
* Adds repositories and dependencies extension functions
8775
*/
88-
void addDependencies() {
76+
private void addExtensionFunctions() {
77+
project.repositories {
78+
mavenLocal()
79+
mavenCentral()
80+
}
81+
8982
Dependencies.configureProject(project)
9083
}
9184
}

src/main/groovy/ru/endlesscode/bukkitgradle/DevServerPlugin.groovy

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

3+
import org.gradle.api.GradleException
34
import org.gradle.api.Plugin
45
import org.gradle.api.Project
5-
import org.gradle.internal.impldep.org.apache.maven.lifecycle.LifecycleExecutionException
66
import ru.endlesscode.bukkitgradle.server.ServerCore
77
import ru.endlesscode.bukkitgradle.task.PrepareServer
88
import ru.endlesscode.bukkitgradle.task.RunServer
@@ -26,20 +26,20 @@ class DevServerPlugin implements Plugin<Project> {
2626
PrepareServer prepareServer = project.task(
2727
'prepareServer',
2828
type: PrepareServer,
29-
dependsOn: ['build', 'buildServerCore', 'copyServerCore']
29+
dependsOn: ['build', 'copyServerCore']
3030
) {
3131
group = BukkitGradlePlugin.GROUP
3232
description = 'Prepare server ro run. Configure server and copy compiled plugin to plugins dir'
3333
core serverCore
3434
} as PrepareServer
3535

36-
Path runConfigurationsDir = project.projectDir.toPath().resolve(".idea/runConfigurations")
36+
Path runConfigurationsDir = project.rootProject.projectDir.toPath().resolve(".idea/runConfigurations")
3737
project.task('buildIdeaRun', dependsOn: 'prepareServer') {
3838
group = BukkitGradlePlugin.GROUP
3939
description = 'Configure IDEA server run configuration'
4040
}.doLast {
4141
if (Files.notExists(runConfigurationsDir.parent)) {
42-
throw new LifecycleExecutionException("This task only for IntelliJ IDEA.")
42+
throw new GradleException("This task only for IntelliJ IDEA.")
4343
}
4444

4545
Files.createDirectories(runConfigurationsDir)

src/main/groovy/ru/endlesscode/bukkitgradle/extension/RunConfiguration.groovy

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ru.endlesscode.bukkitgradle.extension
22

33
import groovy.xml.MarkupBuilder
44
import org.gradle.api.Project
5+
import ru.endlesscode.bukkitgradle.server.CoreType
56
import ru.endlesscode.bukkitgradle.server.ServerCore
67
import ru.endlesscode.bukkitgradle.task.PrepareServer
78

@@ -21,9 +22,13 @@ class RunConfiguration {
2122
String javaArgs
2223
String bukkitArgs
2324

25+
private CoreType coreType
26+
2427
RunConfiguration(Project project) {
2528
this.project = project
2629

30+
this.coreType = CoreType.SPIGOT
31+
2732
this.eula = false
2833
this.onlineMode = false
2934
this.debug = true
@@ -33,6 +38,20 @@ class RunConfiguration {
3338
this.bukkitArgs = ''
3439
}
3540

41+
void setCore(String core) {
42+
try {
43+
coreType = CoreType.valueOf(core.toUpperCase())
44+
} catch (IllegalArgumentException ignored) {
45+
project.logger.warn("Core type '$core' not found. May be it doesn't supported by BukkitGradle yet. " +
46+
"You may write issue on GitHub to request supporting.\n" +
47+
"Fallback core type is '${coreType.toString().toLowerCase()}'")
48+
}
49+
}
50+
51+
def getCoreType() {
52+
return coreType
53+
}
54+
3655
/**
3756
* Returns arguments for java
3857
*
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package ru.endlesscode.bukkitgradle.server
2+
3+
enum CoreType {
4+
SPIGOT, PAPER
5+
}

0 commit comments

Comments
 (0)