plugins {
	id 'java-library'
	id 'eclipse'
	id 'idea'
	id 'net.neoforged.moddev' version '2.0.76'
}

import groovy.json.JsonOutput
import groovy.json.JsonSlurper

version = '1.10'
group = 'net.geforcemods.securitycraft'

base {
	archivesName = 'securitycraft'
}

java.toolchain.languageVersion = JavaLanguageVersion.of(21)
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))

processResources {
	exclude ".cache"
	duplicatesStrategy = 'include'

	//minify json resources
	doLast {
		fileTree(dir: outputs.files.asPath, include: "**/*.json").each {
			File file -> file.text = JsonOutput.toJson(new JsonSlurper().parse(file))
		}
	}
}

sourceSets.main.resources {
	srcDir 'src/generated/resources' //include generated files
}

neoForge {
	version = "21.4.126"
	validateAccessTransformers = true

	runs {
		configureEach {
			logLevel = org.slf4j.event.Level.DEBUG
			gameDirectory = project.file('run/' + name)
			ideName = "SC ${project.mc_version} " + ideName.get()
		}

		client {
			client()
		}

		client2 {
			client()
			gameDirectory = project.file('run/client')
			programArguments.addAll('--username', 'Dev2')
		}

		server {
			server()
			programArgument('-nogui')
		}

		data {
			clientData()
			programArguments.addAll('--mod', 'securitycraft', '--all', '--output', file('src/generated/resources/').getAbsolutePath())
		}
	}

	mods {
		securitycraft {
			sourceSet(sourceSets.main)
		}
	}
}

repositories {
	maven {
		url = "https://cursemaven.com/"
		content {
			includeGroup "curse.maven"
		}
	}

	exclusiveContent {
		forRepository {
			maven {
				url = "https://api.modrinth.com/maven"
			}
		}
		filter {
			includeGroup "maven.modrinth"
		}
	}
}

dependencies {
	compileOnly "curse.maven:architectury-api-419699:5553800" //ftb teams dependency
	compileOnly "curse.maven:ftb-library-forge-404465:5557408" //ftb teams dependency
	compileOnly "curse.maven:ftb-teams-forge-404468:5448371"
	implementation "curse.maven:jei-238222:6557699"
	compileOnly "curse.maven:the-one-probe-245211:5502323"
	compileOnly "curse.maven:jade-324717:6011327"
	implementation "curse.maven:betterf3-401648:5873289"
	implementation "curse.maven:cloth-config-348521:5834708" //betterf3 dependency
	compileOnly "curse.maven:wthit-forge-455982:5977924"
	implementation "curse.maven:badpackets-615134:5430629" //wthit dependency
	compileOnly "curse.maven:projecte-226410:3955047"
	compileOnly "curse.maven:embeddium-908741:6116910"
	implementation "maven.modrinth:sodium:mc1.21.4-0.6.13-neoforge" //incompatible with embeddium
}

tasks.named('jar', Jar).configure {
	exclude('net/geforcemods/securitycraft/datagen/**') //exclude files from the built jar that are only used to generate the assets & data
	archiveFileName = "[${project.mc_version}] SecurityCraft v${version}.jar"
	manifest {
		attributes(["Specification-Title": "SecurityCraft",
					"Specification-Vendor": "Geforce, bl4ckscor3, Redstone_Dubstep",
					"Specification-Version": "${version}",
					"Implementation-Title": "SecurityCraft",
					"Implementation-Version": "${version}",
					"Implementation-Vendor": "Geforce, bl4ckscor3, Redstone_Dubstep"],)
	}
}

tasks.withType(JavaCompile).configureEach {
	options.encoding = 'UTF-8'
	options.release = 21
}

idea {
	module {
		downloadSources = true
		downloadJavadoc = true
	}
}