-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
151 lines (120 loc) · 3.89 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
plugins {
id("java-library")
id("application")
id("maven-publish")
kotlin("jvm")
}
repositories {
ivy {
name = "Cosmic Reach"
url = uri("https://github.com/CRModders/CosmicArchive/raw/main/versions/")
patternLayout {
artifact("[classifier]/Cosmic Reach-[revision].jar")
}
// This is required in Gradle 6.0+ as metadata file (ivy.xml) is mandatory
metadataSources {
artifact()
}
content {
includeModule("finalforeach", "cosmicreach")
}
}
maven("https://jitpack.io") {
name = "JitPack"
}
maven("https://maven.quiltmc.org/repository/release") {
name = "Quilt"
}
maven("https://maven.fabricmc.net/") {
name = "Fabric"
}
maven("https://repo.spongepowered.org/maven/") {
name = "Sponge"
}
/* // CRM repos, you may or may not want it (you won't need it as CRM stuff is also on jitpack).
maven("https://maven.crmodders.dev/releases") {
name = "crmReleases"
}
*/
mavenCentral()
}
// Config to provide the Cosmic Reach project
val cosmicreach: Configuration by configurations.creating {
configurations.compileOnly.get().extendsFrom(this)
}
// Allows to include something without it being in the maven (recommended to be used when including mods)
val internal: Configuration by configurations.creating {
isVisible = false
isCanBeConsumed = false
isCanBeResolved = false
}
configurations["compileClasspath"].extendsFrom(internal)
configurations["runtimeClasspath"].extendsFrom(internal)
configurations["testCompileClasspath"].extendsFrom(internal)
configurations["testRuntimeClasspath"].extendsFrom(internal)
dependencies {
// Cosmic Reach
cosmicreach("finalforeach:cosmicreach:${project.properties["cosmic_reach_version"].toString()}:pre-alpha")
// Cosmic Quilt
internal("org.codeberg.CRModders:cosmic-quilt:${project.properties["cosmic_quilt_version"].toString()}")
// Modmenu
// internal("org.codeberg.CRModders:modmenu:${project.properties["modmenu_version"].toString()}")
// Kotlin
internal("org.codeberg.CRModders:kosmic:${project.properties["kosmic_version"].toString()}")
}
tasks.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 = mutableMapOf(
"mod_version" to project.version,
"mod_group" to project.group,
"mod_name" to project.name,
"mod_id" to project.properties["id"].toString(),
)
inputs.properties(replaceProperties)
replaceProperties["project"] = project
filesMatching(resourceTargets) {
expand(replaceProperties)
}
}
var jarFile = tasks.named<Jar>("jar").flatMap { jar -> jar.archiveFile }.get().asFile
val defaultArgs = listOf(
"-Dloader.development=true", // Allows stuff to be found through the classpath
"-Dloader.gameJarPath=${cosmicreach.asPath}", // Defines path to Cosmic Reach
)
application {
// As Quilt is our loader, use its main class at:
mainClass = "org.quiltmc.loader.impl.launch.knot.KnotClient"
applicationDefaultJvmArgs = defaultArgs
}
tasks.run.configure {
dependsOn("jar")
val runDir = File("run/")
if (!runDir.exists())
runDir.mkdirs()
workingDir = runDir
}
java {
withSourcesJar()
// withJavadocJar() // If docs are included with the project, this line can be un-commented
}
sourceSets {
main {
java {
srcDir("src/main/java")
}
kotlin {
srcDir("src/main/kotlin")
}
}
}
publishing {
publications.create<MavenPublication>("maven") {
groupId = project.group.toString()
artifactId = project.name
from(components["java"])
}
repositories {
}
}