-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle.kts
163 lines (131 loc) · 4.27 KB
/
build.gradle.kts
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
@file:Suppress("NAME_SHADOWING")
import dev.crmodders.cosmicloom.CosmicLoomPlugin
import dev.crmodders.cosmicloom.task.tasks.RunClientTask
import dev.crmodders.cosmicloom.task.tasks.RunServerTask
object Constants {
const val GROUP = "dev.crmodders"
const val MODID = "flux-api"
const val VERSION = "0.8.0-alpha.3"
const val SUBGROUP = "${GROUP}.${MODID}"
const val VERSION_COSMIC_REACH = "0.3.14"
const val VERSION_COSMIC_QUILT = "2.3.2"
}
plugins {
`java-library`
`maven-publish`
id("cosmicloom")
}
base {
group = Constants.GROUP
archivesName = Constants.MODID
version = Constants.VERSION
}
java {
withSourcesJar()
// withJavadocJar()
toolchain {
// Sets the Java version to use
languageVersion = JavaLanguageVersion.of(17)
}
}
subprojects {
apply<JavaLibraryPlugin>()
apply<CosmicLoomPlugin>()
apply<MavenPublishPlugin>()
base {
group = Constants.SUBGROUP
archivesName = name
version = Constants.VERSION
}
}
dependencies {
subprojects {
api(project)
include(project)
}
}
allprojects {
loom {
splitEnvironmentSourceSets()
}
sourceSets {
val client by existing {}
val testmod by registering {
val main = main.get()
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
val testmodClient by registering {
val main = main.get()
val client by getting
val testmod by getting
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
compileClasspath += client.compileClasspath
runtimeClasspath += client.runtimeClasspath
compileClasspath += testmod.compileClasspath
runtimeClasspath += testmod.runtimeClasspath
}
val test by existing {
val testmodClient by getting
compileClasspath += testmodClient.compileClasspath
runtimeClasspath += testmodClient.runtimeClasspath
}
}
dependencies {
cosmicReach(loom.cosmicReachClient("pre-alpha", Constants.VERSION_COSMIC_REACH))
cosmicReachServer(loom.cosmicReachServer("pre-alpha", Constants.VERSION_COSMIC_REACH))
modImplementation(loom.cosmicQuilt(Constants.VERSION_COSMIC_QUILT))
}
tasks {
val runClient by existing(RunClientTask::class)
val runServer by existing(RunServerTask::class)
val runTestmodClient by registering(RunClientTask::class) {
description = "Runs the Cosmic Reach testmod client"
isIgnoreExitValue = true
gameJar = runClient.get().gameJar
source = "testmodClient"
classpath(source.map { sourceSets[it].runtimeClasspath })
}
val runTestmodServer by registering(RunServerTask::class) {
description = "Runs the Cosmic Reach testmod server"
gameJar = runServer.get().gameJar
source = "testmod"
classpath(source.map { sourceSets[it].runtimeClasspath })
}
withType<ProcessResources> {
// Locations of where to inject the properties
val resourceTargets = listOf(
"quilt.mod.json"
)
// Left item is the name in the target, right is the variable name
val replaceProperties = mapOf(
"mod_group" to Constants.GROUP,
"mod_version" to Constants.VERSION,
// Not all versions have both client and server
"cosmic_reach_version" to Constants.VERSION_COSMIC_REACH,
)
inputs.properties(replaceProperties)
filesMatching(resourceTargets) {
expand(replaceProperties)
}
}
}
@Suppress("UnstableApiUsage")
testing {
suites {
val test by getting(JvmTestSuite::class) {
useJUnitJupiter()
}
}
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = project.group as String
artifactId = project.base.archivesName.get()
from(components["java"])
}
}
}
}