228 lines
6.1 KiB
Groovy
228 lines
6.1 KiB
Groovy
plugins {
|
|
id "java-library"
|
|
id "maven-publish"
|
|
}
|
|
|
|
repositories {
|
|
ivy {
|
|
name "Cosmic Reach"
|
|
url "https://github.com/CRModders/CosmicArchive/raw/main/versions"
|
|
patternLayout {
|
|
artifact "[classifier]/[revision]/client/Cosmic-Reach-[revision].jar"
|
|
}
|
|
// This is required in Gradle 6.0+ as metadata file (ivy.xml) is mandatory
|
|
metadataSources {
|
|
artifact()
|
|
}
|
|
|
|
content {
|
|
includeModule "finalforeach", "cosmicreach"
|
|
}
|
|
}
|
|
|
|
ivy {
|
|
name "Cosmic Reach"
|
|
url "https://github.com/CRModders/CosmicArchive/raw/main/versions"
|
|
patternLayout {
|
|
artifact "[classifier]/[revision]/server/Cosmic-Reach-Server-[revision].jar"
|
|
}
|
|
// This is required in Gradle 6.0+ as metadata file (ivy.xml) is mandatory
|
|
metadataSources {
|
|
artifact()
|
|
}
|
|
|
|
content {
|
|
includeModule "finalforeach", "cosmicreach-server"
|
|
}
|
|
}
|
|
|
|
|
|
maven {
|
|
name "crmReleases"
|
|
url "https://maven.crmodders.dev/releases"
|
|
}
|
|
maven {
|
|
name "crmReleases"
|
|
url "https://maven.crmodders.dev/snapshots"
|
|
}
|
|
maven {
|
|
name "JitPack"
|
|
url "https://jitpack.io"
|
|
}
|
|
maven {
|
|
name "Quilt"
|
|
url "https://maven.quiltmc.org/repository/release"
|
|
}
|
|
maven {
|
|
name "Fabric"
|
|
url "https://maven.fabricmc.net/"
|
|
}
|
|
maven {
|
|
name "Sponge"
|
|
url "https://repo.spongepowered.org/maven/"
|
|
}
|
|
|
|
mavenCentral()
|
|
|
|
flatDir {
|
|
dirs "${rootDir}/mods/"
|
|
content {
|
|
includeGroup "quilt-mod"
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
configurations {
|
|
// Config to provide the Cosmic Reach project
|
|
cosmicreach
|
|
// Config to provide the Cosmic Reach project
|
|
cosmicreachServer
|
|
|
|
// Allows cosmic reach to be used in the codebase
|
|
compileOnly.extendsFrom(cosmicreach)
|
|
compileOnly.extendsFrom(cosmicreachServer)
|
|
|
|
|
|
|
|
internal {
|
|
visible = false
|
|
canBeConsumed = false
|
|
canBeResolved = false
|
|
}
|
|
compileClasspath.extendsFrom(internal)
|
|
runtimeClasspath.extendsFrom(internal)
|
|
testCompileClasspath.extendsFrom(internal)
|
|
testRuntimeClasspath.extendsFrom(internal)
|
|
|
|
}
|
|
|
|
|
|
dependencies {
|
|
// Cosmic Reach jar
|
|
cosmicreach "finalforeach:cosmicreach:${cosmic_reach_version}:pre-alpha"
|
|
cosmicreachServer "finalforeach:cosmicreach-server:${cosmic_reach_server_version? cosmic_reach_server_version: cosmic_reach_version}:pre-alpha"
|
|
|
|
// Cosmic Quilt
|
|
internal "org.codeberg.CRModders:cosmic-quilt:${cosmic_quilt_version}"
|
|
// Modmenu
|
|
// internal "org.codeberg.CRModders:modmenu:${modmenu_version}"
|
|
|
|
//quiltMod "quilt-mod:fluxapi:0.5.8r2"
|
|
//quiltMod "dev.crmodders:fluxapi:${fluxapi_version}"//0.5.5
|
|
|
|
def dir = new File(project.projectDir, "src/main/resources/${id}");
|
|
def dir_path = dir.getPath()
|
|
|
|
def files = dir.listFiles().toList();
|
|
List<String> paths = new ArrayList<String>();
|
|
|
|
while (files.size()>0){
|
|
File file = files[0]
|
|
files.remove(0)
|
|
if (file.isDirectory())
|
|
files.addAll(file.listFiles().toList())
|
|
else
|
|
paths.add(file.getPath())
|
|
}
|
|
|
|
String assets_txt = new File(project.projectDir,"src/main/resources/${id}/assets.txt")
|
|
FileWriter writer = new FileWriter(assets_txt)
|
|
String txt = ""
|
|
for (String path in paths) {
|
|
String sb = path.replace(dir_path+"/","${id}:").replace(dir_path+"\\","${id}:");
|
|
txt += sb+"\n";
|
|
}
|
|
writer.write(txt)
|
|
writer.close()
|
|
}
|
|
|
|
processResources {
|
|
def resourceTargets = [ // Locations of where to inject the properties
|
|
"quilt.mod.json"
|
|
]
|
|
|
|
// Left item is the name in the target, right is the varuable name
|
|
def replaceProperties = [
|
|
"mod_version" : project.version,
|
|
"mod_group" : project.group,
|
|
"mod_name" : project.name,
|
|
"mod_id" : id,
|
|
]
|
|
|
|
|
|
inputs.properties replaceProperties
|
|
replaceProperties.put "project", project
|
|
filesMatching(resourceTargets) {
|
|
expand replaceProperties
|
|
}
|
|
}
|
|
|
|
|
|
tasks.register("runClient", JavaExec) {
|
|
// We need to build the jar before we can actually run
|
|
dependsOn "jar"
|
|
|
|
// We need to use Quilt's main class so that we can actually modify the game
|
|
mainClass = "dev.crmodders.cosmicquilt.loader.knot.KnotClient"
|
|
// Tells this task the dependencies needed for it to run properly.
|
|
classpath sourceSets.main.runtimeClasspath
|
|
|
|
// Allows stuff to be found through the classpath
|
|
jvmArgs "-Dloader.development=true"
|
|
// Tells the loader where the game jar is located
|
|
jvmArgs "-Dloader.gameJarPath=" + configurations.cosmicreach.asPath
|
|
|
|
// Change the run directory
|
|
File runningDir = new File("run/")
|
|
if (!runningDir.exists())
|
|
runningDir.mkdirs()
|
|
workingDir = runningDir
|
|
}
|
|
|
|
tasks.register("runServer", JavaExec) {
|
|
// We need to build the jar before we can actually run
|
|
dependsOn "jar"
|
|
|
|
standardInput = System.in
|
|
// We need to use Quilt's main class so that we can actually modify the game
|
|
mainClass = "dev.crmodders.cosmicquilt.loader.knot.KnotServer"
|
|
// Tells this task the dependencies needed for it to run properly.
|
|
classpath sourceSets.main.runtimeClasspath
|
|
|
|
// Allows stuff to be found through the classpath
|
|
jvmArgs "-Dloader.development=true"
|
|
// Tells the loader where the game jar is located
|
|
jvmArgs "-Dloader.gameJarPath=" + configurations.cosmicreachServer.asPath
|
|
|
|
// Change the run directory
|
|
File runningDir = new File("run/")
|
|
if (!runningDir.exists())
|
|
runningDir.mkdirs()
|
|
workingDir = runningDir
|
|
}
|
|
|
|
|
|
java {
|
|
withSourcesJar()
|
|
// withJavadocJar() // If docs are included with the project, this line can be un-commented
|
|
|
|
// Sets the Java version
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
|
|
publishing {
|
|
publications {
|
|
maven(MavenPublication) {
|
|
groupId = group
|
|
artifactId = id
|
|
|
|
from components.java
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
|
|
}
|
|
}
|