-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathbuild.gradle
258 lines (216 loc) · 7.54 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
import java.nio.file.StandardOpenOption
buildscript {
repositories {
maven {url "https://plugins.gradle.org/m2/"}
mavenCentral()
}
dependencies {
classpath "org.apache.httpcomponents:httpmime:4.5.13"
classpath "com.google.code.gson:gson:2.8.6"
classpath "org.apache.httpcomponents:httpclient:4.5.13"
}
}
plugins {
id "com.modrinth.minotaur" version "2.+"
id 'dev.s7a.gradle.minecraft.server' version '1.1.0'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
}
apply from: 'env-variables.gradle'
apply from: 'changelog-util.gradle'
allprojects {
apply plugin: 'java'
apply plugin: 'idea'
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
if (project.name != "Advanced-Portals") {
task buildSubmodules doLast {
task -> println "Building $task.project.name"
}
buildSubmodules.finalizedBy build
}
tasks.processResources {
def files = ["plugin.yml", "bungee.yml"]
filesMatching(files) {
expand(["pluginVersion": project.version])
}
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
ext.branch = rootProject.ext.branch
ext.snapshotName = rootProject.ext.snapshotName
ext.githubSha = rootProject.ext.githubSha
ext.shaRef = rootProject.ext.shaRef
ext.isRelease = rootProject.ext.isRelease
def versionString = (rootProject.file('./version.txt').text + (isRelease ? "" : "-${snapshotName}${shaRef}")).replaceAll('\n', '').replaceAll('\r', '')
setVersion(versionString)
}
println("Branch ${ext.branch}${ext.shaRef} isRelease: '${ext.isRelease}'")
println("Snapshot Name: ${ext.snapshotName}")
println("Github SHA: ${ext.githubSha}")
println("Sha Ref: ${ext.shaRef}")
archivesBaseName = "Advanced-Portals"
group = 'com.sekwah.advancedportals'
println "Version: ${getVersion()}"
description = ""
configurations {
// configuration that holds jars to copy into lib
implementation.extendsFrom(includeLibs)
}
repositories {
maven { url "https://repo.maven.apache.org/maven2" }
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://nexus.velocitypowered.com/repository/maven-public/" }
}
// includeLibs just says to include the library in the final jar
dependencies {
includeLibs project(':lang')
includeLibs project(':core')
includeLibs project(':bungee')
includeLibs project(':spigot')
includeLibs project(':velocity')
}
println "Branch ${ext.branch}${ext.shaRef} isRelease: '${ext.isRelease}'"
tasks.named('jar') {
dependsOn(':core:shadowJar')
}
jar {
// Filters the files out that are in the build folders. Look to see if there is a better way to do this?
from configurations.includeLibs.filter {
it.path.contains("${File.separator}build${File.separator}libs")
} .collect {
println("Will Include: ${it.name}")
it.isDirectory() ? it : zipTree(it)
}
}
// This is used to download my plugin for helping reload the server in tandem with the copyPlugin task
tasks.register('downloadSekCDevToolsPlugin') {
doLast {
// Define the URL and destination path
def url = 'https://github.com/sekwah41/SekCDevToolsPlugin/releases/download/v1.0.0/SekCDevToolsPlugin-1.0-SNAPSHOT.jar'
def destinationDir = new File("$buildDir/MinecraftServer/plugins")
def destinationFile = new File(destinationDir, 'SekCDevToolsPlugin-1.0-SNAPSHOT.jar')
// Create the directory if it doesn't exist
if (!destinationDir.exists()) {
destinationDir.mkdirs()
}
// Download the file if it doesn't exist
if (!destinationFile.exists()) {
println "Downloading SekCDevToolsPlugin..."
new URL(url).withInputStream { i ->
destinationFile.withOutputStream {
it << i
}
}
} else {
println "SekCDevToolsPlugin already downloaded"
}
}
}
tasks.launchMinecraftServer.dependsOn(downloadSekCDevToolsPlugin)
minecraftServerConfig {
jarUrl.set('https://download.getbukkit.org/spigot/spigot-1.20.2.jar')
jvmArgument = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-DIReallyKnowWhatIAmDoingISwear=true"]
}
tasks.withType(Jar).configureEach {
duplicatesStrategy = DuplicatesStrategy.WARN
}
/**
* Will build then copy it to the minecraft server folder for use with the launch task and dev tools plugin
*/
tasks.register('copyPlugin') {
dependsOn(build)
doLast {
copy {
def sourceFilePath = Paths.get("$buildDir/libs/Advanced-Portals-${getVersion()}.jar")
def destinationFilePath = Paths.get("$buildDir/MinecraftServer/plugins/Advanced-Portals.jar")
println "Handling file: $destinationFilePath"
byte[] newContent = Files.readAllBytes(sourceFilePath)
if (Files.exists(destinationFilePath)) {
println "File exists. Overwriting with new binary content."
Files.write(destinationFilePath, newContent, StandardOpenOption.TRUNCATE_EXISTING)
} else {
println "File does not exist. Copying from source."
Files.copy(sourceFilePath, destinationFilePath, StandardCopyOption.REPLACE_EXISTING)
}
}
}
}
// Set SPIGOT_LOC to the location of your server and SPIGOT_JAR as the name of the jar file in the server you want to run
// DIReallyKnowWhatIAmDoingISwear is to remove the stupid pause spigot has at the start
tasks.register('runJar') {
doLast {
javaexec {
main "-jar"
args "${System.env.MC_SERVER_LOC}\\${System.env.MC_SERVER_JAR}.jar"
jvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-DIReallyKnowWhatIAmDoingISwear=true"]
workingDir "${System.env.MC_SERVER_LOC}"
}
}
}
idea {
project {
settings {
taskTriggers {
afterSync(project(':core').tasks.named('generateTemplates'))
}
}
}
}
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = project.modrinth_slug
versionType = "release"
uploadFile = jar
loaders = ["spigot", "bukkit", "paper", "velocity", "waterfall", "bungeecord", "purpur"]
gameVersions = [
"1.13",
"1.13.1",
"1.13.2",
"1.14",
"1.14.1",
"1.14.2",
"1.14.3",
"1.14.4",
"1.15",
"1.15.1",
"1.15.2",
"1.16",
"1.16.1",
"1.16.2",
"1.16.3",
"1.16.4",
"1.16.5",
"1.17",
"1.17.1",
"1.18",
"1.18.1",
"1.18.2",
"1.19",
"1.19.1",
"1.19.2",
"1.19.3",
"1.19.4",
"1.20",
"1.20.1",
"1.20.2",
"1.20.3",
"1.20.4",
"1.20.5",
"1.20.6",
"1.21",
"1.21.1",
"1.21.2",
"1.21.3",
"1.21.4"
]
changelog = getReleaseChangelog()
syncBodyFrom = rootProject.file("README.md").text
}
tasks.modrinth.dependsOn(tasks.modrinthSyncBody)
apply from: 'curse.gradle'
apply from: 'discord.gradle'