-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle
161 lines (136 loc) · 5.17 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
157
158
159
160
161
// For those who want the bleeding edge
buildscript {
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven { url = "http://files.minecraftforge.net/maven" }
maven { url 'https://oss.sonatype.org/content/groups/public/' }
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "de.undercouch:gradle-download-task:3.4.3"
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven {
name 'spigot-repo'
url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
}
apply plugin: 'de.undercouch.download'
version = "1.12.2-1.2.1-FirstLight"
group= "com.gmail.nuclearcat1337.snitch_master" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "SnitchMaster"
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}
minecraft {
version = "1.12.2-14.23.5.2768"
runDir = "run"
// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not allways work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_20171003"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}
configurations {
server {
description = 'dependencies that the server should have'
transitive = true
}
}
dependencies {
server group: 'org.spigotmc', name: 'spigot', version: project.property('apiversion')
server group: 'org.bukkit', name: 'craftbukkit', version: project.property('apiversion')
compile group: "info.journeymap", name: "journeymap-api", version: "1.12-1.4", changing: true
testCompile "junit:junit:4.11"
}
processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
def spigotBuildDir = new File("${project.buildDir}/spigot/")
task buildSpigot(type: Exec) {
group = 'spigot server'
if (hasSpigot()) {
enabled = false;
} else {
dependsOn 'downloadBuildTools'
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
commandLine 'where git'.execute().text.trim().replace('cmd\\git.exe', 'bin\\sh.exe'), '-login', '-c', 'java -jar BuildTools.jar --rev ' + project.property('apibuildtoolversion')
} else {
commandLine 'java -jar BuildTools.jar --rev ' + project.property('apibuildtoolversion')
}
workingDir = spigotBuildDir
}
}
task downloadBuildTools(type: de.undercouch.gradle.tasks.download.Download) {
group = 'spigot server'
spigotBuildDir.mkdirs()
src project.property('buildtoolurl')
dest new File(spigotBuildDir, 'BuildTools.jar')
}
task extractServerJar(type: Copy) {
group = 'spigot server'
from {
configurations.server
}
include("spigot-" + project.property("apiversion") + ".jar")
rename("spigot-" + project.property("apiversion") + ".jar", "server.jar")
into "testserver/"
}
task setupDevServer(dependsOn: 'extractServerJar', type: Copy) {
group = 'spigot server'
from 'config/serverfiles'
into 'testserver'
}
task prepareDevServer(dependsOn: ['buildSpigot', 'setupDevServer']) {
group = 'spigot server'
}
task startDevServer(dependsOn: [prepareDevServer], type: JavaExec) {
group = 'spigot server'
description = 'Starts a spigot test server'
classpath configurations.server
main = 'org.bukkit.craftbukkit.Main'
workingDir = 'testserver/'
standardInput = System.in
}
task wrapper(type: Wrapper) {
group = 'spigot server'
description = 'Generates and updates Gradle wrapper files.'
gradleVersion = '4.1'
}
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()
}