CR_OmniPower_Mod/build.gradle
pietru f08b8d340f
All checks were successful
/ Auto-Build-App (push) Successful in 2m22s
update events
2024-09-19 16:49:22 +02:00

185 lines
4.7 KiB
Groovy

plugins {
id "application"
id "maven-publish"
}
repositories {
ivy {
name "Cosmic Reach"
url "https://github.com/CRModders/CosmicArchive/raw/main/versions/pre-alpha"
patternLayout {
artifact "/Cosmic Reach-[revision].jar"
}
// This is required in Gradle 6.0+ as metadata file (ivy.xml) is mandatory
metadataSources {
artifact()
}
content {
includeGroup "finalforeach"
}
}
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 {
cosmicreach // Config to provide the Cosmic Reach project
compileOnly.extendsFrom(cosmicreach) // Allows cosmic reach to be used in the codebase
quiltMod // Config to be able to load Quilt Mods
implementation.extendsFrom(quiltMod)
}
dependencies {
// Cosmic Reach jar
cosmicreach "finalforeach:cosmicreach:${cosmic_reach_version}"
// Cosmic Quilt
//quiltMod "org.codeberg.CRModders:cosmic-quilt:${cosmic_quilt_version}"
implementation "org.codeberg.CRModders:cosmic-quilt:${cosmic_quilt_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
}
}
application {
// As Quilt is our loader, use its main class at:
mainClass = "org.quiltmc.loader.impl.launch.knot.KnotClient"
}
// Sets up all the Quilt Mods
def String getQuiltModLocations(Configuration config) {
StringBuilder sb = new StringBuilder()
for (obj in config.allDependencies) {
sb.append(File.pathSeparator + config.files(obj)[0])
}
return sb.toString()
}
applicationDefaultJvmArgs = [
"-Dloader.skipMcProvider=true", // Stops Quilt from attempting to find mappings, and all the other Minecraft stuff
"-Dloader.gameJarPath=" + configurations.cosmicreach.asPath, // Defines path to Cosmic Reach
"-Dloader.addMods=" +
jar.archiveFile.get().asFile + // Add the jar of this project
getQuiltModLocations(configurations.quiltMod) // Adds the jars of any Quilt mods added
]
run {
// To run this project in the game, depend on the creation of jar task
dependsOn "jar"
// Change the run directory
File runningDir = new File("run/")
if (!runningDir.exists())
runningDir.mkdirs()
tasks.run.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 {
}
}