-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
205 lines (171 loc) · 5.77 KB
/
Copy pathbuild.gradle
File metadata and controls
205 lines (171 loc) · 5.77 KB
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
import groovy.json.JsonSlurper
import java.nio.charset.StandardCharsets
import java.nio.file.FileVisitResult
import java.nio.file.Files
import java.nio.file.SimpleFileVisitor
import java.nio.file.StandardCopyOption
import java.nio.file.Paths
import java.nio.file.attribute.BasicFileAttributes
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kotlin.ksp)
alias(libs.plugins.kotlin.assert)
id 'maven-publish'
id 'java-library'
}
def json = new JsonSlurper()
def mod = json.parse("${projectDir}/src/main/resources/plugin.json" as File)
group = 'mindurka'
version = "${mod['version']}"
compileJava.options.encoding = "UTF-8"
def workspacePath = gradle.ext.workspacePath
allprojects {
repositories {
mavenCentral()
}
}
apply from: "$workspacePath/.cache/tools/buildscript/shared.repos.gradle"
java {
withSourcesJar()
withJavadocJar()
}
publishing {
publications {
internal(MavenPublication) {
from components.java
version "latest-SNAPSHOT"
}
}
repositories {
maven {
url = "file://$workspacePath/.cache/maven"
}
}
}
dependencies {
compileOnly files("$workspacePath/.cache/tools/buildscript/server-release.jar")
implementation libs.bundles.kotlin.serialization
implementation libs.kotlin.reflect
implementation libs.kotlin.datetime
implementation libs.kotlin.coro
implementation libs.rabbitmq.amqp
implementation libs.surrealdb
implementation libs.bundles.jline
implementation libs.jansi
testImplementation "org.jetbrains.kotlin:kotlin-test"
testImplementation files("$workspacePath/.cache/tools/buildscript/server-release.jar")
implementation project(':annotations')
implementation project(':buildExtras')
ksp project(':processor')
}
sourceSets {
main {
kotlin {
srcDir "build/generated/buildtime"
}
}
}
jar {
from ({ configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }) {
exclude 'doc/**'
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
powerAssert {
functions = ["kotlin.assert", "kotlin.test.assertTrue", "kotlin.test.assertEquals", "kotlin.test.assertNull"]
includedSourceSets = ["main", "test"]
}
test {
useJUnitPlatform()
testLogging {
events "skipped", "failed"
showExceptions true
exceptionFormat "full"
showCauses true
showStackTraces true
}
}
tasks.named("compileKotlin") {
dependsOn "generateExtras"
}
tasks.register("generateExtras") {
def rpath = rootDir
doLast {
def path = rpath.toPath().resolve("build/generated/buildtime")
if (Files.exists(path)) Files.walkFileTree(path, new SimpleFileVisitor<java.nio.file.Path>() {
@Override
FileVisitResult visitFile(java.nio.file.Path file, BasicFileAttributes attrs) {
Files.delete(file)
return FileVisitResult.CONTINUE
}
@Override
FileVisitResult postVisitDirectory(java.nio.file.Path file, IOException exc) {
Files.delete(file)
return FileVisitResult.CONTINUE
}
})
Files.createDirectories(path.resolve("mindurka/coreplugin/"))
def builder = new StringBuilder()
builder.append("package mindurka.coreplugin\n\n")
builder.append("/** Compile time info passed to CorePlugin. */\n")
builder.append("object Build {\n")
builder.append(" /** Commit hash of CorePlugin. */\n")
builder.append(" @JvmField\n")
builder.append(" val gitCommit = \"${"git rev-parse HEAD".execute().inputReader().readLine().trim()}\"\n")
builder.append("}\n")
Files.write(path.resolve("mindurka/coreplugin/Build.kt"), builder.toString().getBytes(StandardCharsets.UTF_8))
}
}
tasks.named("build") {
dependsOn ":test"
def jarPath = Paths.get("${jar.archivePath}")
doLast {
Files.createDirectories(workspacePath.resolve(".bin"))
Files.copy(
jarPath,
workspacePath.resolve(".bin/CorePlugin.jar"),
StandardCopyOption.REPLACE_EXISTING)
println "Copied CorePlugin to '$workspacePath/.bin/CorePlugin.jar'"
}
}
// tasks.register("runServer") {
// dependsOn build
//
// doLast {
// def path = rootProject.rootDir.toPath().resolve("run")
// Files.createDirectories(path.resolve("config/mods"))
// Files.createDirectories(path.resolve("config/maps"))
//
// if (!Files.exists(path.resolve("server.jar"))) {
// println "Downloading Mindustry server..."
// Files.copy(
// new URI("https://github.com/Anuken/Mindustry/releases/download/v146/server-release.jar").toURL().openStream(),
// path.resolve("server.jar"))
// Files.copy(
// rootDir.toPath().resolve("assets/Crashtest.msav"),
// path.resolve("config/maps/Crashtest.msav"))
// Files.copy(
// rootDir.toPath().resolve("assets/settings.bin"),
// path.resolve("config/settings.bin"))
// }
//
// Files.copy(
// jar.archiveFile.get().asFile.toPath(),
// path.resolve("config/mods/Debug.jar"),
// StandardCopyOption.REPLACE_EXISTING)
//
// javaexec {
// classpath = files(path.resolve("server.jar"))
// workingDir = path.toFile()
// standardInput = System.in
//
// debugOptions {
// enabled = true
// port = 7857
// server = true
// suspend = false
// }
// }
// }
// }