-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.gradle
156 lines (128 loc) · 3.89 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import de.undercouch.gradle.tasks.download.Download
import org.apache.tools.ant.filters.ReplaceTokens
buildscript {
repositories {
jcenter()
}
dependencies {
classpath group: 'com.github.rodionmoiseev.gradle.plugins', name: 'idea-utils', version: '0.2'
}
}
plugins {
id "com.github.johnrengelman.shadow" version "1.2.3"
id "de.undercouch.download" version "3.1.1"
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'idea-utils'
idea {
project {
ipr {
withXml { xmlProvider ->
def project = xmlProvider.asNode()
def runConfigs = new XmlParser().parse(new File("config/intellij_runconfigs.xml"))
project.append(runConfigs)
}
}
}
}
repositories {
mavenLocal()
mavenCentral()
}
group = project.property("group")
version = project.property("version")
sourceCompatibility = project.property("sourceversion")
dependencies {
compile group: 'org.spigotmc', name: 'spigot-api', version: project.property("apiversion")
compile group: 'org.spigotmc', name: 'spigot', version: project.property("apiversion")
// dependencies go here
// Example:
// compile group: 'com.google.guava', name: 'guava', version: '19.0'
}
processResources {
filter ReplaceTokens, tokens: [
"apiversion": project.property("apiversion"),
"version" : project.property("version")
]
}
clean {
delete "final/"
delete "testserver/"
}
compileJava.dependsOn {
buildSpigot
}
jar {
actions = []
dependsOn = []
dependsOn('shadowJar')
}
shadowJar {
dependencies {
exclude(dependency('org.spigotmc:spigot-api:.*'))
exclude(dependency('org.spigotmc:spigot:.*'))
}
}
task deploy(type: Copy, dependsOn: ['build']) {
from "${buildDir}/libs"
into "final/"
}
task setupDevServer(dependsOn: 'extractServerJar', type: Copy) {
from 'config/serverfiles'
into 'testserver'
}
task extractServerJar(type: Copy) {
from {
configurations.runtime
}
include("spigot-" + project.property("apiversion") + ".jar")
rename("spigot-" + project.property("apiversion") + ".jar", "server.jar")
into "testserver/"
}
task copyPluginToTestserver(dependsOn: ['build'], type: Copy) {
from "${buildDir}/libs"
into "testserver/plugins"
}
task prepareDevServer(dependsOn: ['buildSpigot', 'setupDevServer', 'copyPluginToTestserver']) {}
task startDevServer(dependsOn: [prepareDevServer], type: JavaExec) {
classpath configurations.compile, configurations.runtime
main = "org.bukkit.craftbukkit.Main"
workingDir = "testserver/"
standardInput = System.in
}
// START Building Spigot and Bukkit
def spigotBuildDir = new File("$buildDir/spigot/")
task setupWorkspace(dependsOn: ['buildSpigot']) {
}
task buildSpigot(type: JavaExec) {
if (hasSpigot()) {
enabled = false;
dependsOn = [];
} else {
dependsOn = ['cleanSpigotBuild', 'downloadBuildTool']
}
main = '-jar'
args new File(spigotBuildDir, "BuildTools.jar").getAbsolutePath(), "--rev", project.property("apibuildtoolversion")
workingDir = spigotBuildDir
}
task downloadBuildTool(type: Download) {
spigotBuildDir.mkdirs()
src project.property("buildtoolurl")
dest new File(spigotBuildDir, "BuildTools.jar")
}
task cleanSpigotBuild() {
spigotBuildDir.deleteDir()
}
def hasSpigot() {
def groupId = "org.spigotmc"
def version = project.property("apiversion")
return hasArtifact(groupId, "spigot-api", version) && hasArtifact(groupId, "spigot", version)
}
def hasArtifact(groupId, artifactId, version) {
def localMavenRepo = new File(new File(ant.properties['user.home'] as String), ".m2/repository/")
def file = new File(localMavenRepo, groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/")
return file.exists()
}
// END Building Spigot and Bukkit