-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathterasology-module.gradle.kts
More file actions
193 lines (160 loc) · 6.07 KB
/
Copy pathterasology-module.gradle.kts
File metadata and controls
193 lines (160 loc) · 6.07 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
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
// Simple build file for modules - the one under the Core module is the template, will be copied as needed to modules
import org.gradle.plugins.ide.eclipse.model.EclipseModel
import org.gradle.plugins.ide.idea.model.IdeaModel
import org.terasology.gradology.ModuleMetadataForGradle
plugins {
`java-library`
idea
eclipse
}
val moduleMetadata = ModuleMetadataForGradle.forProject(project)
project.version = moduleMetadata.version
// Jenkins-Artifactory integration catches on to this as part of the Maven-type descriptor
project.group = moduleMetadata.group
logger.info("Version for {} loaded as {} for group {}", project.name, project.version, project.group)
// Grab all the common stuff like plugins to use, artifact repositories, code analysis config, Artifactory settings, Git magic
// Note that this statement is down a ways because it is affected by the stuff higher in this file like setting versioning
apply(from = "$rootDir/config/gradle/publish.gradle")
// Handle some logic related to where what is
configure<SourceSetContainer> {
main {
java.outputDir = buildDir.resolve("classes")
}
test {
java.outputDir = buildDir.resolve("testClasses")
}
}
configurations {
all {
resolutionStrategy.preferProjectModules()
}
}
// Set dependencies. Note that the dependency information from module.txt is used for other Terasology modules
dependencies {
implementation(group = "org.terasology.engine", name = "engine", version = moduleMetadata.engineVersion())
implementation(group = "org.terasology.engine", name = "engine-tests", version = moduleMetadata.engineVersion())
for ((gradleDep, optional) in moduleMetadata.moduleDependencies()) {
if (optional) {
// `optional` module dependencies are ones it does not require for runtime
// (but will use opportunistically if available)
compileOnly(gradleDep.asMap())
// though modules also sometimes use "optional" to describe their test dependencies;
// they're not required for runtime, but they *are* required for tests.
testImplementation(gradleDep.asMap())
} else {
implementation(gradleDep.asMap())
}
}
testRuntimeOnly("org.slf4j:jul-to-slf4j:1.7.21")
add("testImplementation", platform("org.junit:junit-bom:5.7.1"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testImplementation("org.mockito:mockito-junit-jupiter:3.7.7")
}
if (project.name == "ModuleTestingEnvironment") {
dependencies {
// MTE is a special snowflake, it gets these things as non-test dependencies
implementation("ch.qos.logback:logback-classic:1.2.3")
runtimeOnly("org.codehaus.janino:janino:3.1.3") {
because("logback filters")
}
add("implementation", platform("org.junit:junit-bom:5.7.1"))
implementation("org.junit.jupiter:junit-jupiter-api")
implementation("org.mockito:mockito-junit-jupiter:3.7.7")
}
}
// Generate the module directory structure if missing
tasks.register("createSkeleton") {
mkdir("assets")
mkdir("assets/animations")
mkdir("assets/atlas")
mkdir("assets/behaviors")
mkdir("assets/blocks")
mkdir("assets/blockSounds")
mkdir("assets/blockTiles")
mkdir("assets/fonts")
mkdir("assets/i18n")
mkdir("assets/materials")
mkdir("assets/mesh")
mkdir("assets/music")
mkdir("assets/prefabs")
mkdir("assets/shaders")
mkdir("assets/shapes")
mkdir("assets/skeletalMesh")
mkdir("assets/skins")
mkdir("assets/sounds")
mkdir("assets/textures")
mkdir("assets/ui")
mkdir("overrides")
mkdir("deltas")
mkdir("src/main/java")
mkdir("src/test/java")
}
val mainSourceSet: SourceSet = sourceSets[SourceSet.MAIN_SOURCE_SET_NAME]
// This task syncs everything in the assets dir into the output dir, used when jarring the module
tasks.register<Sync>("syncAssets") {
from("assets")
into("${mainSourceSet.output.classesDirs.first()}/assets")
}
tasks.register<Sync>("syncOverrides") {
from("overrides")
into("${mainSourceSet.output.classesDirs.first()}/overrides")
}
tasks.register<Sync>("syncDeltas") {
from("deltas")
into("${mainSourceSet.output.classesDirs.first()}/deltas")
}
// Instructions for packaging a jar file - is a manifest even needed for modules?
tasks.named("jar") {
// Make sure the assets directory is included
dependsOn("syncAssets")
dependsOn("syncOverrides")
dependsOn("syncDeltas")
// Jarring needs to copy module.txt and all the assets into the output
doFirst {
copy {
from("module.txt")
into(mainSourceSet.output.classesDirs.first())
}
}
}
tasks.named<Test>("test") {
description = "Runs all tests (slow)"
useJUnitPlatform ()
systemProperty("junit.jupiter.execution.timeout.default", "4m")
}
tasks.register<Test>("unitTest") {
group = "Verification"
description = "Runs unit tests (fast)"
useJUnitPlatform {
excludeTags = setOf("MteTest", "TteTest")
}
systemProperty("junit.jupiter.execution.timeout.default", "1m")
}
tasks.register<Test>("integrationTest") {
group = "Verification"
description = "Runs integration tests (slow) tagged with 'MteTest' or 'TteTest'"
useJUnitPlatform {
includeTags = setOf("MteTest", "TteTest")
}
systemProperty("junit.jupiter.execution.timeout.default", "4m")
}
// Prep an IntelliJ module for the Terasology module - yes, might want to read that twice :D
configure<IdeaModel> {
module {
// Change around the output a bit
inheritOutputDirs = false
outputDir = buildDir.resolve("classes")
testOutputDir = buildDir.resolve("testClasses")
isDownloadSources = true
}
}
// For Eclipse just make sure the classpath is right
configure<EclipseModel> {
classpath {
defaultOutputDir = file("build/classes")
}
}