generated from Devan-Kerman/Spigot-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
83 lines (69 loc) · 2.52 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
plugins {
id "com.github.johnrengelman.shadow" version "5.2.0"
id 'java'
}
group = pluginGroup
version = pluginVersion
def mcVersion = minecraftVersion
def paper = paperBuild
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
repositories {
mavenCentral()
maven {
name = 'papermc-repo'
url = 'https://papermc.io/repo/repository/maven-public/'
}
maven {
name = 'nbt api people'
url = 'https://repo.codemc.org/repository/maven-public/'
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compileOnly 'org.bukkit:bukkit:1.12.2-R0.1-SNAPSHOT'
compile group: 'it.unimi.dsi', name: 'fastutil', version: '8.3.0'
compile fileTree(dir: 'libs', include: '*.jar')
compile "de.tr7zw:item-nbt-api:2.2.0"
compileOnly group: 'org.jetbrains', name: 'annotations', version: '19.0.0'
}
shadowJar {
from sourceSets.main.java
from sourceSets.main.output
destinationDir = 'run/plugins' as File
relocate 'de.tr7zw.changeme.nbtapi', 'net.devtech.tr7zw.nbtapi'
relocate 'it.unimi.dsi', 'net.devtech.fastutil'
}
task validateMain {
println("validating main class")
char sep = File.separatorChar
sourceSets.main.java.srcDirs.forEach {
File file = new File(it, "${pluginGroup.replace('.' as char, sep)}$sep${pluginName.toLowerCase()}$sep${pluginName}.java")
if(!file.exists())
throw new IllegalArgumentException("Update your gradle.properties! main class must be pluginGroup.pluginname.PluginName!")
}
}
task installPaper {
def f = new File('run/paperclip.jar')
if (!f.exists()) {
f.parentFile.mkdirs()
def url = new URL("https://papermc.io/api/v1/paper/$mcVersion/$paper/download")
def con = url.openConnection();
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0")
IOGroovyMethods.withStream(con.getInputStream(), { i -> f.withOutputStream { it << i } })
// eula pls
Runtime.getRuntime().exec("java -jar paperclip.jar", null, new File('run')).waitFor()
}
}
tasks.jar.dependsOn tasks.shadowJar
tasks.build.dependsOn tasks.validateMain
init.doLast {
installPaper
}
import org.apache.tools.ant.filters.ReplaceTokens
import org.codehaus.groovy.runtime.IOGroovyMethods
processResources {
from(sourceSets.main.resources.srcDirs) {
filter ReplaceTokens, tokens: [version: version, group: pluginGroup, pluginName: pluginName, pluginname: pluginName.toLowerCase()]
}
}